summaryrefslogtreecommitdiffstats
path: root/input
diff options
context:
space:
mode:
authorJames Ross-Gowan <rossymiles@gmail.com>2017-04-24 22:04:25 +1000
committerJames Ross-Gowan <rossymiles@gmail.com>2017-05-12 22:58:58 +1000
commit6ccb7b5fa520497461b282cf6a32dfac276f43d7 (patch)
tree3211782a794a3817f4fd10f5da732475f6b556ea /input
parentcc6922cf060e2ea619914a2ac3aa679760368bbf (diff)
downloadmpv-6ccb7b5fa520497461b282cf6a32dfac276f43d7.tar.bz2
mpv-6ccb7b5fa520497461b282cf6a32dfac276f43d7.tar.xz
command: mark some commands as "scalable"
Scalable commands (seek, cycle and add) understand the cmd->scale parameter and will "scale" their action accordingly, for example, a seek with scale = 0.5 will only seek half the specified amount and a seek with scale = 2.0 will seek twice as much. Mark these commands so in the next commit, input.c will be able to synthesize input with cmd->scale = 1 for non-scalable commands.
Diffstat (limited to 'input')
-rw-r--r--input/cmd_list.c13
-rw-r--r--input/cmd_list.h3
2 files changed, 14 insertions, 2 deletions
diff --git a/input/cmd_list.c b/input/cmd_list.c
index 33cf40f233..07dd924cbf 100644
--- a/input/cmd_list.c
+++ b/input/cmd_list.c
@@ -72,6 +72,7 @@ const struct mp_cmd_def mp_cmds[] = {
{"exact", 32|16})),
},
.allow_auto_repeat = true,
+ .scalable = true,
},
{ MP_CMD_REVERT_SEEK, "revert-seek", {
OARG_FLAGS(0, ({"mark", 1})),
@@ -148,12 +149,15 @@ const struct mp_cmd_def mp_cmds[] = {
{ MP_CMD_SET, "set", { ARG_STRING, ARG_STRING } },
{ MP_CMD_ADD, "add", { ARG_STRING, OARG_DOUBLE(1) },
- .allow_auto_repeat = true},
+ .allow_auto_repeat = true,
+ .scalable = true,
+ },
{ MP_CMD_CYCLE, "cycle", {
ARG_STRING,
OARG_CYCLEDIR(1),
},
- .allow_auto_repeat = true
+ .allow_auto_repeat = true,
+ .scalable = true,
},
{ MP_CMD_MULTIPLY, "multiply", { ARG_STRING, ARG_DOUBLE },
.allow_auto_repeat = true},
@@ -348,6 +352,11 @@ bool mp_input_is_repeatable_cmd(struct mp_cmd *cmd)
(cmd->flags & MP_ALLOW_REPEAT);
}
+bool mp_input_is_scalable_cmd(struct mp_cmd *cmd)
+{
+ return cmd->def && cmd->def->scalable;
+}
+
void mp_print_cmd_list(struct mp_log *out)
{
for (int i = 0; mp_cmds[i].name; i++) {
diff --git a/input/cmd_list.h b/input/cmd_list.h
index 404df462f4..cf881af2bb 100644
--- a/input/cmd_list.h
+++ b/input/cmd_list.h
@@ -32,6 +32,7 @@ struct mp_cmd_def {
bool allow_auto_repeat; // react to repeated key events
bool on_updown; // always emit it on both up and down key events
bool vararg; // last argument can be given 0 to multiple times
+ bool scalable;
};
extern const struct mp_cmd_def mp_cmds[];
@@ -131,6 +132,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_scalable_cmd(struct mp_cmd *cmd);
+
struct bstr;
bool mp_replace_legacy_cmd(void *talloc_ctx, struct bstr *s);