summaryrefslogtreecommitdiffstats
path: root/input/cmd_parse.c
diff options
context:
space:
mode:
authorJames Ross-Gowan <rossymiles@gmail.com>2017-04-25 18:03:06 +1000
committerJames Ross-Gowan <rossymiles@gmail.com>2017-05-12 22:58:58 +1000
commit89fd3e1d9d25731c6cae8af1b9c5b0bae726c436 (patch)
tree84bd2fbe5b7af1c7245f4387464fd947474b149c /input/cmd_parse.c
parent937128697fbbef6b21e2d23a4785f1334f62b9e3 (diff)
downloadmpv-89fd3e1d9d25731c6cae8af1b9c5b0bae726c436.tar.bz2
mpv-89fd3e1d9d25731c6cae8af1b9c5b0bae726c436.tar.xz
command: use scale_units to add/cycle integer properties
This adds check_property_scalable, which returns true if the property is backed by a floating-point number. When the add or cycle commands operate on these properties, they can benefit from the fractional scale value in cmd->scale. When the property is not backed by a floating-point number, cmd->scale_units is used instead, so for axis events, the property is only incrmented when the user scrolls one full unit. This solution isn't perfect, because in some cases integer-backed properties could benefit from accurate scrolling. For example, if an axis is bound to "cycle audio 5", the cycle command could be made to change the audio track by one when the user scrolls 1/5th of a unit, though this behaviour would require more changes to the options system.
Diffstat (limited to 'input/cmd_parse.c')
-rw-r--r--input/cmd_parse.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/input/cmd_parse.c b/input/cmd_parse.c
index b0c6c50753..0af9665cf0 100644
--- a/input/cmd_parse.c
+++ b/input/cmd_parse.c
@@ -140,7 +140,7 @@ struct mp_cmd *mp_input_parse_cmd_node(struct mp_log *log, mpv_node *node)
{
struct mp_cmd *cmd = talloc_ptrtype(NULL, cmd);
talloc_set_destructor(cmd, destroy_cmd);
- *cmd = (struct mp_cmd) { .scale = 1, };
+ *cmd = (struct mp_cmd) { .scale = 1, .scale_units = 1 };
if (node->format != MPV_FORMAT_NODE_ARRAY)
goto error;
@@ -254,6 +254,7 @@ static struct mp_cmd *parse_cmd_str(struct mp_log *log, void *tmp,
*cmd = (struct mp_cmd) {
.flags = MP_ON_OSD_AUTO | MP_EXPAND_PROPERTIES,
.scale = 1,
+ .scale_units = 1,
};
ctx->str = bstr_lstrip(ctx->str);