summaryrefslogtreecommitdiff
path: root/Kernel/Devices
diff options
context:
space:
mode:
authorIdan Horowitz <idan.horowitz@gmail.com>2021-05-01 20:10:06 +0300
committerAndreas Kling <kling@serenityos.org>2021-05-01 21:08:23 +0200
commit8293b223614fa23348a7f2c8e8fc695bd6714868 (patch)
treefbf397824c9b270c2db1ced7a9ccb93255acdcce /Kernel/Devices
parent63ff271125fe851dbe44fa578a7bb0028d976bfd (diff)
downloadserenity-8293b223614fa23348a7f2c8e8fc695bd6714868.zip
Kernel: Handle both shift keys being pressed and then released
Our current implementation does not work in the special case in which both shift keys are pressed, and then only one of the keys is released, as this would result in writing lower case letters, instead of the expected upper case letters. This commit fixes that by keeping track of the amount of shift keys that are pressed (instead of if any are at all), and only switching to the unshifted keymap once all of them are released.
Diffstat (limited to 'Kernel/Devices')
-rw-r--r--Kernel/Devices/HID/KeyboardDevice.h1
-rw-r--r--Kernel/Devices/HID/PS2KeyboardDevice.cpp7
2 files changed, 7 insertions, 1 deletions
diff --git a/Kernel/Devices/HID/KeyboardDevice.h b/Kernel/Devices/HID/KeyboardDevice.h
index 96cbf0310d..9d1b9f689d 100644
--- a/Kernel/Devices/HID/KeyboardDevice.h
+++ b/Kernel/Devices/HID/KeyboardDevice.h
@@ -56,6 +56,7 @@ protected:
bool m_caps_lock_on { false };
bool m_num_lock_on { false };
bool m_has_e0_prefix { false };
+ bool m_both_shift_keys_pressed { false };
void key_state_changed(u8 raw, bool pressed);
};
diff --git a/Kernel/Devices/HID/PS2KeyboardDevice.cpp b/Kernel/Devices/HID/PS2KeyboardDevice.cpp
index 9dfe2a772d..8ff6d5b3b0 100644
--- a/Kernel/Devices/HID/PS2KeyboardDevice.cpp
+++ b/Kernel/Devices/HID/PS2KeyboardDevice.cpp
@@ -54,7 +54,12 @@ void PS2KeyboardDevice::irq_handle_byte_read(u8 byte)
break;
case 0x2a:
case 0x36:
- update_modifier(Mod_Shift, pressed);
+ if (m_both_shift_keys_pressed)
+ m_both_shift_keys_pressed = false;
+ else if ((m_modifiers & Mod_Shift) != 0 && pressed)
+ m_both_shift_keys_pressed = true;
+ else
+ update_modifier(Mod_Shift, pressed);
break;
}
switch (ch) {