aboutsummaryrefslogtreecommitdiffstats
path: root/src/window.cpp
diff options
context:
space:
mode:
authorladevieq <ladevie.quentin@gmail.com>2021-01-26 22:27:44 +0100
committerladevieq <ladevie.quentin@gmail.com>2021-01-26 22:27:44 +0100
commitd3b08c7e8bf808281e32fdef5e5222fb6633a5d0 (patch)
treed25b4f72694e9624ba30e112aef7849d03512c75 /src/window.cpp
parentfbe4f159bc4d9f801128fbb487e9e86d3786062c (diff)
Improve XCB keyboard inputs handling
Diffstat (limited to 'src/window.cpp')
-rw-r--r--src/window.cpp14
1 files changed, 9 insertions, 5 deletions
diff --git a/src/window.cpp b/src/window.cpp
index 840d570..a353809 100644
--- a/src/window.cpp
+++ b/src/window.cpp
@@ -119,12 +119,16 @@ void window::poll_events() {
}
case XCB_KEY_RELEASE:
case XCB_KEY_PRESS: {
- auto key_press_event = (xcb_key_press_event_t*)event;
- auto keysym = xkb_state_key_get_one_sym(keyboard_state, key_press_event->detail);
+ auto key_press_event = (xcb_key_press_event_t*)event;
+ auto keysym = xkb_state_key_get_one_sym(keyboard_state, key_press_event->detail);
+ auto isKeyPress = event->response_type == XCB_KEY_PRESS;
+ auto key = (KEYS)keysym;
+
+ keyboard[key] = isKeyPress;
+
struct event new_event = {
- .type = event->response_type == XCB_KEY_PRESS ? EVENT_TYPES::KEY_PRESS :EVENT_TYPES::KEY_RELEASE
- .modifiers = key_press_event->state;
- .keycode = keysym;
+ .key = key,
+ .type = isKeyPress ? EVENT_TYPES::KEY_PRESS :EVENT_TYPES::KEY_RELEASE
};
events.push_back(new_event);