mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 02:27:43 +00:00
Kernel: Change the code point of numpad keys to 0, when Num Lock is off
Previously we would set the KeyCode correctly to the appropriate extended keys values, like Home and End, but keep the code point of the original keys, like 1, 2, 3, etc. Because of this, the keys would just print the original keys, instead of behaving like the extended ones.
This commit is contained in:
parent
c261e5e39b
commit
719ab586c4
3 changed files with 7 additions and 3 deletions
|
@ -174,7 +174,7 @@ HIDManagement& HIDManagement::the()
|
|||
return *s_the;
|
||||
}
|
||||
|
||||
u32 HIDManagement::get_char_from_character_map(KeyEvent event) const
|
||||
u32 HIDManagement::get_char_from_character_map(KeyEvent event, bool num_lock_on) const
|
||||
{
|
||||
auto modifiers = event.modifiers();
|
||||
auto index = event.scancode & 0xFF; // Index is last byte of scan code.
|
||||
|
@ -208,6 +208,10 @@ u32 HIDManagement::get_char_from_character_map(KeyEvent event) const
|
|||
// Except for `keypad-/` and 'keypad-return', all e0 scan codes are not actually characters. i.e., `keypad-0` and
|
||||
// `Insert` have the same scancode except for the prefix, but insert should not have a code_point.
|
||||
code_point = 0;
|
||||
} else if (!num_lock_on && !event.e0_prefix && event.scancode >= 0x47 && event.scancode <= 0x53 && event.key != Key_Minus && event.key != Key_Plus) {
|
||||
// When Num Lock is off, some numpad keys have the same function as some of the extended keys like Home, End, PgDown, arrows etc.
|
||||
// These keys should have the code_point set to 0.
|
||||
code_point = 0;
|
||||
}
|
||||
|
||||
return code_point;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue