input: use mnemonic names for mouse buttons

mpv's mouse button numbering is based on X11 button numbering, which
allows for an arbitrary number of buttons and includes mouse wheel input
as buttons 3-6. This button numbering was used throughout the codebase
and exposed in input.conf, and it was difficult to remember which
physical button each number actually referred to and which referred to
the scroll wheel.

In practice, PC mice only have between two and five buttons and one or
two scroll wheel axes, which are more or less in the same location and
have more or less the same function. This allows us to use names to
refer to the buttons instead of numbers, which makes input.conf syntax a
lot easier to remember. It also makes the syntax robust to changes in
mpv's underlying numbering. The old MOUSE_BTNx names are still
understood as deprecated aliases of the named buttons.

This changes both the input.conf syntax and the MP_MOUSE_BTNx symbols in
the codebase, since I think both would benefit from using names over
numbers, especially since some platforms don't use X11 button numbering
and handle different mouse buttons in different windowing system events.

This also makes the names shorter, since otherwise they would be pretty
long, and it removes the high-numbered MOUSE_BTNx_DBL names, since they
weren't used.

Names are the same as used in Qt:
https://doc.qt.io/qt-5/qt.html#MouseButton-enum
This commit is contained in:
James Ross-Gowan 2017-08-08 21:34:38 +10:00
parent 449d9725c9
commit 957e9a37db
13 changed files with 171 additions and 170 deletions

View File

@ -59,6 +59,10 @@ Interface changes
obscure use that stopped working with the change above. It was also
prone to be confused with a feature not implemented by it: auto did _not_
mean that deinterlacing was enabled on demand.)
- add shortened mnemonic names for mouse button bindings, eg. mbtn_left
the old numeric names (mouse_btn0) are deprecated
- remove mouse_btn3_dbl and up, since they are only generated for buttons
0-2 (these now print an error when sent from the 'mouse' command)
--- mpv 0.26.0 ---
- remove remaining deprecated audio device options, like --alsa-device
Some of them were removed in earlier releases.

View File

@ -28,13 +28,13 @@
# If this is enabled, treat all the following bindings as default.
#default-bindings start
#MOUSE_BTN0 ignore # don't do anything
#MOUSE_BTN0_DBL cycle fullscreen # toggle fullscreen on/off
#MOUSE_BTN2 cycle pause # toggle pause on/off
#MOUSE_BTN3 seek 10
#MOUSE_BTN4 seek -10
#MOUSE_BTN5 add volume -2
#MOUSE_BTN6 add volume 2
#MBTN_LEFT ignore # don't do anything
#MBTN_LEFT_DBL cycle fullscreen # toggle fullscreen on/off
#MBTN_RIGHT cycle pause # toggle pause on/off
#WHEEL_UP seek 10
#WHEEL_DOWN seek -10
#WHEEL_LEFT add volume -2
#WHEEL_RIGHT add volume 2
# Mouse wheels, touchpad or other input devices that have axes
# if the input devices supports precise scrolling it will also scale the

View File

@ -732,8 +732,8 @@ static void mp_input_feed_key(struct input_ctx *ictx, int code, double scale,
if (ictx->last_doubleclick_key_down == code &&
now - ictx->last_doubleclick_time < opts->doubleclick_time / 1000.0)
{
if (code >= MP_MOUSE_BTN0 && code <= MP_MOUSE_BTN2) {
interpret_key(ictx, code - MP_MOUSE_BTN0 + MP_MOUSE_BTN0_DBL,
if (code >= MP_MBTN_LEFT && code <= MP_MBTN_RIGHT) {
interpret_key(ictx, code - MP_MOUSE_BASE + MP_MOUSE_DBL_BASE,
1, 1);
}
}

View File

@ -78,46 +78,29 @@ static const struct key_name key_names[] = {
{ MP_KEY_KPDEC, "KP_DEC" },
{ MP_KEY_KPINS, "KP_INS" },
{ MP_KEY_KPENTER, "KP_ENTER" },
{ MP_MOUSE_BTN0, "MOUSE_BTN0" },
{ MP_MOUSE_BTN1, "MOUSE_BTN1" },
{ MP_MOUSE_BTN2, "MOUSE_BTN2" },
{ MP_MOUSE_BTN3, "MOUSE_BTN3" },
{ MP_MOUSE_BTN4, "MOUSE_BTN4" },
{ MP_MOUSE_BTN5, "MOUSE_BTN5" },
{ MP_MOUSE_BTN6, "MOUSE_BTN6" },
{ MP_MOUSE_BTN7, "MOUSE_BTN7" },
{ MP_MOUSE_BTN8, "MOUSE_BTN8" },
{ MP_MOUSE_BTN9, "MOUSE_BTN9" },
{ MP_MOUSE_BTN10, "MOUSE_BTN10" },
{ MP_MOUSE_BTN11, "MOUSE_BTN11" },
{ MP_MOUSE_BTN12, "MOUSE_BTN12" },
{ MP_MOUSE_BTN13, "MOUSE_BTN13" },
{ MP_MOUSE_BTN14, "MOUSE_BTN14" },
{ MP_MOUSE_BTN15, "MOUSE_BTN15" },
{ MP_MOUSE_BTN16, "MOUSE_BTN16" },
{ MP_MOUSE_BTN17, "MOUSE_BTN17" },
{ MP_MOUSE_BTN18, "MOUSE_BTN18" },
{ MP_MOUSE_BTN19, "MOUSE_BTN19" },
{ MP_MOUSE_BTN0_DBL, "MOUSE_BTN0_DBL" },
{ MP_MOUSE_BTN1_DBL, "MOUSE_BTN1_DBL" },
{ MP_MOUSE_BTN2_DBL, "MOUSE_BTN2_DBL" },
{ MP_MOUSE_BTN3_DBL, "MOUSE_BTN3_DBL" },
{ MP_MOUSE_BTN4_DBL, "MOUSE_BTN4_DBL" },
{ MP_MOUSE_BTN5_DBL, "MOUSE_BTN5_DBL" },
{ MP_MOUSE_BTN6_DBL, "MOUSE_BTN6_DBL" },
{ MP_MOUSE_BTN7_DBL, "MOUSE_BTN7_DBL" },
{ MP_MOUSE_BTN8_DBL, "MOUSE_BTN8_DBL" },
{ MP_MOUSE_BTN9_DBL, "MOUSE_BTN9_DBL" },
{ MP_MOUSE_BTN10_DBL, "MOUSE_BTN10_DBL" },
{ MP_MOUSE_BTN11_DBL, "MOUSE_BTN11_DBL" },
{ MP_MOUSE_BTN12_DBL, "MOUSE_BTN12_DBL" },
{ MP_MOUSE_BTN13_DBL, "MOUSE_BTN13_DBL" },
{ MP_MOUSE_BTN14_DBL, "MOUSE_BTN14_DBL" },
{ MP_MOUSE_BTN15_DBL, "MOUSE_BTN15_DBL" },
{ MP_MOUSE_BTN16_DBL, "MOUSE_BTN16_DBL" },
{ MP_MOUSE_BTN17_DBL, "MOUSE_BTN17_DBL" },
{ MP_MOUSE_BTN18_DBL, "MOUSE_BTN18_DBL" },
{ MP_MOUSE_BTN19_DBL, "MOUSE_BTN19_DBL" },
{ MP_MBTN_LEFT, "MBTN_LEFT" },
{ MP_MBTN_MID, "MBTN_MID" },
{ MP_MBTN_RIGHT, "MBTN_RIGHT" },
{ MP_WHEEL_UP, "WHEEL_UP" },
{ MP_WHEEL_DOWN, "WHEEL_DOWN" },
{ MP_WHEEL_LEFT, "WHEEL_LEFT" },
{ MP_WHEEL_RIGHT, "WHEEL_RIGHT" },
{ MP_MBTN_BACK, "MBTN_BACK" },
{ MP_MBTN_FORWARD, "MBTN_FORWARD" },
{ MP_MBTN9, "MBTN9" },
{ MP_MBTN10, "MBTN10" },
{ MP_MBTN11, "MBTN11" },
{ MP_MBTN12, "MBTN12" },
{ MP_MBTN13, "MBTN13" },
{ MP_MBTN14, "MBTN14" },
{ MP_MBTN15, "MBTN15" },
{ MP_MBTN16, "MBTN16" },
{ MP_MBTN17, "MBTN17" },
{ MP_MBTN18, "MBTN18" },
{ MP_MBTN19, "MBTN19" },
{ MP_MBTN_LEFT_DBL, "MBTN_LEFT_DBL" },
{ MP_MBTN_MID_DBL, "MBTN_MID_DBL" },
{ MP_MBTN_RIGHT_DBL, "MBTN_RIGHT_DBL" },
{ MP_AR_PLAY, "AR_PLAY" },
{ MP_AR_PLAY_HOLD, "AR_PLAY_HOLD" },
@ -169,6 +152,31 @@ static const struct key_name key_names[] = {
{ MP_KEY_PREV, "XF86_PREV" },
{ MP_KEY_NEXT, "XF86_NEXT" },
// Deprecated numeric aliases for the mouse buttons
{ MP_MBTN_LEFT, "MOUSE_BTN0" },
{ MP_MBTN_MID, "MOUSE_BTN1" },
{ MP_MBTN_RIGHT, "MOUSE_BTN2" },
{ MP_WHEEL_UP, "MOUSE_BTN3" },
{ MP_WHEEL_DOWN, "MOUSE_BTN4" },
{ MP_WHEEL_LEFT, "MOUSE_BTN5" },
{ MP_WHEEL_RIGHT, "MOUSE_BTN6" },
{ MP_MBTN_BACK, "MOUSE_BTN7" },
{ MP_MBTN_FORWARD, "MOUSE_BTN8" },
{ MP_MBTN9, "MOUSE_BTN9" },
{ MP_MBTN10, "MOUSE_BTN10" },
{ MP_MBTN11, "MOUSE_BTN11" },
{ MP_MBTN12, "MOUSE_BTN12" },
{ MP_MBTN13, "MOUSE_BTN13" },
{ MP_MBTN14, "MOUSE_BTN14" },
{ MP_MBTN15, "MOUSE_BTN15" },
{ MP_MBTN16, "MOUSE_BTN16" },
{ MP_MBTN17, "MOUSE_BTN17" },
{ MP_MBTN18, "MOUSE_BTN18" },
{ MP_MBTN19, "MOUSE_BTN19" },
{ MP_MBTN_LEFT_DBL, "MOUSE_BTN0_DBL" },
{ MP_MBTN_MID_DBL, "MOUSE_BTN1_DBL" },
{ MP_MBTN_RIGHT_DBL, "MOUSE_BTN2_DBL" },
{ MP_KEY_CLOSE_WIN, "CLOSE_WIN" },
{ MP_KEY_MOUSE_MOVE, "MOUSE_MOVE" },
{ MP_KEY_MOUSE_LEAVE, "MOUSE_LEAVE" },

View File

@ -98,57 +98,40 @@
#define MP_KEY_KPENTER (MP_KEY_KEYPAD+13)
// Mouse events from VOs
#define MP_MOUSE_BASE ((MP_KEY_BASE+0xA0)|MP_NO_REPEAT_KEY|MP_KEY_EMIT_ON_UP)
#define MP_MOUSE_BTN0 (MP_MOUSE_BASE+0)
#define MP_MOUSE_BTN1 (MP_MOUSE_BASE+1)
#define MP_MOUSE_BTN2 (MP_MOUSE_BASE+2)
#define MP_MOUSE_BTN3 (MP_MOUSE_BASE+3)
#define MP_MOUSE_BTN4 (MP_MOUSE_BASE+4)
#define MP_MOUSE_BTN5 (MP_MOUSE_BASE+5)
#define MP_MOUSE_BTN6 (MP_MOUSE_BASE+6)
#define MP_MOUSE_BTN7 (MP_MOUSE_BASE+7)
#define MP_MOUSE_BTN8 (MP_MOUSE_BASE+8)
#define MP_MOUSE_BTN9 (MP_MOUSE_BASE+9)
#define MP_MOUSE_BTN10 (MP_MOUSE_BASE+10)
#define MP_MOUSE_BTN11 (MP_MOUSE_BASE+11)
#define MP_MOUSE_BTN12 (MP_MOUSE_BASE+12)
#define MP_MOUSE_BTN13 (MP_MOUSE_BASE+13)
#define MP_MOUSE_BTN14 (MP_MOUSE_BASE+14)
#define MP_MOUSE_BTN15 (MP_MOUSE_BASE+15)
#define MP_MOUSE_BTN16 (MP_MOUSE_BASE+16)
#define MP_MOUSE_BTN17 (MP_MOUSE_BASE+17)
#define MP_MOUSE_BTN18 (MP_MOUSE_BASE+18)
#define MP_MOUSE_BTN19 (MP_MOUSE_BASE+19)
#define MP_MOUSE_BTN_END (MP_MOUSE_BASE+20)
#define MP_MOUSE_BASE ((MP_KEY_BASE+0xA0)|MP_NO_REPEAT_KEY|MP_KEY_EMIT_ON_UP)
#define MP_MBTN_LEFT (MP_MOUSE_BASE+0)
#define MP_MBTN_MID (MP_MOUSE_BASE+1)
#define MP_MBTN_RIGHT (MP_MOUSE_BASE+2)
#define MP_WHEEL_UP (MP_MOUSE_BASE+3)
#define MP_WHEEL_DOWN (MP_MOUSE_BASE+4)
#define MP_WHEEL_LEFT (MP_MOUSE_BASE+5)
#define MP_WHEEL_RIGHT (MP_MOUSE_BASE+6)
#define MP_MBTN_BACK (MP_MOUSE_BASE+7)
#define MP_MBTN_FORWARD (MP_MOUSE_BASE+8)
#define MP_MBTN9 (MP_MOUSE_BASE+9)
#define MP_MBTN10 (MP_MOUSE_BASE+10)
#define MP_MBTN11 (MP_MOUSE_BASE+11)
#define MP_MBTN12 (MP_MOUSE_BASE+12)
#define MP_MBTN13 (MP_MOUSE_BASE+13)
#define MP_MBTN14 (MP_MOUSE_BASE+14)
#define MP_MBTN15 (MP_MOUSE_BASE+15)
#define MP_MBTN16 (MP_MOUSE_BASE+16)
#define MP_MBTN17 (MP_MOUSE_BASE+17)
#define MP_MBTN18 (MP_MOUSE_BASE+18)
#define MP_MBTN19 (MP_MOUSE_BASE+19)
#define MP_MOUSE_END (MP_MOUSE_BASE+20)
#define MP_KEY_IS_MOUSE_BTN_SINGLE(code) \
((code) >= MP_MOUSE_BASE && (code) < MP_MOUSE_BTN_END)
((code) >= MP_MOUSE_BASE && (code) < MP_MOUSE_END)
#define MP_MOUSE_BASE_DBL ((MP_KEY_BASE+0xC0)|MP_NO_REPEAT_KEY)
#define MP_MOUSE_BTN0_DBL (MP_MOUSE_BASE_DBL+0)
#define MP_MOUSE_BTN1_DBL (MP_MOUSE_BASE_DBL+1)
#define MP_MOUSE_BTN2_DBL (MP_MOUSE_BASE_DBL+2)
#define MP_MOUSE_BTN3_DBL (MP_MOUSE_BASE_DBL+3)
#define MP_MOUSE_BTN4_DBL (MP_MOUSE_BASE_DBL+4)
#define MP_MOUSE_BTN5_DBL (MP_MOUSE_BASE_DBL+5)
#define MP_MOUSE_BTN6_DBL (MP_MOUSE_BASE_DBL+6)
#define MP_MOUSE_BTN7_DBL (MP_MOUSE_BASE_DBL+7)
#define MP_MOUSE_BTN8_DBL (MP_MOUSE_BASE_DBL+8)
#define MP_MOUSE_BTN9_DBL (MP_MOUSE_BASE_DBL+9)
#define MP_MOUSE_BTN10_DBL (MP_MOUSE_BASE_DBL+10)
#define MP_MOUSE_BTN11_DBL (MP_MOUSE_BASE_DBL+11)
#define MP_MOUSE_BTN12_DBL (MP_MOUSE_BASE_DBL+12)
#define MP_MOUSE_BTN13_DBL (MP_MOUSE_BASE_DBL+13)
#define MP_MOUSE_BTN14_DBL (MP_MOUSE_BASE_DBL+14)
#define MP_MOUSE_BTN15_DBL (MP_MOUSE_BASE_DBL+15)
#define MP_MOUSE_BTN16_DBL (MP_MOUSE_BASE_DBL+16)
#define MP_MOUSE_BTN17_DBL (MP_MOUSE_BASE_DBL+17)
#define MP_MOUSE_BTN18_DBL (MP_MOUSE_BASE_DBL+18)
#define MP_MOUSE_BTN19_DBL (MP_MOUSE_BASE_DBL+19)
#define MP_MOUSE_BTN_DBL_END (MP_MOUSE_BASE_DBL+20)
#define MP_MOUSE_DBL_BASE ((MP_KEY_BASE+0xC0)|MP_NO_REPEAT_KEY)
#define MP_MBTN_LEFT_DBL (MP_MOUSE_DBL_BASE+0)
#define MP_MBTN_MID_DBL (MP_MOUSE_DBL_BASE+1)
#define MP_MBTN_RIGHT_DBL (MP_MOUSE_DBL_BASE+2)
#define MP_MOUSE_DBL_END (MP_MOUSE_DBL_BASE+20)
#define MP_KEY_IS_MOUSE_BTN_DBL(code) \
((code) >= MP_MOUSE_BTN0_DBL && (code) < MP_MOUSE_BTN_DBL_END)
((code) >= MP_MOUSE_DBL_BASE && (code) < MP_MOUSE_DBL_END)
// Apple Remote input module
#define MP_AR_BASE (MP_KEY_BASE+0xE0)

View File

@ -5601,7 +5601,12 @@ int run_command(struct MPContext *mpctx, struct mp_cmd *cmd, struct mpv_node *re
return -1;
}
const bool dbc = cmd->args[3].v.i;
button += dbc ? MP_MOUSE_BASE_DBL : MP_MOUSE_BASE;
if (dbc && button > (MP_MBTN_RIGHT - MP_MOUSE_BASE)) {
MP_ERR(mpctx, "%d is not a valid mouse button for double-clicks.\n",
button);
return -1;
}
button += dbc ? MP_MOUSE_DBL_BASE : MP_MOUSE_BASE;
mp_input_set_mouse_pos_artificial(mpctx->input, x, y);
mp_input_put_key_artificial(mpctx->input, button);
break;

View File

@ -1000,7 +1000,7 @@ layouts["box"] = function ()
lo.style = osc_styles.smallButtonsR
lo = add_layout("volume")
lo.geometry =
lo.geometry =
{x = posX+pos_offsetX - (25 * 2) - osc_geo.p,
y = bigbtnrowY, an = 4, w = 25, h = 25}
lo.style = osc_styles.smallButtonsR
@ -1550,7 +1550,7 @@ function osc_init()
return not (title == "") and title or "mpv"
end
ne.eventresponder["mouse_btn0_up"] = function ()
ne.eventresponder["mbtn_left_up"] = function ()
local title = mp.get_property_osd("media-title")
if (have_pl) then
title = string.format("[%d/%d] %s", countone(pl_pos - 1),
@ -1559,7 +1559,7 @@ function osc_init()
show_message(title)
end
ne.eventresponder["mouse_btn2_up"] =
ne.eventresponder["mbtn_right_up"] =
function () show_message(mp.get_property_osd("filename")) end
-- playlist buttons
@ -1569,14 +1569,14 @@ function osc_init()
ne.content = "\238\132\144"
ne.enabled = (pl_pos > 1) or (loop ~= "no")
ne.eventresponder["mouse_btn0_up"] =
ne.eventresponder["mbtn_left_up"] =
function ()
mp.commandv("playlist-prev", "weak")
show_message(get_playlist(), 3)
end
ne.eventresponder["shift+mouse_btn0_up"] =
ne.eventresponder["shift+mbtn_left_up"] =
function () show_message(get_playlist(), 3) end
ne.eventresponder["mouse_btn2_up"] =
ne.eventresponder["mbtn_right_up"] =
function () show_message(get_playlist(), 3) end
--next
@ -1584,14 +1584,14 @@ function osc_init()
ne.content = "\238\132\129"
ne.enabled = (have_pl and (pl_pos < pl_count)) or (loop ~= "no")
ne.eventresponder["mouse_btn0_up"] =
ne.eventresponder["mbtn_left_up"] =
function ()
mp.commandv("playlist-next", "weak")
show_message(get_playlist(), 3)
end
ne.eventresponder["shift+mouse_btn0_up"] =
ne.eventresponder["shift+mbtn_left_up"] =
function () show_message(get_playlist(), 3) end
ne.eventresponder["mouse_btn2_up"] =
ne.eventresponder["mbtn_right_up"] =
function () show_message(get_playlist(), 3) end
@ -1607,7 +1607,7 @@ function osc_init()
return ("\238\128\130")
end
end
ne.eventresponder["mouse_btn0_up"] =
ne.eventresponder["mbtn_left_up"] =
function () mp.commandv("cycle", "pause") end
--skipback
@ -1615,11 +1615,11 @@ function osc_init()
ne.softrepeat = true
ne.content = "\238\128\132"
ne.eventresponder["mouse_btn0_down"] =
ne.eventresponder["mbtn_left_down"] =
function () mp.commandv("seek", -5, "relative", "keyframes") end
ne.eventresponder["shift+mouse_btn0_down"] =
ne.eventresponder["shift+mbtn_left_down"] =
function () mp.commandv("frame-back-step") end
ne.eventresponder["mouse_btn2_down"] =
ne.eventresponder["mbtn_right_down"] =
function () mp.commandv("seek", -30, "relative", "keyframes") end
--skipfrwd
@ -1627,11 +1627,11 @@ function osc_init()
ne.softrepeat = true
ne.content = "\238\128\133"
ne.eventresponder["mouse_btn0_down"] =
ne.eventresponder["mbtn_left_down"] =
function () mp.commandv("seek", 10, "relative", "keyframes") end
ne.eventresponder["shift+mouse_btn0_down"] =
ne.eventresponder["shift+mbtn_left_down"] =
function () mp.commandv("frame-step") end
ne.eventresponder["mouse_btn2_down"] =
ne.eventresponder["mbtn_right_down"] =
function () mp.commandv("seek", 60, "relative", "keyframes") end
--ch_prev
@ -1639,14 +1639,14 @@ function osc_init()
ne.enabled = have_ch
ne.content = "\238\132\132"
ne.eventresponder["mouse_btn0_up"] =
ne.eventresponder["mbtn_left_up"] =
function ()
mp.commandv("add", "chapter", -1)
show_message(get_chapterlist(), 3)
end
ne.eventresponder["shift+mouse_btn0_up"] =
ne.eventresponder["shift+mbtn_left_up"] =
function () show_message(get_chapterlist(), 3) end
ne.eventresponder["mouse_btn2_up"] =
ne.eventresponder["mbtn_right_up"] =
function () show_message(get_chapterlist(), 3) end
--ch_next
@ -1654,14 +1654,14 @@ function osc_init()
ne.enabled = have_ch
ne.content = "\238\132\133"
ne.eventresponder["mouse_btn0_up"] =
ne.eventresponder["mbtn_left_up"] =
function ()
mp.commandv("add", "chapter", 1)
show_message(get_chapterlist(), 3)
end
ne.eventresponder["shift+mouse_btn0_up"] =
ne.eventresponder["shift+mbtn_left_up"] =
function () show_message(get_chapterlist(), 3) end
ne.eventresponder["mouse_btn2_up"] =
ne.eventresponder["mbtn_right_up"] =
function () show_message(get_chapterlist(), 3) end
--
@ -1679,11 +1679,11 @@ function osc_init()
return ("\238\132\134" .. osc_styles.smallButtonsLlabel
.. " " .. aid .. "/" .. #tracks_osc.audio)
end
ne.eventresponder["mouse_btn0_up"] =
ne.eventresponder["mbtn_left_up"] =
function () set_track("audio", 1) end
ne.eventresponder["mouse_btn2_up"] =
ne.eventresponder["mbtn_right_up"] =
function () set_track("audio", -1) end
ne.eventresponder["shift+mouse_btn0_down"] =
ne.eventresponder["shift+mbtn_left_down"] =
function () show_message(get_tracklist("audio"), 2) end
--cy_sub
@ -1698,11 +1698,11 @@ function osc_init()
return ("\238\132\135" .. osc_styles.smallButtonsLlabel
.. " " .. sid .. "/" .. #tracks_osc.sub)
end
ne.eventresponder["mouse_btn0_up"] =
ne.eventresponder["mbtn_left_up"] =
function () set_track("sub", 1) end
ne.eventresponder["mouse_btn2_up"] =
ne.eventresponder["mbtn_right_up"] =
function () set_track("sub", -1) end
ne.eventresponder["shift+mouse_btn0_down"] =
ne.eventresponder["shift+mbtn_left_down"] =
function () show_message(get_tracklist("sub"), 2) end
--tog_fs
@ -1714,7 +1714,7 @@ function osc_init()
return ("\238\132\136")
end
end
ne.eventresponder["mouse_btn0_up"] =
ne.eventresponder["mbtn_left_up"] =
function () mp.commandv("cycle", "fullscreen") end
@ -1760,7 +1760,7 @@ function osc_init()
end
end
ne.eventresponder["mouse_btn0_down"] = --exact seeks on single clicks
ne.eventresponder["mbtn_left_down"] = --exact seeks on single clicks
function (element) mp.commandv("seek", get_slider_value(element),
"absolute-percent", "exact") end
ne.eventresponder["reset"] =
@ -1777,7 +1777,7 @@ function osc_init()
return (mp.get_property_osd("playback-time"))
end
end
ne.eventresponder["mouse_btn0_up"] = function ()
ne.eventresponder["mbtn_left_up"] = function ()
state.tc_ms = not state.tc_ms
request_init()
end
@ -1801,7 +1801,7 @@ function osc_init()
end
end
end
ne.eventresponder["mouse_btn0_up"] =
ne.eventresponder["mbtn_left_up"] =
function () state.rightTC_trem = not state.rightTC_trem end
-- cache
@ -1848,12 +1848,12 @@ function osc_init()
return volicon[math.min(4,math.ceil(volume / (100/3)))]
end
end
ne.eventresponder["mouse_btn0_up"] =
ne.eventresponder["mbtn_left_up"] =
function () mp.commandv("cycle", "mute") end
ne.eventresponder["mouse_wheel_up_press"] =
ne.eventresponder["wheel_up_press"] =
function () mp.commandv("osd-auto", "add", "volume", 5) end
ne.eventresponder["mouse_wheel_down_press"] =
ne.eventresponder["wheel_down_press"] =
function () mp.commandv("osd-auto", "add", "volume", -5) end
@ -2296,19 +2296,19 @@ do_enable_keybindings()
--mouse input bindings
mp.set_key_bindings({
{"mouse_btn0", function(e) process_event("mouse_btn0", "up") end,
function(e) process_event("mouse_btn0", "down") end},
{"shift+mouse_btn0", function(e) process_event("shift+mouse_btn0", "up") end,
function(e) process_event("shift+mouse_btn0", "down") end},
{"mouse_btn2", function(e) process_event("mouse_btn2", "up") end,
function(e) process_event("mouse_btn2", "down") end},
{"mouse_btn3", function(e) process_event("mouse_wheel_up", "press") end},
{"mouse_btn4", function(e) process_event("mouse_wheel_down", "press") end},
{"axis_up", function(e) process_event("mouse_wheel_up", "press") end},
{"axis_down", function(e) process_event("mouse_wheel_down", "press") end},
{"mouse_btn0_dbl", "ignore"},
{"shift+mouse_btn0_dbl", "ignore"},
{"mouse_btn2_dbl", "ignore"},
{"mbtn_left", function(e) process_event("mbtn_left", "up") end,
function(e) process_event("mbtn_left", "down") end},
{"shift+mbtn_left", function(e) process_event("shift+mbtn_left", "up") end,
function(e) process_event("shift+mbtn_left", "down") end},
{"mbtn_right", function(e) process_event("mbtn_right", "up") end,
function(e) process_event("mbtn_right", "down") end},
{"wheel_up", function(e) process_event("wheel_up", "press") end},
{"wheel_down", function(e) process_event("wheel_down", "press") end},
{"axis_up", function(e) process_event("wheel_up", "press") end},
{"axis_down", function(e) process_event("wheel_down", "press") end},
{"mbtn_left_dbl", "ignore"},
{"shift+mbtn_left_dbl", "ignore"},
{"mbtn_right_dbl", "ignore"},
}, "input", "force")
mp.enable_key_bindings("input")

View File

@ -266,9 +266,9 @@
int mpkey;
if (fabs(deltaY) >= fabs(deltaX)) {
mpkey = deltaY > 0 ? MP_MOUSE_BTN3 : MP_MOUSE_BTN4;
mpkey = deltaY > 0 ? MP_WHEEL_UP : MP_WHEEL_DOWN;
} else {
mpkey = deltaX > 0 ? MP_MOUSE_BTN5 : MP_MOUSE_BTN6;
mpkey = deltaX > 0 ? MP_WHEEL_LEFT : MP_WHEEL_RIGHT;
}
[self.adapter putKey:mpkey withModifiers:modifiers];
@ -291,7 +291,7 @@
- (void)putMouseEvent:(NSEvent *)event withState:(int)state
{
self.hasMouseDown = (state == MP_KEY_STATE_DOWN);
int mpkey = (MP_MOUSE_BTN0 + [self mpvButtonNumber:event]);
int mpkey = (MP_MOUSE_BASE + [self mpvButtonNumber:event]);
[self.adapter putKey:(mpkey | state) withModifiers:[event modifierFlags]];
}

View File

@ -179,11 +179,11 @@ static void check_events(struct vo *vo)
break;
case CACA_EVENT_MOUSE_PRESS:
mp_input_put_key(vo->input_ctx,
(MP_MOUSE_BTN0 + cev.data.mouse.button - 1) | MP_KEY_STATE_DOWN);
(MP_MOUSE_BASE + cev.data.mouse.button - 1) | MP_KEY_STATE_DOWN);
break;
case CACA_EVENT_MOUSE_RELEASE:
mp_input_put_key(vo->input_ctx,
(MP_MOUSE_BTN0 + cev.data.mouse.button - 1) | MP_KEY_STATE_UP);
(MP_MOUSE_BASE + cev.data.mouse.button - 1) | MP_KEY_STATE_UP);
break;
case CACA_EVENT_KEY_PRESS:
{

View File

@ -608,11 +608,11 @@ static void wait_events(struct vo *vo, int64_t until_time_us)
break;
case SDL_MOUSEBUTTONDOWN:
mp_input_put_key(vo->input_ctx,
(MP_MOUSE_BTN0 + ev.button.button - 1) | MP_KEY_STATE_DOWN);
(MP_MOUSE_BASE + ev.button.button - 1) | MP_KEY_STATE_DOWN);
break;
case SDL_MOUSEBUTTONUP:
mp_input_put_key(vo->input_ctx,
(MP_MOUSE_BTN0 + ev.button.button - 1) | MP_KEY_STATE_UP);
(MP_MOUSE_BASE + ev.button.button - 1) | MP_KEY_STATE_UP);
break;
case SDL_MOUSEWHEEL:
break;

View File

@ -413,13 +413,13 @@ static bool handle_mouse_down(struct vo_w32_state *w32, int btn, int x, int y)
btn |= mod_state(w32);
mp_input_put_key(w32->input_ctx, btn | MP_KEY_STATE_DOWN);
if (btn == MP_MOUSE_BTN0 && !w32->current_fs &&
if (btn == MP_MBTN_LEFT && !w32->current_fs &&
!mp_input_test_dragging(w32->input_ctx, x, y))
{
// Window dragging hack
ReleaseCapture();
SendMessage(w32->window, WM_NCLBUTTONDOWN, HTCAPTION, 0);
mp_input_put_key(w32->input_ctx, MP_MOUSE_BTN0 | MP_KEY_STATE_UP);
mp_input_put_key(w32->input_ctx, MP_MBTN_LEFT | MP_KEY_STATE_UP);
// Indicate the message was handled, so DefWindowProc won't be called
return true;
@ -1096,26 +1096,26 @@ static LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam,
break;
}
case WM_LBUTTONDOWN:
if (handle_mouse_down(w32, MP_MOUSE_BTN0, GET_X_LPARAM(lParam),
GET_Y_LPARAM(lParam)))
if (handle_mouse_down(w32, MP_MBTN_LEFT, GET_X_LPARAM(lParam),
GET_Y_LPARAM(lParam)))
return 0;
break;
case WM_LBUTTONUP:
handle_mouse_up(w32, MP_MOUSE_BTN0);
handle_mouse_up(w32, MP_MBTN_LEFT);
break;
case WM_MBUTTONDOWN:
handle_mouse_down(w32, MP_MOUSE_BTN1, GET_X_LPARAM(lParam),
GET_Y_LPARAM(lParam));
handle_mouse_down(w32, MP_MBTN_MID, GET_X_LPARAM(lParam),
GET_Y_LPARAM(lParam));
break;
case WM_MBUTTONUP:
handle_mouse_up(w32, MP_MOUSE_BTN1);
handle_mouse_up(w32, MP_MBTN_MID);
break;
case WM_RBUTTONDOWN:
handle_mouse_down(w32, MP_MOUSE_BTN2, GET_X_LPARAM(lParam),
handle_mouse_down(w32, MP_MBTN_RIGHT, GET_X_LPARAM(lParam),
GET_Y_LPARAM(lParam));
break;
case WM_RBUTTONUP:
handle_mouse_up(w32, MP_MOUSE_BTN2);
handle_mouse_up(w32, MP_MBTN_RIGHT);
break;
case WM_MOUSEWHEEL:
handle_mouse_wheel(w32, false, GET_WHEEL_DELTA_WPARAM(wParam));
@ -1127,11 +1127,12 @@ static LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam,
return TRUE;
case WM_XBUTTONDOWN:
handle_mouse_down(w32,
HIWORD(wParam) == 1 ? MP_MOUSE_BTN7 : MP_MOUSE_BTN8,
GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam));
HIWORD(wParam) == 1 ? MP_MBTN_BACK : MP_MBTN_FORWARD,
GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam));
break;
case WM_XBUTTONUP:
handle_mouse_up(w32, HIWORD(wParam) == 1 ? MP_MOUSE_BTN7 : MP_MOUSE_BTN8);
handle_mouse_up(w32,
HIWORD(wParam) == 1 ? MP_MBTN_BACK : MP_MBTN_FORWARD);
break;
case WM_DISPLAYCHANGE:
force_update_display_info(w32);

View File

@ -403,7 +403,7 @@ static void pointer_handle_enter(void *data,
/* Release the left button on pointer enter again
* because after moving the shell surface no release event is sent */
mp_input_put_key(wl->vo->input_ctx, MP_KEY_MOUSE_ENTER);
mp_input_put_key(wl->vo->input_ctx, MP_MOUSE_BTN0 | MP_KEY_STATE_UP);
mp_input_put_key(wl->vo->input_ctx, MP_MBTN_LEFT | MP_KEY_STATE_UP);
show_cursor(wl);
}
@ -448,13 +448,13 @@ static void pointer_handle_button(void *data,
state = state == WL_POINTER_BUTTON_STATE_PRESSED ? MP_KEY_STATE_DOWN
: MP_KEY_STATE_UP;
button = button == BTN_LEFT ? MP_MOUSE_BTN0 :
button == BTN_MIDDLE ? MP_MOUSE_BTN1 : MP_MOUSE_BTN2;
button = button == BTN_LEFT ? MP_MBTN_LEFT :
button == BTN_MIDDLE ? MP_MBTN_MID : MP_MBTN_RIGHT;
mp_input_put_key(wl->vo->input_ctx, button | state);
if (!mp_input_test_dragging(wl->vo->input_ctx, wl->window.mouse_x, wl->window.mouse_y) &&
(button == MP_MOUSE_BTN0) && (state == MP_KEY_STATE_DOWN))
(button == MP_MBTN_LEFT) && (state == MP_KEY_STATE_DOWN))
window_move(wl, serial);
}

View File

@ -1136,7 +1136,7 @@ void vo_x11_check_events(struct vo *vo)
if (Event.xbutton.button == 1)
x11->win_drag_button1_down = true;
mp_input_put_key(x11->input_ctx,
(MP_MOUSE_BTN0 + Event.xbutton.button - 1) |
(MP_MOUSE_BASE + Event.xbutton.button - 1) |
get_mods(Event.xbutton.state) | MP_KEY_STATE_DOWN);
long msg[4] = {XEMBED_REQUEST_FOCUS};
vo_x11_xembed_send_message(x11, msg);
@ -1145,7 +1145,7 @@ void vo_x11_check_events(struct vo *vo)
if (Event.xbutton.button == 1)
x11->win_drag_button1_down = false;
mp_input_put_key(x11->input_ctx,
(MP_MOUSE_BTN0 + Event.xbutton.button - 1) |
(MP_MOUSE_BASE + Event.xbutton.button - 1) |
get_mods(Event.xbutton.state) | MP_KEY_STATE_UP);
break;
case MapNotify: