From 9ec6ac31b82f3ecffc994376f073fbd1691cae8a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?H=C3=BCseyin=20ASLIT=C3=9CRK?= Date: Sat, 30 May 2020 15:54:02 +0300 Subject: [PATCH] WindowsServer: Add scancode value to KeyEvent --- Services/WindowServer/Event.h | 5 ++++- Services/WindowServer/Screen.cpp | 2 +- Services/WindowServer/Window.cpp | 6 ++++-- Services/WindowServer/WindowClient.ipc | 4 ++-- 4 files changed, 11 insertions(+), 6 deletions(-) diff --git a/Services/WindowServer/Event.h b/Services/WindowServer/Event.h index 48def26519f..8428769b7db 100644 --- a/Services/WindowServer/Event.h +++ b/Services/WindowServer/Event.h @@ -76,11 +76,12 @@ enum class MouseButton : u8 { class KeyEvent final : public Event { public: - KeyEvent(Type type, int key, char character, u8 modifiers) + KeyEvent(Type type, int key, char character, u8 modifiers, u32 scancode) : Event(type) , m_key(key) , m_character(character) , m_modifiers(modifiers) + , m_scancode(scancode) { } @@ -91,6 +92,7 @@ public: bool logo() const { return m_modifiers & Mod_Logo; } u8 modifiers() const { return m_modifiers; } char character() const { return m_character; } + u32 scancode() const { return m_scancode; } private: friend class EventLoop; @@ -98,6 +100,7 @@ private: int m_key { 0 }; char m_character { 0 }; u8 m_modifiers { 0 }; + u32 m_scancode { 0 }; }; class MouseEvent final : public Event { diff --git a/Services/WindowServer/Screen.cpp b/Services/WindowServer/Screen.cpp index 3f0fbb04fd0..6aa1e05235f 100644 --- a/Services/WindowServer/Screen.cpp +++ b/Services/WindowServer/Screen.cpp @@ -164,7 +164,7 @@ void Screen::on_receive_mouse_data(const MousePacket& packet) void Screen::on_receive_keyboard_data(::KeyEvent kernel_event) { m_modifiers = kernel_event.modifiers(); - auto message = make(kernel_event.is_press() ? Event::KeyDown : Event::KeyUp, kernel_event.key, kernel_event.character, kernel_event.modifiers()); + auto message = make(kernel_event.is_press() ? Event::KeyDown : Event::KeyUp, kernel_event.key, kernel_event.character, kernel_event.modifiers(), kernel_event.scancode); Core::EventLoop::current().post_event(WindowManager::the(), move(message)); } diff --git a/Services/WindowServer/Window.cpp b/Services/WindowServer/Window.cpp index e816935da80..b6f3f9fb5cc 100644 --- a/Services/WindowServer/Window.cpp +++ b/Services/WindowServer/Window.cpp @@ -304,14 +304,16 @@ void Window::event(Core::Event& event) Messages::WindowClient::KeyDown(m_window_id, (u8) static_cast(event).character(), (u32) static_cast(event).key(), - static_cast(event).modifiers())); + static_cast(event).modifiers(), + (u32) static_cast(event).scancode())); break; case Event::KeyUp: m_client->post_message( Messages::WindowClient::KeyUp(m_window_id, (u8) static_cast(event).character(), (u32) static_cast(event).key(), - static_cast(event).modifiers())); + static_cast(event).modifiers(), + (u32) static_cast(event).scancode())); break; case Event::WindowActivated: m_client->post_message(Messages::WindowClient::WindowActivated(m_window_id)); diff --git a/Services/WindowServer/WindowClient.ipc b/Services/WindowServer/WindowClient.ipc index ddcdcb6cf75..051b057a9d5 100644 --- a/Services/WindowServer/WindowClient.ipc +++ b/Services/WindowServer/WindowClient.ipc @@ -8,8 +8,8 @@ endpoint WindowClient = 4 MouseWheel(i32 window_id, Gfx::Point mouse_position, u32 button, u32 buttons, u32 modifiers, i32 wheel_delta) =| WindowEntered(i32 window_id) =| WindowLeft(i32 window_id) =| - KeyDown(i32 window_id, u8 character, u32 key, u32 modifiers) =| - KeyUp(i32 window_id, u8 character, u32 key, u32 modifiers) =| + KeyDown(i32 window_id, u8 character, u32 key, u32 modifiers, u32 scancode) =| + KeyUp(i32 window_id, u8 character, u32 key, u32 modifiers, u32 scancode) =| WindowActivated(i32 window_id) =| WindowDeactivated(i32 window_id) =| WindowStateChanged(i32 window_id, bool minimized, bool occluded) =|