mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 00:57:45 +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
|
@ -303,7 +303,7 @@ void KeyboardDevice::handle_scan_code_input_event(ScanCodeEvent event)
|
||||||
queued_event.flags = m_modifiers;
|
queued_event.flags = m_modifiers;
|
||||||
queued_event.e0_prefix = event.e0_prefix;
|
queued_event.e0_prefix = event.e0_prefix;
|
||||||
queued_event.caps_lock_on = m_caps_lock_on;
|
queued_event.caps_lock_on = m_caps_lock_on;
|
||||||
queued_event.code_point = HIDManagement::the().get_char_from_character_map(queued_event);
|
queued_event.code_point = HIDManagement::the().get_char_from_character_map(queued_event, m_num_lock_on);
|
||||||
|
|
||||||
// If using a non-QWERTY layout, queued_event.key needs to be updated to be the same as event.code_point
|
// If using a non-QWERTY layout, queued_event.key needs to be updated to be the same as event.code_point
|
||||||
KeyCode mapped_key = code_point_to_key_code(queued_event.code_point);
|
KeyCode mapped_key = code_point_to_key_code(queued_event.code_point);
|
||||||
|
|
|
@ -174,7 +174,7 @@ HIDManagement& HIDManagement::the()
|
||||||
return *s_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 modifiers = event.modifiers();
|
||||||
auto index = event.scancode & 0xFF; // Index is last byte of scan code.
|
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
|
// 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.
|
// `Insert` have the same scancode except for the prefix, but insert should not have a code_point.
|
||||||
code_point = 0;
|
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;
|
return code_point;
|
||||||
|
|
|
@ -46,7 +46,7 @@ public:
|
||||||
|
|
||||||
SpinlockProtected<KeymapData, LockRank::None>& keymap_data() { return m_keymap_data; }
|
SpinlockProtected<KeymapData, LockRank::None>& keymap_data() { return m_keymap_data; }
|
||||||
|
|
||||||
u32 get_char_from_character_map(KeyEvent) const;
|
u32 get_char_from_character_map(KeyEvent, bool) const;
|
||||||
|
|
||||||
void set_client(KeyboardClient* client);
|
void set_client(KeyboardClient* client);
|
||||||
void set_maps(NonnullOwnPtr<KString> character_map_name, Keyboard::CharacterMapData const& character_map);
|
void set_maps(NonnullOwnPtr<KString> character_map_name, Keyboard::CharacterMapData const& character_map);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue