From 8a2fbef5b29aec9b799fe91e8ce2dd10cf6a7262 Mon Sep 17 00:00:00 2001 From: Frank Praznik Date: Mon, 5 Jan 2026 11:57:00 -0500 Subject: [PATCH] wayland: Define the magic values for stylus buttons Use the Linux defines if available, and if not, define the buttons with the rest of the values, as is done for mouse buttons. --- src/video/wayland/SDL_waylandevents.c | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/src/video/wayland/SDL_waylandevents.c b/src/video/wayland/SDL_waylandevents.c index 5a9bef048f..8422edee42 100644 --- a/src/video/wayland/SDL_waylandevents.c +++ b/src/video/wayland/SDL_waylandevents.c @@ -53,14 +53,18 @@ #include #endif +// Per the spec, Wayland mouse and stylus buttons are defined as Linux event codes. #ifdef SDL_INPUT_LINUXEV #include #else -#define BTN_LEFT (0x110) -#define BTN_RIGHT (0x111) -#define BTN_MIDDLE (0x112) -#define BTN_SIDE (0x113) -#define BTN_EXTRA (0x114) +#define BTN_LEFT (0x110) +#define BTN_RIGHT (0x111) +#define BTN_MIDDLE (0x112) +#define BTN_SIDE (0x113) +#define BTN_EXTRA (0x114) +#define BTN_STYLUS (0x14b) +#define BTN_STYLUS2 (0x14c) +#define BTN_STYLUS3 (0x149) #endif #include "../../events/SDL_keysym_to_scancode_c.h" #include "../../events/imKStoUCS.h" @@ -3381,14 +3385,13 @@ static void tablet_tool_handle_button(void *data, struct zwp_tablet_tool_v2 *too int sdlbutton; switch (button) { - // see %{_includedir}/linux/input-event-codes.h - case 0x14b: // BTN_STYLUS + case BTN_STYLUS: sdlbutton = 1; break; - case 0x14c: // BTN_STYLUS2 + case BTN_STYLUS2: sdlbutton = 2; break; - case 0x149: // BTN_STYLUS3 + case BTN_STYLUS3: sdlbutton = 3; break; default: