mirror of
https://github.com/bradgrantham/apple2e.git
synced 2024-09-28 02:55:16 +00:00
implement paste through interface
This commit is contained in:
parent
7192c35a42
commit
32854e2246
@ -1533,6 +1533,13 @@ enum APPLE2Einterface::EventType keyboard_to_mainboard(MAINboard *board)
|
||||
APPLE2Einterface::event e = APPLE2Einterface::dequeue_event();
|
||||
if(e.type == APPLE2Einterface::QUIT) {
|
||||
return APPLE2Einterface::QUIT;
|
||||
} else if(e.type == APPLE2Einterface::PASTE) {
|
||||
for(int i = 0; i < strlen(e.str); i++)
|
||||
if(e.str[i] == '\n')
|
||||
board->enqueue_key('\r');
|
||||
else
|
||||
board->enqueue_key(e.str[i]);
|
||||
free(e.str);
|
||||
} else if(e.type == APPLE2Einterface::KEYDOWN) {
|
||||
if((e.value == APPLE2Einterface::LEFT_SHIFT) || (e.value == APPLE2Einterface::RIGHT_SHIFT))
|
||||
shift_down = true;
|
||||
|
@ -48,7 +48,7 @@ event dequeue_event()
|
||||
{
|
||||
if(event_waiting()) {
|
||||
event e = event_queue.front();
|
||||
event_queue.pop_back();
|
||||
event_queue.pop_front();
|
||||
return e;
|
||||
} else
|
||||
return {NONE, 0};
|
||||
@ -454,17 +454,6 @@ static void redraw(GLFWwindow *window)
|
||||
|
||||
CheckOpenGL(__FILE__, __LINE__);
|
||||
|
||||
if(0) if(mode == TEXT) {
|
||||
printf("------------------------------------------\n");
|
||||
for(int row = 0; row < 24; row++) {
|
||||
printf("|");
|
||||
for(int col = 0; col < 24; col++)
|
||||
fputc(textport[display_page][row][col] & 0x7F, stdout);
|
||||
printf("|\n");
|
||||
}
|
||||
printf("------------------------------------------\n");
|
||||
}
|
||||
|
||||
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
||||
|
||||
if(mode == HIRES) {
|
||||
@ -512,9 +501,6 @@ static void redraw(GLFWwindow *window)
|
||||
glActiveTexture(GL_TEXTURE1);
|
||||
glBindTexture(GL_TEXTURE_RECTANGLE, font_texture);
|
||||
glUniform1i(font_texture_location, 1);
|
||||
cout << elapsed_millis << endl;
|
||||
cout << elapsed_millis /1870 << endl;
|
||||
cout << (elapsed_millis /1870) % 2 << endl;
|
||||
glUniform1i(blink_location, (elapsed_millis / 1870) % 2);
|
||||
|
||||
} else if(mode == LORES) {
|
||||
@ -549,9 +535,20 @@ static void error_callback(int error, const char* description)
|
||||
|
||||
static void key(GLFWwindow *window, int key, int scancode, int action, int mods)
|
||||
{
|
||||
static bool super_down = false;
|
||||
|
||||
if(action == GLFW_PRESS) {
|
||||
if(key == GLFW_KEY_RIGHT_SUPER)
|
||||
super_down = true;
|
||||
else if(key == GLFW_KEY_V) {
|
||||
const char* text = glfwGetClipboardString(window);
|
||||
if (text)
|
||||
event_queue.push_back({PASTE, 0, strdup(text)});
|
||||
} else
|
||||
event_queue.push_back({KEYDOWN, key});
|
||||
} else if(action == GLFW_RELEASE) {
|
||||
if(key == GLFW_KEY_RIGHT_SUPER)
|
||||
super_down = false;
|
||||
event_queue.push_back({KEYUP, key});
|
||||
}
|
||||
}
|
||||
|
@ -2,7 +2,7 @@
|
||||
|
||||
namespace APPLE2Einterface
|
||||
{
|
||||
enum EventType {NONE, KEYDOWN, KEYUP, RESET, REBOOT, QUIT};
|
||||
enum EventType {NONE, KEYDOWN, KEYUP, RESET, REBOOT, PASTE, QUIT};
|
||||
|
||||
const int LEFT_SHIFT = 340;
|
||||
const int LEFT_CONTROL = 341;
|
||||
@ -31,9 +31,11 @@ const int CAPS_LOCK = 280;
|
||||
struct event {
|
||||
EventType type;
|
||||
int value;
|
||||
event(EventType type_, int value_) :
|
||||
char *str;
|
||||
event(EventType type_, int value_, char *str_ = NULL) :
|
||||
type(type_),
|
||||
value(value_)
|
||||
value(value_),
|
||||
str(str_)
|
||||
{}
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user