1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 04:37:34 +00:00

Userland: Actually use the correct character map index from KeyEvent

Instead of using a scan code, which for scan code set 2 will not
represent the expected character mapping index, we could just use
another variable in the KeyEvent structure that correctly points to the
character index.

This change is mostly relevant to the KeyboardMapper application, and
also to the WindowServer code, as both handle KeyEvents and need to
use the character mapping index in various situations.
This commit is contained in:
Liav A 2023-04-14 18:57:41 +03:00 committed by Andrew Kaster
parent b89cc81674
commit 60a96b3786
9 changed files with 41 additions and 32 deletions

View file

@ -60,8 +60,9 @@ enum MouseButton : u8 {
class KeyEvent final : public Event {
public:
KeyEvent(Type type, int key, u32 code_point, u8 modifiers, u32 scancode)
KeyEvent(Type type, int key, u8 map_entry_index, u32 code_point, u8 modifiers, u32 scancode)
: Event(type)
, m_map_entry_index(map_entry_index)
, m_key(key)
, m_code_point(code_point)
, m_modifiers(modifiers)
@ -77,10 +78,12 @@ public:
u8 modifiers() const { return m_modifiers; }
u32 code_point() const { return m_code_point; }
u32 scancode() const { return m_scancode; }
u8 map_entry_index() const { return m_map_entry_index; }
private:
friend class EventLoop;
friend class Screen;
u8 m_map_entry_index { 0 };
int m_key { 0 };
u32 m_code_point { 0 };
u8 m_modifiers { 0 };