lua: always handle key repeat on the script side

Simpler, and leaves the decision to repeat or not fully to the script
(instead of requiring the user to care about it when remapping a script
binding).
This commit is contained in:
wm4 2014-11-24 16:47:03 +01:00
parent 2a017734a5
commit 89c1525585
2 changed files with 8 additions and 5 deletions

View File

@ -166,7 +166,9 @@ const struct mp_cmd_def mp_cmds[] = {
{ MP_CMD_VO_CMDLINE, "vo_cmdline", { ARG_STRING } },
{ MP_CMD_SCRIPT_BINDING, "script_binding", { ARG_STRING } },
{ MP_CMD_SCRIPT_BINDING, "script_binding", { ARG_STRING },
.allow_auto_repeat = true},
{ MP_CMD_SCRIPT_MESSAGE, "script_message", { ARG_STRING }, .vararg = true },
{ MP_CMD_SCRIPT_MESSAGE_TO, "script_message_to", { ARG_STRING, ARG_STRING },
.vararg = true },

View File

@ -75,7 +75,7 @@ function mp.set_key_bindings(list, section, flags)
local is_mouse = state:sub(2, 2) == "m"
local def = (is_mouse and "u") or "d"
if event == "r" then
event = "d"
return
end
if event == "p" and cb then
cb()
@ -142,9 +142,7 @@ local function add_binding(attrs, key, name, fn, rp)
name = reserve_binding()
end
local bind = key
if rp == "repeatable" or rp["repeatable"] then
bind = bind .. " repeatable"
end
local repeatable = rp == "repeatable" or rp["repeatable"]
if rp["forced"] then
attrs.forced = true
end
@ -176,6 +174,9 @@ local function add_binding(attrs, key, name, fn, rp)
-- Also, key repeat triggers the binding again.
local event = state:sub(1, 1)
local is_mouse = state:sub(2, 2) == "m"
if event == "r" and not repeatable then
return
end
if is_mouse and event == "u" then
fn()
elseif (not is_mouse) and (event == "d" or event == "r") then