summaryrefslogtreecommitdiffstats
path: root/input
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2012-10-12 09:21:26 +0200
committerwm4 <wm4@nowhere>2012-10-12 10:13:43 +0200
commite1b15dee4c250bf6509594e241eb2856c8d21e0f (patch)
tree180e8796a5e79b9f18fb08193db2e3ca0e8a16f3 /input
parent32fe890cc1f9c90699fb9cd9eb5f42e597d9665a (diff)
downloadmpv-e1b15dee4c250bf6509594e241eb2856c8d21e0f.tar.bz2
mpv-e1b15dee4c250bf6509594e241eb2856c8d21e0f.tar.xz
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.
Diffstat (limited to 'input')
-rw-r--r--input/input.c29
1 files changed, 28 insertions, 1 deletions
diff --git a/input/input.c b/input/input.c
index 28a5af2112..afaa50a5ce 100644
--- a/input/input.c
+++ b/input/input.c
@@ -100,6 +100,13 @@ struct key_name {
M_CHOICES(c)}, \
.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[] = {
{ MP_CMD_IGNORE, "ignore", },
#ifdef CONFIG_RADIO
@@ -173,7 +180,12 @@ static const mp_cmd_t mp_cmds[] = {
{ MP_CMD_SET, "set", { ARG_STRING, ARG_STRING } },
{ MP_CMD_GET_PROPERTY, "get_property", { ARG_STRING } },
{ 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 } },
@@ -730,6 +742,21 @@ int mp_input_add_key_fd(struct input_ctx *ictx, int fd, int select,
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)
{
bstr t = bstr_lstrip(str);