mirror of
https://github.com/bradgrantham/apple2e.git
synced 2024-09-27 11:01:13 +00:00
Support Quit on window, clean up a little
This commit is contained in:
parent
e5926d512e
commit
33a78aabe9
15
apple2e.cpp
15
apple2e.cpp
@ -136,7 +136,6 @@ struct APPLE2Edisplay
|
||||
if((within_page >= row_offset) &&
|
||||
(within_page < row_offset + 40)){
|
||||
int col = within_page - row_offset;
|
||||
printf("TEXT WRITE %d %d %d '%c'\n", page, row, col, data);
|
||||
text_page[page][row][col] = data;
|
||||
}
|
||||
}
|
||||
@ -1589,15 +1588,17 @@ map<int, key_to_ascii> interface_key_to_apple2e =
|
||||
{' ', {' ', ' ', 0, 0}},
|
||||
};
|
||||
|
||||
void keyboard_to_mainboard(MAINboard *board)
|
||||
enum event::Type keyboard_to_mainboard(MAINboard *board)
|
||||
{
|
||||
static bool shift_down = false;
|
||||
static bool control_down = false;
|
||||
// skip CAPS for now
|
||||
|
||||
if(interface_event_waiting()) {
|
||||
while(interface_event_waiting()) {
|
||||
event e = interface_dequeue_event();
|
||||
if(e.type == event::KEYDOWN) {
|
||||
if(e.type == event::QUIT) {
|
||||
return event::QUIT;
|
||||
} else if(e.type == event::KEYDOWN) {
|
||||
if((e.value == event::LEFT_SHIFT) || (e.value == event::RIGHT_SHIFT))
|
||||
shift_down = true;
|
||||
else if((e.value == event::LEFT_CONTROL) || (e.value == event::RIGHT_CONTROL))
|
||||
@ -1639,6 +1640,7 @@ void keyboard_to_mainboard(MAINboard *board)
|
||||
control_down = false;
|
||||
}
|
||||
}
|
||||
return event::NONE;
|
||||
}
|
||||
|
||||
|
||||
@ -1717,7 +1719,9 @@ int main(int argc, char **argv)
|
||||
char key;
|
||||
bool have_key = peek_key(&key);
|
||||
|
||||
keyboard_to_mainboard(mainboard);
|
||||
if(keyboard_to_mainboard(mainboard) == event::QUIT) {
|
||||
break;
|
||||
}
|
||||
|
||||
if(have_key) {
|
||||
if(key == '') {
|
||||
@ -1800,5 +1804,6 @@ int main(int argc, char **argv)
|
||||
}
|
||||
}
|
||||
|
||||
stop_keyboard();
|
||||
interface_shutdown();
|
||||
}
|
||||
|
@ -71,7 +71,6 @@ static void error_callback(int error, const char* description)
|
||||
|
||||
static void key(GLFWwindow *window, int key, int scancode, int action, int mods)
|
||||
{
|
||||
printf("key %d(%c), scancode %d, action %d, mods %02X\n", key, isprint(key) ? key : '?', scancode, action, mods);
|
||||
if(action == GLFW_PRESS) {
|
||||
event_queue.push_back({event::KEYDOWN, key});
|
||||
} else if(action == GLFW_RELEASE) {
|
||||
@ -167,7 +166,7 @@ void interface_start()
|
||||
void interface_iterate()
|
||||
{
|
||||
if(glfwWindowShouldClose(window)) {
|
||||
// set to quit
|
||||
event_queue.push_back({event::QUIT, 0});
|
||||
}
|
||||
|
||||
redraw(window);
|
||||
|
@ -1,7 +1,7 @@
|
||||
#include <tuple>
|
||||
|
||||
struct event {
|
||||
enum EventType {NONE, KEYDOWN, KEYUP, RESET, REBOOT} type;
|
||||
enum Type {NONE, KEYDOWN, KEYUP, RESET, REBOOT, QUIT} type;
|
||||
static const int LEFT_SHIFT = 340;
|
||||
static const int LEFT_CONTROL = 341;
|
||||
static const int LEFT_ALT = 342;
|
||||
@ -26,7 +26,7 @@ struct event {
|
||||
static const int END = 269;
|
||||
static const int CAPS_LOCK = 280;
|
||||
int value;
|
||||
event(EventType type_, int value_) :
|
||||
event(Type type_, int value_) :
|
||||
type(type_),
|
||||
value(value_)
|
||||
{}
|
||||
|
Loading…
Reference in New Issue
Block a user