From 39b47de235fa881637606d777a0f6beb6a5a57dc Mon Sep 17 00:00:00 2001 From: Bad Diode Date: Wed, 12 Oct 2022 14:26:12 +0200 Subject: [PATCH] [WIP] Add front buttons handling --- src/main.c | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/src/main.c b/src/main.c index 8792a9a..c9bd4b1 100644 --- a/src/main.c +++ b/src/main.c @@ -76,11 +76,12 @@ init_input(void) { in.kbd_fd = -1; in.mouse_fd = -1; - in.kbd_fd = open(KBD_PATH, O_RDONLY | O_NONBLOCK); + // in.kbd_fd = open(KBD_PATH, O_RDONLY | O_NONBLOCK); + in.kbd_fd = open("/dev/input/event0", O_RDONLY | O_NONBLOCK); if (in.kbd_fd == -1) { // NOTE: Some applications may not require a keyboard so this is // optional, but we are still displaying an error. - // fprintf(stderr, "error: couldn't open keyboard %s: %s.\n", KBD_PATH, strerror(errno)); + fprintf(stderr, "error: couldn't open keyboard %s: %s.\n", KBD_PATH, strerror(errno)); } // in.mouse_fd = open(MOUSE_PATH, O_RDONLY | O_NONBLOCK); @@ -158,7 +159,7 @@ poll_mouse(void) { void poll_input(void) { - // poll_keyboard(); + poll_keyboard(); poll_mouse(); } @@ -289,6 +290,16 @@ handle_keyboard(void) { case KEY_RIGHT: { rune = 0x80; } break; default: break; } + + // NOTE: Nook overrides. + switch (key_code) { + case 156: { rune = 0x40; } break; // top left + case 139: { rune = 0x40; } break; // bottom left + case 151: { rune = 0x80; } break; // top right + case 158: { rune = 0x80; } break; // bottom right + default: break; + } + if (rune) { controller_now |= rune; continue;