mirror of https://github.com/mpv-player/mpv
commands: use "up" and "down" as 2nd argument for cycle command
Allow the values "up" and "down" as step argument for the cycle input command. Previously, this argument was a float, which specified an arbitrary step value and direction (similar to the add command). Instead of "1" and "-1", "up" and "down" is to be used. Float values are still accepted. That capability might be removed in the future, as there's probably hardly any actual use for arbitrary step values.
This commit is contained in:
parent
32fe890cc1
commit
e1b15dee4c
|
@ -79,10 +79,10 @@ add <property> [<value>]
|
||||||
Add the given value to the property. On overflow or underflow, clamp the
|
Add the given value to the property. On overflow or underflow, clamp the
|
||||||
property to the maximum. If <value> is omitted, assume ``1``.
|
property to the maximum. If <value> is omitted, assume ``1``.
|
||||||
|
|
||||||
cycle <property> [<value>]
|
cycle <property> [up|down]
|
||||||
Cycle the given property. Negative values cycle the property backwards. On
|
Cycle the given property. ``up`` and ``down`` set the cycle direction. On
|
||||||
overflow, set the property back to the minimum, on underflow set it to the
|
overflow, set the property back to the minimum, on underflow set it to the
|
||||||
maximum. If <value> is omitted, assume ``1``.
|
maximum. If ``up`` or ``down`` is omitted, assume ``up``.
|
||||||
|
|
||||||
speed_mult <value>
|
speed_mult <value>
|
||||||
Multiply the ``speed`` property by the given value.
|
Multiply the ``speed`` property by the given value.
|
||||||
|
|
|
@ -93,7 +93,7 @@ v cycle sub-visibility
|
||||||
# stretch SSA/ASS subtitles with anamorphic videos to match historical
|
# stretch SSA/ASS subtitles with anamorphic videos to match historical
|
||||||
V cycle ass-vsfilter-aspect-compat
|
V cycle ass-vsfilter-aspect-compat
|
||||||
j cycle sub # cycle through subtitles
|
j cycle sub # cycle through subtitles
|
||||||
J cycle sub -1 # ...backwards
|
J cycle sub down # ...backwards
|
||||||
F cycle sub-forced-only
|
F cycle sub-forced-only
|
||||||
SHARP cycle audio # switch audio streams
|
SHARP cycle audio # switch audio streams
|
||||||
_ cycle video
|
_ cycle video
|
||||||
|
|
|
@ -100,6 +100,13 @@ struct key_name {
|
||||||
M_CHOICES(c)}, \
|
M_CHOICES(c)}, \
|
||||||
.optional = true, .v.i = def }
|
.optional = true, .v.i = def }
|
||||||
|
|
||||||
|
static int parse_cycle_dir(const struct m_option *opt, struct bstr name,
|
||||||
|
struct bstr param, void *dst);
|
||||||
|
static const struct m_option_type m_option_type_cycle_dir = {
|
||||||
|
.name = "up|down",
|
||||||
|
.parse = parse_cycle_dir,
|
||||||
|
};
|
||||||
|
|
||||||
static const mp_cmd_t mp_cmds[] = {
|
static const mp_cmd_t mp_cmds[] = {
|
||||||
{ MP_CMD_IGNORE, "ignore", },
|
{ MP_CMD_IGNORE, "ignore", },
|
||||||
#ifdef CONFIG_RADIO
|
#ifdef CONFIG_RADIO
|
||||||
|
@ -173,7 +180,12 @@ static const mp_cmd_t mp_cmds[] = {
|
||||||
{ MP_CMD_SET, "set", { ARG_STRING, ARG_STRING } },
|
{ MP_CMD_SET, "set", { ARG_STRING, ARG_STRING } },
|
||||||
{ MP_CMD_GET_PROPERTY, "get_property", { ARG_STRING } },
|
{ MP_CMD_GET_PROPERTY, "get_property", { ARG_STRING } },
|
||||||
{ MP_CMD_ADD, "add", { ARG_STRING, OARG_FLOAT(0) } },
|
{ MP_CMD_ADD, "add", { ARG_STRING, OARG_FLOAT(0) } },
|
||||||
{ MP_CMD_CYCLE, "cycle", { ARG_STRING, OARG_FLOAT(0) } },
|
{ MP_CMD_CYCLE, "cycle", {
|
||||||
|
ARG_STRING,
|
||||||
|
{ .type = {"", NULL, &m_option_type_cycle_dir},
|
||||||
|
.optional = true,
|
||||||
|
.v.f = 1 },
|
||||||
|
}},
|
||||||
|
|
||||||
{ MP_CMD_SET_MOUSE_POS, "set_mouse_pos", { ARG_INT, ARG_INT } },
|
{ MP_CMD_SET_MOUSE_POS, "set_mouse_pos", { ARG_INT, ARG_INT } },
|
||||||
|
|
||||||
|
@ -730,6 +742,21 @@ int mp_input_add_key_fd(struct input_ctx *ictx, int fd, int select,
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int parse_cycle_dir(const struct m_option *opt, struct bstr name,
|
||||||
|
struct bstr param, void *dst)
|
||||||
|
{
|
||||||
|
float val;
|
||||||
|
if (bstrcmp0(param, "up") == 0) {
|
||||||
|
val = +1;
|
||||||
|
} else if (bstrcmp0(param, "down") == 0) {
|
||||||
|
val = -1;
|
||||||
|
} else {
|
||||||
|
return m_option_type_float.parse(opt, name, param, dst);
|
||||||
|
}
|
||||||
|
*(float *)dst = val;
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
static bool read_token(bstr str, bstr *out_rest, bstr *out_token)
|
static bool read_token(bstr str, bstr *out_rest, bstr *out_token)
|
||||||
{
|
{
|
||||||
bstr t = bstr_lstrip(str);
|
bstr t = bstr_lstrip(str);
|
||||||
|
|
Loading…
Reference in New Issue