Skip to content

Commit e3df61b

Browse files
committed
Fixed right mouse button emulation when using a pen
Pen button 1 is typically used as right click. Pen button 2 (Wacom eraser) doesn't have a specific mapping, but we'll use middle click for now.
1 parent 106ccc7 commit e3df61b

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

src/events/SDL_pen.c

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -568,7 +568,16 @@ void SDL_SendPenButton(Uint64 timestamp, SDL_PenID instance_id, SDL_Window *wind
568568
if (window && (!pen_touching || (pen_touching == instance_id))) {
569569
SDL_Mouse *mouse = SDL_GetMouse();
570570
if (mouse && mouse->pen_mouse_events) {
571-
SDL_SendMouseButton(timestamp, window, SDL_PEN_MOUSEID, button + 1, down);
571+
static const Uint8 mouse_buttons[] = {
572+
SDL_BUTTON_LEFT,
573+
SDL_BUTTON_RIGHT,
574+
SDL_BUTTON_MIDDLE,
575+
SDL_BUTTON_X1,
576+
SDL_BUTTON_X2
577+
};
578+
if (button < SDL_arraysize(mouse_buttons)) {
579+
SDL_SendMouseButton(timestamp, window, SDL_PEN_MOUSEID, mouse_buttons[button], down);
580+
}
572581
}
573582
}
574583
}

0 commit comments

Comments
 (0)