Skip to content

Commit

Permalink
[Wayland] Support for mouse buttons 4&5 and horizontal wheel
Browse files Browse the repository at this point in the history
  • Loading branch information
zoltanvb committed Jun 19, 2024
1 parent e3bb6b7 commit f49bbbd
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 2 deletions.
14 changes: 14 additions & 0 deletions input/common/wayland_common.c
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,8 @@ static void wl_pointer_handle_leave(void *data,
wl->input.mouse.left = false;
wl->input.mouse.right = false;
wl->input.mouse.middle = false;
wl->input.mouse.side = false;
wl->input.mouse.extra = false;

if (wl->input.mouse.surface == surface)
wl->input.mouse.surface = NULL;
Expand Down Expand Up @@ -270,6 +272,12 @@ static void wl_pointer_handle_button(void *data,
case BTN_MIDDLE:
wl->input.mouse.middle = true;
break;
case BTN_SIDE:
wl->input.mouse.side = true;
break;
case BTN_EXTRA:
wl->input.mouse.extra = true;
break;
}
}
else
Expand All @@ -285,6 +293,12 @@ static void wl_pointer_handle_button(void *data,
case BTN_MIDDLE:
wl->input.mouse.middle = false;
break;
case BTN_SIDE:
wl->input.mouse.side = false;
break;
case BTN_EXTRA:
wl->input.mouse.extra = false;
break;
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion input/common/wayland_common.h
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ typedef struct input_ctx_wayland_data
int delta_x, delta_y;
bool last_valid;
bool focus;
bool left, right, middle;
bool left, right, middle, side, extra;
bool wu, wd, wl, wr;
} mouse;

Expand Down
13 changes: 12 additions & 1 deletion input/drivers/wayland_input.c
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,18 @@ static int16_t input_wl_state(
return wl->mouse.right;
case RETRO_DEVICE_ID_MOUSE_MIDDLE:
return wl->mouse.middle;
/* TODO/FIXME: Rest of the mouse inputs. */
case RETRO_DEVICE_ID_MOUSE_BUTTON_4:
return wl->mouse.side;
case RETRO_DEVICE_ID_MOUSE_BUTTON_5:
return wl->mouse.extra;
case RETRO_DEVICE_ID_MOUSE_HORIZ_WHEELDOWN:
state = wl->mouse.wl;
wl->mouse.wl = false;
return state;
case RETRO_DEVICE_ID_MOUSE_HORIZ_WHEELUP:
state = wl->mouse.wr;
wl->mouse.wr = false;
return state;
}
}
break;
Expand Down

0 comments on commit f49bbbd

Please sign in to comment.