aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBad Diode <bd@badd10de.dev>2022-10-12 14:26:12 +0200
committerBad Diode <bd@badd10de.dev>2022-10-12 14:26:12 +0200
commit39b47de235fa881637606d777a0f6beb6a5a57dc (patch)
tree839a62785d4c0ca0f5d50e15673294db41e8c961
parentc7fd12ca4cd5b98846bf9635d96de9b04b48a0ee (diff)
downloaduxnfb-39b47de235fa881637606d777a0f6beb6a5a57dc.tar.gz
uxnfb-39b47de235fa881637606d777a0f6beb6a5a57dc.zip
[WIP] Add front buttons handling
-rw-r--r--src/main.c17
1 files 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) {
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
159void 160void
160poll_input(void) { 161poll_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;