aboutsummaryrefslogtreecommitdiff
path: root/sys/arch/amd64
diff options
context:
space:
mode:
Diffstat (limited to 'sys/arch/amd64')
-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: