mirror of https://github.com/mpv-player/mpv
command: support passing scale to `keypress`
This commit is contained in:
parent
a08e8e0b46
commit
00942d56ba
|
@ -827,11 +827,13 @@ Remember to quote string arguments in input.conf (see `Flat command syntax`_).
|
|||
<double>
|
||||
The mouse event represents double-click.
|
||||
|
||||
``keypress <name>``
|
||||
``keypress <name> [<scale>]``
|
||||
Send a key event through mpv's input handler, triggering whatever
|
||||
behavior is configured to that key. ``name`` uses the ``input.conf``
|
||||
naming scheme for keys and modifiers. Useful for the client API: key events
|
||||
can be sent to libmpv to handle internally.
|
||||
naming scheme for keys and modifiers. ``scale`` is used to scale numerical
|
||||
change effected by the bound command (same mechanism as precise scrolling).
|
||||
Useful for the client API: key events can be sent to libmpv to handle
|
||||
internally.
|
||||
|
||||
``keydown <name>``
|
||||
Similar to ``keypress``, but sets the ``KEYDOWN`` flag so that if the key is
|
||||
|
|
|
@ -6197,7 +6197,8 @@ static void cmd_key(void *p)
|
|||
cmd->success = false;
|
||||
return;
|
||||
}
|
||||
mp_input_put_key_artificial(mpctx->input, code | action, 1);
|
||||
double scale = action == 0 ? cmd->args[1].v.d : 1;
|
||||
mp_input_put_key_artificial(mpctx->input, code | action, scale);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -6753,7 +6754,8 @@ const struct mp_cmd_def mp_cmds[] = {
|
|||
.flags = MP_CMD_OPT_ARG}}},
|
||||
{ "keybind", cmd_key_bind, { {"name", OPT_STRING(v.s)},
|
||||
{"cmd", OPT_STRING(v.s)} }},
|
||||
{ "keypress", cmd_key, { {"name", OPT_STRING(v.s)} },
|
||||
{ "keypress", cmd_key, { {"name", OPT_STRING(v.s)},
|
||||
{"scale", OPT_DOUBLE(v.d), OPTDEF_DOUBLE(1)} },
|
||||
.priv = &(const int){0}},
|
||||
{ "keydown", cmd_key, { {"name", OPT_STRING(v.s)} },
|
||||
.priv = &(const int){MP_KEY_STATE_DOWN}},
|
||||
|
|
Loading…
Reference in New Issue