mirror of
https://github.com/SerenityOS/serenity.git
synced 2025-01-24 02:12:09 -05:00
WindowsServer: Add scancode value to KeyEvent
This commit is contained in:
parent
c6f1962919
commit
9ec6ac31b8
4 changed files with 11 additions and 6 deletions
|
@ -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 {
|
||||
|
|
|
@ -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<KeyEvent>(kernel_event.is_press() ? Event::KeyDown : Event::KeyUp, kernel_event.key, kernel_event.character, kernel_event.modifiers());
|
||||
auto message = make<KeyEvent>(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));
|
||||
}
|
||||
|
||||
|
|
|
@ -304,14 +304,16 @@ void Window::event(Core::Event& event)
|
|||
Messages::WindowClient::KeyDown(m_window_id,
|
||||
(u8) static_cast<const KeyEvent&>(event).character(),
|
||||
(u32) static_cast<const KeyEvent&>(event).key(),
|
||||
static_cast<const KeyEvent&>(event).modifiers()));
|
||||
static_cast<const KeyEvent&>(event).modifiers(),
|
||||
(u32) static_cast<const KeyEvent&>(event).scancode()));
|
||||
break;
|
||||
case Event::KeyUp:
|
||||
m_client->post_message(
|
||||
Messages::WindowClient::KeyUp(m_window_id,
|
||||
(u8) static_cast<const KeyEvent&>(event).character(),
|
||||
(u32) static_cast<const KeyEvent&>(event).key(),
|
||||
static_cast<const KeyEvent&>(event).modifiers()));
|
||||
static_cast<const KeyEvent&>(event).modifiers(),
|
||||
(u32) static_cast<const KeyEvent&>(event).scancode()));
|
||||
break;
|
||||
case Event::WindowActivated:
|
||||
m_client->post_message(Messages::WindowClient::WindowActivated(m_window_id));
|
||||
|
|
|
@ -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) =|
|
||||
|
|
Loading…
Add table
Reference in a new issue