formatting and make events const

This commit is contained in:
nub31
2025-08-29 15:30:30 +02:00
parent 9c1b4a2c94
commit 827d27e3e3
7 changed files with 67 additions and 47 deletions

View File

@@ -18,7 +18,7 @@ bool caps_lock = false;
static keyboard_handler_t keyboard_handlers[KEYBOARD_HANDLERS_LENGTH];
static int handler_index = 0;
void handle_keyboard(isr_frame_t* frame)
void handle_keyboard(const isr_frame_t* frame)
{
uint8_t code = inb(0x60);
uint8_t scan_code = code & 0x7F;
@@ -42,7 +42,12 @@ void handle_keyboard(isr_frame_t* frame)
}
default:
{
keyboard_event_t event = { .scan_code = scan_code, .pressed = pressed, .caps_lock = caps_lock, .shift = shift };
keyboard_event_t event = {
.scan_code = scan_code,
.pressed = pressed,
.caps_lock = caps_lock,
.shift = shift,
};
for (int i = 0; i < handler_index; i++)
{
@@ -52,9 +57,10 @@ void handle_keyboard(isr_frame_t* frame)
}
}
void register_keypress_handler(keyboard_handler_t handler)
void register_keypress_handler(const keyboard_handler_t handler)
{
// todo(nub31): remove when a memory allocator is implemented and keyboard_handlers is a dynamic list
// todo(nub31): remove when a memory allocator is implemented and
// keyboard_handlers is a dynamic list
if (handler_index >= KEYBOARD_HANDLERS_LENGTH)
{
vga_print_error();