aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIan Moffett <ian@osmora.org>2024-05-12 23:05:58 -0400
committerIan Moffett <ian@osmora.org>2024-05-12 23:11:00 -0400
commitb3c0e1e2f9bef74b395c9d9f670c93a8d8f5c725 (patch)
treef7d112d37ca15ab04647538c18349a12ef123d8a
parentbfb2bce1a7b4cb623e2ace5b6b2fa6718bd6e2bc (diff)
kernel/amd64: i8042: Prevent blinking capslock LED
Holding down the caps-lock key would result in the LED blinking rapidly which is obviously not normal. This commit corrects that behavior. Signed-off-by: Ian Moffett <ian@osmora.org>
-rw-r--r--sys/arch/amd64/isa/i8042.c17
1 files changed, 16 insertions, 1 deletions
diff --git a/sys/arch/amd64/isa/i8042.c b/sys/arch/amd64/isa/i8042.c
index 9b9e254..dd1990f 100644
--- a/sys/arch/amd64/isa/i8042.c
+++ b/sys/arch/amd64/isa/i8042.c
@@ -48,6 +48,7 @@ __KERNEL_META("$Hyra$: i8042.c, Ian Marco Moffett, "
static struct spinlock data_lock;
static bool shift_key = false;
static bool capslock = false;
+static bool capslock_released = true;
static int dev_send(bool aux, uint8_t data);
@@ -96,8 +97,18 @@ scancode_to_chr(uint8_t sc, char *chr)
bool release = __TEST(sc, __BIT(7));
switch (sc) {
- /* Capslock */
+ /* Capslock pressed */
case 0x3A:
+ /*
+ * If we are holding down caps-lock, we do not
+ * want a stream of presses that constantly cause
+ * it to toggle, only toggle if released then pushed
+ * again.
+ */
+ if (!capslock_released)
+ return -EAGAIN;
+
+ capslock_released = false;
capslock = !capslock;
if (!capslock) {
@@ -106,6 +117,10 @@ scancode_to_chr(uint8_t sc, char *chr)
kbd_set_leds(I8042_LED_CAPS);
}
return -EAGAIN;
+ /* Capslock released */
+ case 0xBA:
+ capslock_released = true;
+ return -EAGAIN;
/* Shift */
case 0x36:
case 0xAA: