diff options
author | Bad Diode <bd@badd10de.dev> | 2022-10-12 14:26:12 +0200 |
---|---|---|
committer | Bad Diode <bd@badd10de.dev> | 2022-10-12 14:26:12 +0200 |
commit | 39b47de235fa881637606d777a0f6beb6a5a57dc (patch) | |
tree | 839a62785d4c0ca0f5d50e15673294db41e8c961 | |
parent | c7fd12ca4cd5b98846bf9635d96de9b04b48a0ee (diff) | |
download | uxnfb-39b47de235fa881637606d777a0f6beb6a5a57dc.tar.gz uxnfb-39b47de235fa881637606d777a0f6beb6a5a57dc.zip |
[WIP] Add front buttons handling
-rw-r--r-- | src/main.c | 17 |
1 files changed, 14 insertions, 3 deletions
@@ -76,11 +76,12 @@ init_input(void) { | |||
76 | in.kbd_fd = -1; | 76 | in.kbd_fd = -1; |
77 | in.mouse_fd = -1; | 77 | in.mouse_fd = -1; |
78 | 78 | ||
79 | in.kbd_fd = open(KBD_PATH, O_RDONLY | O_NONBLOCK); | 79 | // in.kbd_fd = open(KBD_PATH, O_RDONLY | O_NONBLOCK); |
80 | in.kbd_fd = open("/dev/input/event0", O_RDONLY | O_NONBLOCK); | ||
80 | if (in.kbd_fd == -1) { | 81 | if (in.kbd_fd == -1) { |
81 | // NOTE: Some applications may not require a keyboard so this is | 82 | // NOTE: Some applications may not require a keyboard so this is |
82 | // optional, but we are still displaying an error. | 83 | // optional, but we are still displaying an error. |
83 | // fprintf(stderr, "error: couldn't open keyboard %s: %s.\n", KBD_PATH, strerror(errno)); | 84 | fprintf(stderr, "error: couldn't open keyboard %s: %s.\n", KBD_PATH, strerror(errno)); |
84 | } | 85 | } |
85 | 86 | ||
86 | // in.mouse_fd = open(MOUSE_PATH, O_RDONLY | O_NONBLOCK); | 87 | // in.mouse_fd = open(MOUSE_PATH, O_RDONLY | O_NONBLOCK); |
@@ -158,7 +159,7 @@ poll_mouse(void) { | |||
158 | 159 | ||
159 | void | 160 | void |
160 | poll_input(void) { | 161 | poll_input(void) { |
161 | // poll_keyboard(); | 162 | poll_keyboard(); |
162 | poll_mouse(); | 163 | poll_mouse(); |
163 | } | 164 | } |
164 | 165 | ||
@@ -289,6 +290,16 @@ handle_keyboard(void) { | |||
289 | case KEY_RIGHT: { rune = 0x80; } break; | 290 | case KEY_RIGHT: { rune = 0x80; } break; |
290 | default: break; | 291 | default: break; |
291 | } | 292 | } |
293 | |||
294 | // NOTE: Nook overrides. | ||
295 | switch (key_code) { | ||
296 | case 156: { rune = 0x40; } break; // top left | ||
297 | case 139: { rune = 0x40; } break; // bottom left | ||
298 | case 151: { rune = 0x80; } break; // top right | ||
299 | case 158: { rune = 0x80; } break; // bottom right | ||
300 | default: break; | ||
301 | } | ||
302 | |||
292 | if (rune) { | 303 | if (rune) { |
293 | controller_now |= rune; | 304 | controller_now |= rune; |
294 | continue; | 305 | continue; |