Skip to content

Commit

Permalink
Kernel: Handle both shift keys being pressed and then released
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
IdanHo authored and awesomekling committed May 1, 2021
1 parent 63ff271 commit 8293b22
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
1 change: 1 addition & 0 deletions Kernel/Devices/HID/KeyboardDevice.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ class KeyboardDevice : public HIDDevice {
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);
};
Expand Down
7 changes: 6 additions & 1 deletion Kernel/Devices/HID/PS2KeyboardDevice.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit 8293b22

Please sign in to comment.