mirror of
https://github.com/mpv-player/mpv
synced 2025-02-16 12:17:12 +00:00
input: add a define for the number of mouse buttons and use it
(Why the fuck are there up to 20 mouse buttons?)
This commit is contained in:
parent
25525cee62
commit
eb08cd75c1
@ -135,6 +135,8 @@
|
||||
#define MP_KEY_IS_MOUSE_BTN_DBL(code) \
|
||||
((code) >= MP_MBTN_DBL_BASE && (code) < MP_MBTN_DBL_END)
|
||||
|
||||
#define MP_KEY_MOUSE_BTN_COUNT (MP_MBTN_END - MP_MBTN_BASE)
|
||||
|
||||
// Apple Remote input module
|
||||
#define MP_AR_BASE (MP_KEY_BASE+0xE0)
|
||||
#define MP_AR_PLAY (MP_AR_BASE + 0)
|
||||
|
@ -5757,7 +5757,7 @@ static void cmd_mouse(void *p)
|
||||
mp_input_set_mouse_pos_artificial(mpctx->input, x, y);
|
||||
return;
|
||||
}
|
||||
if (button < 0 || button >= 20) {// invalid button
|
||||
if (button < 0 || button >= MP_KEY_MOUSE_BTN_COUNT) {// invalid button
|
||||
MP_ERR(mpctx, "%d is not a valid mouse button number.\n", button);
|
||||
cmd->success = false;
|
||||
return;
|
||||
|
@ -1133,6 +1133,8 @@ void vo_x11_check_events(struct vo *vo)
|
||||
mp_input_put_key(x11->input_ctx, MP_KEY_MOUSE_ENTER);
|
||||
break;
|
||||
case ButtonPress:
|
||||
if (Event.xbutton.button - 1 >= MP_KEY_MOUSE_BTN_COUNT)
|
||||
break;
|
||||
if (Event.xbutton.button == 1)
|
||||
x11->win_drag_button1_down = true;
|
||||
mp_input_put_key(x11->input_ctx,
|
||||
@ -1142,6 +1144,8 @@ void vo_x11_check_events(struct vo *vo)
|
||||
vo_x11_xembed_send_message(x11, msg);
|
||||
break;
|
||||
case ButtonRelease:
|
||||
if (Event.xbutton.button - 1 >= MP_KEY_MOUSE_BTN_COUNT)
|
||||
break;
|
||||
if (Event.xbutton.button == 1)
|
||||
x11->win_drag_button1_down = false;
|
||||
mp_input_put_key(x11->input_ctx,
|
||||
|
Loading…
Reference in New Issue
Block a user