diff --git a/src/kernel/drivers/interrupts/keyboard/keyboard.c b/src/kernel/drivers/interrupts/keyboard/keyboard.c index 54e5fcd..493608c 100644 --- a/src/kernel/drivers/interrupts/keyboard/keyboard.c +++ b/src/kernel/drivers/interrupts/keyboard/keyboard.c @@ -1,6 +1,10 @@ #include <_stdio.h> +#include #include #include +#include +#include +#include #include #include #include @@ -71,7 +75,11 @@ printf("unknown compound keycode %x\n", scancode); return; } - printf("%s", altKeycodes[scancode]); + Message *message = malloc(sizeof(Message)); + message->data = altKeycodes[scancode]; + message->type = KEYBOARD_STRING; + message->size = strlen(message->data); + listAdd(&(getKeyboardConsumer()->messages), message); return; } if (scancode & 0x80) { @@ -83,19 +91,16 @@ } return; } - if (!(scancode & 0x80)) { - for (uint8_t i = 0; i < sizeof(modifierScancodes); i++) { - if (scancode == modifierScancodes[i]) { - modifiers = modifiers | 0x01 << i; - return; - } + for (uint8_t i = 0; i < sizeof(modifierScancodes); i++) { + if (scancode == modifierScancodes[i]) { + modifiers = modifiers | 0x01 << i; + return; } - if (modifiers & MODIFIER_LEFT_SHIFT || - modifiers & MODIFIER_RIGHT_SHIFT) { - printf("%c", capitalKeycodes[scancode]); - } else { - printf("%c", keycodes[scancode]); - } + } + if (modifiers & MODIFIER_LEFT_SHIFT || modifiers & MODIFIER_RIGHT_SHIFT) { + printf("%c", capitalKeycodes[scancode]); + } else { + printf("%c", keycodes[scancode]); } } diff --git a/src/kernel/drivers/interrupts/keyboard/keyboard.c b/src/kernel/drivers/interrupts/keyboard/keyboard.c index 54e5fcd..493608c 100644 --- a/src/kernel/drivers/interrupts/keyboard/keyboard.c +++ b/src/kernel/drivers/interrupts/keyboard/keyboard.c @@ -1,6 +1,10 @@ #include <_stdio.h> +#include #include #include +#include +#include +#include #include #include #include @@ -71,7 +75,11 @@ printf("unknown compound keycode %x\n", scancode); return; } - printf("%s", altKeycodes[scancode]); + Message *message = malloc(sizeof(Message)); + message->data = altKeycodes[scancode]; + message->type = KEYBOARD_STRING; + message->size = strlen(message->data); + listAdd(&(getKeyboardConsumer()->messages), message); return; } if (scancode & 0x80) { @@ -83,19 +91,16 @@ } return; } - if (!(scancode & 0x80)) { - for (uint8_t i = 0; i < sizeof(modifierScancodes); i++) { - if (scancode == modifierScancodes[i]) { - modifiers = modifiers | 0x01 << i; - return; - } + for (uint8_t i = 0; i < sizeof(modifierScancodes); i++) { + if (scancode == modifierScancodes[i]) { + modifiers = modifiers | 0x01 << i; + return; } - if (modifiers & MODIFIER_LEFT_SHIFT || - modifiers & MODIFIER_RIGHT_SHIFT) { - printf("%c", capitalKeycodes[scancode]); - } else { - printf("%c", keycodes[scancode]); - } + } + if (modifiers & MODIFIER_LEFT_SHIFT || modifiers & MODIFIER_RIGHT_SHIFT) { + printf("%c", capitalKeycodes[scancode]); + } else { + printf("%c", keycodes[scancode]); } } diff --git a/src/kernel/kernel.c b/src/kernel/kernel.c index 6835a28..21f8233 100644 --- a/src/kernel/kernel.c +++ b/src/kernel/kernel.c @@ -3,6 +3,7 @@ #include #include #include +#include #include #include #include @@ -24,6 +25,20 @@ if (isTaskQueueEmpty()) { asm volatile("hlt"); } + Message *message; + while (message = popBeginning(&(getCurrentTask()->messages))) { + switch (message->type) { + case KEYBOARD_CHAR: + printf("%c", message->data); + break; + case KEYBOARD_STRING: + printf("%s", message->data); + break; + default: + printf("unhandeled message recieved!\n"); + } + free(message); + } yields(); } }