mirror of
https://github.com/mpv-player/mpv
synced 2025-04-11 04:01:31 +00:00
input: add a prefix to make any binding act on key repeat
The fact that it's a generic command prefix that is parsed even when using the client API is a bit unclean (because this flag makes sense for actual key-bindings only), but it's less code this way.
This commit is contained in:
parent
a1811211a2
commit
0a78a61d89
@ -587,7 +587,9 @@ prefixes can be specified. They are separated by whitespace.
|
|||||||
Do not expand properties in string arguments. (Like ``"${property-name}"``.)
|
Do not expand properties in string arguments. (Like ``"${property-name}"``.)
|
||||||
``expand-properties`` (default)
|
``expand-properties`` (default)
|
||||||
All string arguments are expanded as described in `Property Expansion`_.
|
All string arguments are expanded as described in `Property Expansion`_.
|
||||||
|
``repeatable``
|
||||||
|
For some commands, keeping a key pressed doesn't run the command repeatedly.
|
||||||
|
This prefix forces enabling key repeat in any case.
|
||||||
|
|
||||||
All of the osd prefixes are still overridden by the global ``--osd-level``
|
All of the osd prefixes are still overridden by the global ``--osd-level``
|
||||||
settings.
|
settings.
|
||||||
|
@ -297,7 +297,8 @@ bool mp_input_is_abort_cmd(struct mp_cmd *cmd)
|
|||||||
bool mp_input_is_repeatable_cmd(struct mp_cmd *cmd)
|
bool mp_input_is_repeatable_cmd(struct mp_cmd *cmd)
|
||||||
{
|
{
|
||||||
return (cmd->def && cmd->def->allow_auto_repeat) ||
|
return (cmd->def && cmd->def->allow_auto_repeat) ||
|
||||||
cmd->id == MP_CMD_COMMAND_LIST;
|
cmd->id == MP_CMD_COMMAND_LIST ||
|
||||||
|
(cmd->flags & MP_ALLOW_REPEAT);
|
||||||
}
|
}
|
||||||
|
|
||||||
void mp_print_cmd_list(struct mp_log *out)
|
void mp_print_cmd_list(struct mp_log *out)
|
||||||
|
@ -49,6 +49,7 @@ static const struct flag cmd_flags[] = {
|
|||||||
{"osd-auto", MP_ON_OSD_FLAGS, MP_ON_OSD_AUTO},
|
{"osd-auto", MP_ON_OSD_FLAGS, MP_ON_OSD_AUTO},
|
||||||
{"expand-properties", 0, MP_EXPAND_PROPERTIES},
|
{"expand-properties", 0, MP_EXPAND_PROPERTIES},
|
||||||
{"raw", MP_EXPAND_PROPERTIES, 0},
|
{"raw", MP_EXPAND_PROPERTIES, 0},
|
||||||
|
{"repeatable", 0, MP_ALLOW_REPEAT},
|
||||||
{0}
|
{0}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -883,7 +883,8 @@ mp_cmd_t *mp_input_read_cmd(struct input_ctx *ictx)
|
|||||||
struct mp_cmd *ret = queue_remove_head(&ictx->cmd_queue);
|
struct mp_cmd *ret = queue_remove_head(&ictx->cmd_queue);
|
||||||
if (!ret) {
|
if (!ret) {
|
||||||
ret = check_autorepeat(ictx);
|
ret = check_autorepeat(ictx);
|
||||||
if (ret)
|
// (if explicitly repeated, don't let command.c ignore it)
|
||||||
|
if (ret && !(ret->flags & MP_ALLOW_REPEAT))
|
||||||
ret->repeated = true;
|
ret->repeated = true;
|
||||||
}
|
}
|
||||||
if (ret && ret->mouse_move) {
|
if (ret && ret->mouse_move) {
|
||||||
|
@ -34,6 +34,7 @@ enum mp_cmd_flags {
|
|||||||
MP_ON_OSD_BAR = 2, // force a bar, if applicable
|
MP_ON_OSD_BAR = 2, // force a bar, if applicable
|
||||||
MP_ON_OSD_MSG = 4, // force a message, if applicable
|
MP_ON_OSD_MSG = 4, // force a message, if applicable
|
||||||
MP_EXPAND_PROPERTIES = 8, // expand strings as properties
|
MP_EXPAND_PROPERTIES = 8, // expand strings as properties
|
||||||
|
MP_ALLOW_REPEAT = 16, // if used as keybinding, allow key repeat
|
||||||
|
|
||||||
MP_ON_OSD_FLAGS = MP_ON_OSD_NO | MP_ON_OSD_AUTO |
|
MP_ON_OSD_FLAGS = MP_ON_OSD_NO | MP_ON_OSD_AUTO |
|
||||||
MP_ON_OSD_BAR | MP_ON_OSD_MSG,
|
MP_ON_OSD_BAR | MP_ON_OSD_MSG,
|
||||||
|
Loading…
Reference in New Issue
Block a user