diff options
author | Ian Moffett <ian@osmora.org> | 2025-08-19 20:45:18 +0000 |
---|---|---|
committer | Ian Moffett <ian@osmora.org> | 2025-08-19 20:45:18 +0000 |
commit | b3cb4bb6737585dc72c72b8c0f3ffc94408fb22d (patch) | |
tree | a8beab9662ab7e267648776d043bfda966dfb473 /sys/arch/amd64/isa/i8042.c | |
parent | 35a0640fe55298e206abe62f6509b9fb6e5c616e (diff) |
kernel/amd64: isa: Seperate i8042 capslock logicexpt
This commit moves all of the capslock logic from i8042_kb_getc() into
its own capslock_toggle() function.
Signed-off-by: Ian Moffett <ian@osmora.org>
Diffstat (limited to 'sys/arch/amd64/isa/i8042.c')
-rw-r--r-- | sys/arch/amd64/isa/i8042.c | 43 |
1 files changed, 26 insertions, 17 deletions
diff --git a/sys/arch/amd64/isa/i8042.c b/sys/arch/amd64/isa/i8042.c index 3ae645d..5bc7751 100644 --- a/sys/arch/amd64/isa/i8042.c +++ b/sys/arch/amd64/isa/i8042.c @@ -271,6 +271,31 @@ i8042_en_intr(void) } /* + * Toggle the capslock and LED + */ +static void +capslock_toggle(void) +{ + /* + * In case we are holding the caps lock button down, + * we don't want it to be spam toggled as that would + * be pretty strange looking and probably annoying. + */ + if (!capslock_released) { + return; + } + + capslock_released = false; + capslock = !capslock; + + if (!capslock) { + kbd_set_leds(0); + } else { + kbd_set_leds(I8042_LED_CAPS); + } +} + +/* * Convert scancode to character * * @sc: Scancode @@ -289,23 +314,7 @@ i8042_kb_getc(uint8_t sc, char *chr) return 0; /* Caps lock [press] */ case 0x3A: - /* - * In case we are holding the caps lock button down, - * we don't want it to be spam toggled as that would - * be pretty strange looking and probably annoying. - */ - if (!capslock_released) { - return -EAGAIN; - } - - capslock_released = false; - capslock = !capslock; - - if (!capslock) { - kbd_set_leds(0); - } else { - kbd_set_leds(I8042_LED_CAPS); - } + capslock_toggle(); return -EAGAIN; /* Caps lock [release] */ case 0xBA: |