summaryrefslogtreecommitdiff
path: root/Libraries
diff options
context:
space:
mode:
authorHüseyin ASLITÜRK <asliturk@hotmail.com>2020-05-30 15:53:06 +0300
committerAndreas Kling <kling@serenityos.org>2020-06-03 21:52:40 +0200
commitc6f1962919506019c4c586a4ee94d50fc4e979b6 (patch)
treef0e2be02bec8d9839c29c87c8e1b19f98e18b354 /Libraries
parent46b92fa173f92400e5fbe51ae8b6e860807f4420 (diff)
downloadserenity-c6f1962919506019c4c586a4ee94d50fc4e979b6.zip
LibGUI: Add scancode value to KeyEvent
Diffstat (limited to 'Libraries')
-rw-r--r--Libraries/LibGUI/Event.h5
-rw-r--r--Libraries/LibGUI/WindowServerConnection.cpp4
2 files changed, 6 insertions, 3 deletions
diff --git a/Libraries/LibGUI/Event.h b/Libraries/LibGUI/Event.h
index b8dbe6d73e..93eef75d5b 100644
--- a/Libraries/LibGUI/Event.h
+++ b/Libraries/LibGUI/Event.h
@@ -267,10 +267,11 @@ enum MouseButton : u8 {
class KeyEvent final : public Event {
public:
- KeyEvent(Type type, KeyCode key, u8 modifiers)
+ KeyEvent(Type type, KeyCode key, u8 modifiers, u32 scancode)
: Event(type)
, m_key(key)
, m_modifiers(modifiers)
+ , m_scancode(scancode)
{
}
@@ -281,6 +282,7 @@ public:
bool logo() const { return m_modifiers & Mod_Logo; }
u8 modifiers() const { return m_modifiers; }
String text() const { return m_text; }
+ u32 scancode() const { return m_scancode; }
String to_string() const;
@@ -288,6 +290,7 @@ private:
friend class WindowServerConnection;
KeyCode m_key { 0 };
u8 m_modifiers { 0 };
+ u32 m_scancode { 0 };
String m_text;
};
diff --git a/Libraries/LibGUI/WindowServerConnection.cpp b/Libraries/LibGUI/WindowServerConnection.cpp
index afa94e5768..ed8c584dbc 100644
--- a/Libraries/LibGUI/WindowServerConnection.cpp
+++ b/Libraries/LibGUI/WindowServerConnection.cpp
@@ -129,7 +129,7 @@ void WindowServerConnection::handle(const Messages::WindowClient::KeyDown& messa
if (!window)
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') {
char ch = message.character();
key_event->m_text = String(&ch, 1);
@@ -188,7 +188,7 @@ void WindowServerConnection::handle(const Messages::WindowClient::KeyUp& message
if (!window)
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') {
char ch = message.character();
key_event->m_text = String(&ch, 1);