From ca9e1f6391e9f944b524529d6d4eeec13be75c26 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Tue, 28 Jun 2022 14:43:37 +1000 Subject: [PATCH] Cleanup: replace magic number with define for scan-code/key-code offset --- intern/ghost/intern/GHOST_SystemWayland.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/intern/ghost/intern/GHOST_SystemWayland.cpp b/intern/ghost/intern/GHOST_SystemWayland.cpp index 2ee9420dbf7..96340fc9090 100644 --- a/intern/ghost/intern/GHOST_SystemWayland.cpp +++ b/intern/ghost/intern/GHOST_SystemWayland.cpp @@ -107,6 +107,12 @@ static bool use_gnome_confine_hack = false; /** \name Private Types & Defines * \{ */ +/** + * From XKB internals, use for converting a scan-code from WAYLAND to a #xkb_keycode_t. + * Ideally this wouldn't need a local define. + */ +#define EVDEV_OFFSET 8 + struct buffer_t { void *data = nullptr; size_t size = 0; @@ -1939,7 +1945,7 @@ static void keyboard_handle_key(void *data, const uint32_t state) { input_t *input = static_cast(data); - const xkb_keycode_t key_code = key + 8; + const xkb_keycode_t key_code = key + EVDEV_OFFSET; const xkb_keysym_t sym = xkb_state_key_get_one_sym_without_modifiers( input->xkb_state_empty, input->xkb_state_empty_with_numlock, key_code);