summaryrefslogtreecommitdiffstats
path: root/video/out
diff options
context:
space:
mode:
authorRyan Hendrickson <ryan.hendrickson@alum.mit.edu>2022-01-27 18:21:27 -0500
committerDudemanguy <random342@airmail.cc>2022-01-28 00:14:56 +0000
commit9098ae5a16d558a50345ecb8f74dcf8d79dd1d77 (patch)
tree73d9ae1d494e3d18e8b91d4d2e56fd1391a3a569 /video/out
parent073fbd98eeec86e62b8fada4fe9d42444981edfa (diff)
downloadmpv-9098ae5a16d558a50345ecb8f74dcf8d79dd1d77.tar.bz2
mpv-9098ae5a16d558a50345ecb8f74dcf8d79dd1d77.tar.xz
wayland: support extra mouse buttons
Mouse button event codes above `BTN_EXTRA` (the ones currently defined in `input-event-codes.h` are `BTN_FORWARD`, `BTN_BACK`, and `BTN_TASK`) are mapped to `MP_MBTN9` and up. (Reminder that due to historical reasons, the names `BTN_FORWARD` and `BTN_BACK` are completely misleading; the real forward and back buttons are `BTN_SIDE` and `BTN_EXTRA` and are already mapped correctly by mpv.) This functionality is analogous to what the X11 backend supports in `video/out/x11_common.c` and what the Cocoa backend supports in `video/out/cocoa/events_view.m`.
Diffstat (limited to 'video/out')
-rw-r--r--video/out/wayland_common.c40
1 files changed, 22 insertions, 18 deletions
diff --git a/video/out/wayland_common.c b/video/out/wayland_common.c
index 1f176aaad3..c2591426b6 100644
--- a/video/out/wayland_common.c
+++ b/video/out/wayland_common.c
@@ -205,25 +205,29 @@ static void pointer_handle_button(void *data, struct wl_pointer *wl_pointer,
state = state == WL_POINTER_BUTTON_STATE_PRESSED ? MP_KEY_STATE_DOWN
: MP_KEY_STATE_UP;
- switch (button) {
- case BTN_LEFT:
- button = MP_MBTN_LEFT;
- break;
- case BTN_MIDDLE:
- button = MP_MBTN_MID;
- break;
- case BTN_RIGHT:
- button = MP_MBTN_RIGHT;
- break;
- case BTN_SIDE:
- button = MP_MBTN_BACK;
- break;
- case BTN_EXTRA:
- button = MP_MBTN_FORWARD;
- break;
- default:
+ if (button >= BTN_MOUSE && button < BTN_JOYSTICK) {
+ switch (button) {
+ case BTN_LEFT:
+ button = MP_MBTN_LEFT;
+ break;
+ case BTN_MIDDLE:
+ button = MP_MBTN_MID;
+ break;
+ case BTN_RIGHT:
+ button = MP_MBTN_RIGHT;
+ break;
+ case BTN_SIDE:
+ button = MP_MBTN_BACK;
+ break;
+ case BTN_EXTRA:
+ button = MP_MBTN_FORWARD;
+ break;
+ default:
+ button += MP_MBTN9 - BTN_FORWARD;
+ break;
+ }
+ } else {
button = 0;
- break;
}
if (wl->keyboard)