Skip to content

Commit 8a2fbef

Browse files
committed
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.
1 parent 6c2f9bc commit 8a2fbef

File tree

1 file changed

+12
-9
lines changed

1 file changed

+12
-9
lines changed

src/video/wayland/SDL_waylandevents.c

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -53,14 +53,18 @@
5353
#include <libdecor.h>
5454
#endif
5555

56+
// Per the spec, Wayland mouse and stylus buttons are defined as Linux event codes.
5657
#ifdef SDL_INPUT_LINUXEV
5758
#include <linux/input.h>
5859
#else
59-
#define BTN_LEFT (0x110)
60-
#define BTN_RIGHT (0x111)
61-
#define BTN_MIDDLE (0x112)
62-
#define BTN_SIDE (0x113)
63-
#define BTN_EXTRA (0x114)
60+
#define BTN_LEFT (0x110)
61+
#define BTN_RIGHT (0x111)
62+
#define BTN_MIDDLE (0x112)
63+
#define BTN_SIDE (0x113)
64+
#define BTN_EXTRA (0x114)
65+
#define BTN_STYLUS (0x14b)
66+
#define BTN_STYLUS2 (0x14c)
67+
#define BTN_STYLUS3 (0x149)
6468
#endif
6569
#include "../../events/SDL_keysym_to_scancode_c.h"
6670
#include "../../events/imKStoUCS.h"
@@ -3381,14 +3385,13 @@ static void tablet_tool_handle_button(void *data, struct zwp_tablet_tool_v2 *too
33813385
int sdlbutton;
33823386

33833387
switch (button) {
3384-
// see %{_includedir}/linux/input-event-codes.h
3385-
case 0x14b: // BTN_STYLUS
3388+
case BTN_STYLUS:
33863389
sdlbutton = 1;
33873390
break;
3388-
case 0x14c: // BTN_STYLUS2
3391+
case BTN_STYLUS2:
33893392
sdlbutton = 2;
33903393
break;
3391-
case 0x149: // BTN_STYLUS3
3394+
case BTN_STYLUS3:
33923395
sdlbutton = 3;
33933396
break;
33943397
default:

0 commit comments

Comments
 (0)