This commit is contained in:
nub31
2025-09-01 20:06:58 +02:00
parent 1bc122e29a
commit 1ed52d1e9e
14 changed files with 154 additions and 223 deletions

View File

@@ -33,7 +33,7 @@ bool caps_lock = false;
static keyboard_handler_t keyboard_handlers[KEYBOARD_HANDLERS_LENGTH];
static int handler_index = 0;
char scan_code_to_ascii(u8 scan_code)
char scan_code_to_ascii(uint8_t scan_code)
{
if (scan_code >= 128)
{
@@ -52,8 +52,8 @@ char scan_code_to_ascii(u8 scan_code)
void handle_keyboard(const isr_frame_t* frame)
{
u8 code = inb(0x60);
u8 scan_code = code & 0x7F;
uint8_t code = inb(0x60);
uint8_t scan_code = code & 0x7F;
bool pressed = (code & 0x80) == 0;
switch (scan_code)
@@ -82,7 +82,7 @@ void handle_keyboard(const isr_frame_t* frame)
.ascii = scan_code_to_ascii(scan_code),
};
for (int i = 0; i < handler_index; i++)
for (size_t i = 0; i < handler_index; i++)
{
keyboard_handlers[i](&event);
}
@@ -96,9 +96,8 @@ void register_keypress_handler(const keyboard_handler_t handler)
// keyboard_handlers is a dynamic list
if (handler_index >= KEYBOARD_HANDLERS_LENGTH)
{
vga_print_error();
vga_print(" Maximum keyboard handlers reached\n");
kernel_panic();
kprintf("Maximum keyboard handlers reached\n");
kpanic();
}
keyboard_handlers[handler_index] = handler;