diff --git a/DOCS/man/input.rst b/DOCS/man/input.rst index 920cd0b5ae126..38daba4cdd6b1 100644 --- a/DOCS/man/input.rst +++ b/DOCS/man/input.rst @@ -1273,11 +1273,12 @@ Scripting Commands This command has a variable number of arguments, and cannot be used with named arguments. -``script-binding `` +``script-binding []`` Invoke a script-provided key binding. This can be used to remap key bindings provided by external Lua scripts. - The argument is the name of the binding. + ```` is the name of the binding. ```` is a user-provided + arbitrary string which can be used to provide extra information. It can optionally be prefixed with the name of the script, using ``/`` as separator, e.g. ``script-binding scriptname/bindingname``. Note that script @@ -1295,6 +1296,8 @@ Scripting Commands 5. The text the key would produce, or empty string if not applicable. 6. The scale of the key, such as the ones produced by ``WHEEL_*`` keys. The scale is 1 if the key is nonscalable. + 7. The user-provided string ````, or empty string if the argument is + not used. The 5th argument is only set if no modifiers are present (using the shift key with a letter is normally not emitted as having a modifier, and results diff --git a/player/command.c b/player/command.c index ee972733d3ae3..9e43c26fdb5f1 100644 --- a/player/command.c +++ b/player/command.c @@ -6439,11 +6439,11 @@ static void cmd_script_binding(void *p) char *scale_s = mp_format_double(NULL, scale, 6, false, false, false); for (int i = 0; i < scale_units; i++) { - event.num_args = 6; - event.args = (const char*[6]){"key-binding", name, state, + event.num_args = 7; + event.args = (const char*[7]){"key-binding", name, state, incmd->key_name ? incmd->key_name : "", incmd->key_text ? incmd->key_text : "", - scale_s}; + scale_s, cmd->args[1].v.s}; if (mp_client_send_event_dup(mpctx, target, MPV_EVENT_CLIENT_MESSAGE, &event) < 0) { @@ -7156,7 +7156,12 @@ const struct mp_cmd_def mp_cmds[] = { { "ao-reload", cmd_ao_reload }, - { "script-binding", cmd_script_binding, { {"name", OPT_STRING(v.s)} }, + { "script-binding", cmd_script_binding, + { + {"name", OPT_STRING(v.s)}, + {"arg", OPT_STRING(v.s), OPTDEF_STR(""), + .flags = MP_CMD_OPT_ARG}, + }, .allow_auto_repeat = true, .on_updown = true, .scalable = true }, { "script-message", cmd_script_message, { {"args", OPT_STRING(v.s)} },