From 4ff8a6f6d65bb7867854daada597bfe5ca47ec3f Mon Sep 17 00:00:00 2001 From: Marvin Borner Date: Sun, 16 Aug 2020 21:51:51 +0200 Subject: Added support for two-byte scancodes --- kernel/drivers/keyboard.c | 21 ++++++++++++++++++--- kernel/features/syscall.c | 1 + libc/inc/input.h | 4 ++-- 3 files changed, 21 insertions(+), 5 deletions(-) diff --git a/kernel/drivers/keyboard.c b/kernel/drivers/keyboard.c index 1cf103a..b08278d 100644 --- a/kernel/drivers/keyboard.c +++ b/kernel/drivers/keyboard.c @@ -8,16 +8,31 @@ char keymap[128]; +int state = 0; +int merged = 0; void keyboard_handler() { u32 scancode = (u32)inb(0x60); - // TODO: Support multi-byte scancodes - /* printf("%x %x %x %x\n", scancode, inb(0x60), inb(0x60), inb(0x60)); */ + // TODO: Support more than two-byte scancodes + if (scancode == 0xe0) { + merged = 0xe0; + state = 1; + return; + } else { + merged = scancode << 8 | merged; + } + + // TODO: "Merge" scancode to linux keycode? + printf("%x %x = %x\n", scancode, state ? 0xe0 : 0, merged); if ((scancode & 0x80) == 0) { // PRESS event_trigger(EVENT_KEYBOARD, (u32 *)scancode); - } + } else + print("\n"); + + state = 0; + merged = 0; } void keyboard_acknowledge() diff --git a/kernel/features/syscall.c b/kernel/features/syscall.c index 2f2cbbb..2a01d8a 100644 --- a/kernel/features/syscall.c +++ b/kernel/features/syscall.c @@ -14,6 +14,7 @@ void syscall_handler(struct regs *r) { enum sys num = r->eax; + r->eax = 0; printf("[SYSCALL] %d\n", num); switch (num) { diff --git a/libc/inc/input.h b/libc/inc/input.h index be1c0a4..04a0301 100644 --- a/libc/inc/input.h +++ b/libc/inc/input.h @@ -91,8 +91,8 @@ #define KEY_KP0 82 #define KEY_KPDOT 83 -/* #define KEY_ZENKAKUHANKAKU 85 */ -/* #define KEY_102ND 86 */ +#define KEY_ZENKAKUHANKAKU 85 +#define KEY_102ND 86 #define KEY_F11 87 #define KEY_F12 88 #define KEY_RO 89 -- cgit v1.2.3