summaryrefslogtreecommitdiffstats
path: root/input
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2015-09-10 14:15:12 +0200
committerwm4 <wm4@nowhere>2015-09-10 14:15:48 +0200
commitf1205293a70b13f53bfce0a1a9859132b8421443 (patch)
treefb6ead7e0fbfedbfe9454144ef5349f87de60529 /input
parent2492b5f1198161a04b046554df79390eb312ca5c (diff)
downloadmpv-f1205293a70b13f53bfce0a1a9859132b8421443.tar.bz2
mpv-f1205293a70b13f53bfce0a1a9859132b8421443.tar.xz
command: make "add <property> 0" not change the value
The value 0 was treated specially, and effectively forced the increment to 1. Interestingly, passing 0 or no value also does not include the scale (from touchpads etc.), but this is probably an accidental behavior that was never intentionally added. Simplify it and make the default increment 1. 0 now means what it should: the value will not be changed. This is not particularly useful, but on the other hand there is no need for surprising and unintuitive semantics. OARG_CYCLEDIR() failed to apply the default value, because m_option_type_cycle_dir was missing a copy handler - add this too.
Diffstat (limited to 'input')
-rw-r--r--input/cmd_list.c2
-rw-r--r--input/cmd_parse.c7
2 files changed, 8 insertions, 1 deletions
diff --git a/input/cmd_list.c b/input/cmd_list.c
index 3640cce460..2f3bfb994a 100644
--- a/input/cmd_list.c
+++ b/input/cmd_list.c
@@ -146,7 +146,7 @@ const struct mp_cmd_def mp_cmds[] = {
{ MP_CMD_RUN, "run", { ARG_STRING, ARG_STRING }, .vararg = true },
{ MP_CMD_SET, "set", { ARG_STRING, ARG_STRING } },
- { MP_CMD_ADD, "add", { ARG_STRING, OARG_DOUBLE(0) },
+ { MP_CMD_ADD, "add", { ARG_STRING, OARG_DOUBLE(1) },
.allow_auto_repeat = true},
{ MP_CMD_CYCLE, "cycle", {
ARG_STRING,
diff --git a/input/cmd_parse.c b/input/cmd_parse.c
index 206bd4171f..ba35cd5e1c 100644
--- a/input/cmd_parse.c
+++ b/input/cmd_parse.c
@@ -471,8 +471,15 @@ static int parse_cycle_dir(struct mp_log *log, const struct m_option *opt,
return 1;
}
+static void copy_opt(const m_option_t *opt, void *dst, const void *src)
+{
+ if (dst && src)
+ memcpy(dst, src, opt->type->size);
+}
+
const struct m_option_type m_option_type_cycle_dir = {
.name = "up|down",
.parse = parse_cycle_dir,
+ .copy = copy_opt,
.size = sizeof(double),
};