mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 18:17:44 +00:00
LibGUI: Add scancode value to KeyEvent
This commit is contained in:
parent
46b92fa173
commit
c6f1962919
2 changed files with 6 additions and 3 deletions
|
@ -267,10 +267,11 @@ enum MouseButton : u8 {
|
||||||
|
|
||||||
class KeyEvent final : public Event {
|
class KeyEvent final : public Event {
|
||||||
public:
|
public:
|
||||||
KeyEvent(Type type, KeyCode key, u8 modifiers)
|
KeyEvent(Type type, KeyCode key, u8 modifiers, u32 scancode)
|
||||||
: Event(type)
|
: Event(type)
|
||||||
, m_key(key)
|
, m_key(key)
|
||||||
, m_modifiers(modifiers)
|
, m_modifiers(modifiers)
|
||||||
|
, m_scancode(scancode)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -281,6 +282,7 @@ public:
|
||||||
bool logo() const { return m_modifiers & Mod_Logo; }
|
bool logo() const { return m_modifiers & Mod_Logo; }
|
||||||
u8 modifiers() const { return m_modifiers; }
|
u8 modifiers() const { return m_modifiers; }
|
||||||
String text() const { return m_text; }
|
String text() const { return m_text; }
|
||||||
|
u32 scancode() const { return m_scancode; }
|
||||||
|
|
||||||
String to_string() const;
|
String to_string() const;
|
||||||
|
|
||||||
|
@ -288,6 +290,7 @@ private:
|
||||||
friend class WindowServerConnection;
|
friend class WindowServerConnection;
|
||||||
KeyCode m_key { 0 };
|
KeyCode m_key { 0 };
|
||||||
u8 m_modifiers { 0 };
|
u8 m_modifiers { 0 };
|
||||||
|
u32 m_scancode { 0 };
|
||||||
String m_text;
|
String m_text;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -129,7 +129,7 @@ void WindowServerConnection::handle(const Messages::WindowClient::KeyDown& messa
|
||||||
if (!window)
|
if (!window)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
auto key_event = make<KeyEvent>(Event::KeyDown, (KeyCode) message.key(), message.modifiers());
|
auto key_event = make<KeyEvent>(Event::KeyDown, (KeyCode) message.key(), message.modifiers(), message.scancode());
|
||||||
if (message.character() != '\0') {
|
if (message.character() != '\0') {
|
||||||
char ch = message.character();
|
char ch = message.character();
|
||||||
key_event->m_text = String(&ch, 1);
|
key_event->m_text = String(&ch, 1);
|
||||||
|
@ -188,7 +188,7 @@ void WindowServerConnection::handle(const Messages::WindowClient::KeyUp& message
|
||||||
if (!window)
|
if (!window)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
auto key_event = make<KeyEvent>(Event::KeyUp, (KeyCode) message.key(), message.modifiers());
|
auto key_event = make<KeyEvent>(Event::KeyUp, (KeyCode) message.key(), message.modifiers(), message.scancode());
|
||||||
if (message.character() != '\0') {
|
if (message.character() != '\0') {
|
||||||
char ch = message.character();
|
char ch = message.character();
|
||||||
key_event->m_text = String(&ch, 1);
|
key_event->m_text = String(&ch, 1);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue