From da0160b0eea21c670c62ad9ab7e7a13a019669b6 Mon Sep 17 00:00:00 2001 From: nanahi <130121847+na-na-hi@users.noreply.github.com> Date: Sun, 13 Oct 2024 14:23:59 -0400 Subject: [PATCH] input/cmd: add nonscalable prefix Some keys like WHEEL_UP are "scaled" if the input source is high resolution, like touchpad. However, sometimes it's desirable to disable this scaling and only active the key binding in discrete steps, such as relative keyframe seeking which interacts poorly if the command is scaled. This adds the nonscalable prefix to disable this scaling. --- DOCS/man/input.rst | 7 +++++++ input/cmd.c | 3 ++- input/cmd.h | 1 + 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/DOCS/man/input.rst b/DOCS/man/input.rst index 08a4930065..5c2fdb57d3 100644 --- a/DOCS/man/input.rst +++ b/DOCS/man/input.rst @@ -1832,6 +1832,13 @@ prefixes can be specified. They are separated by whitespace. ``nonrepeatable`` For some commands, keeping a key pressed runs the command repeatedly. This prefix forces disabling key repeat in any case. +``nonscalable`` + When some commands (e.g. ``add``) are bound to scalable keys associated to a + high-precision input device like a touchpad (e.g. ``WHEEL_UP``), the value + specified in the command is scaled to smaller steps based on the high + resolution input data if available. + This prefix forces disabling this behavior, so the value is always changed + in the discrete unit specified in the key binding. ``async`` Allow asynchronous execution (if possible). Note that only a few commands will support this (usually this is explicitly documented). Some commands diff --git a/input/cmd.c b/input/cmd.c index 45a96b4517..6a6d4e63e8 100644 --- a/input/cmd.c +++ b/input/cmd.c @@ -53,6 +53,7 @@ static const struct flag cmd_flags[] = { {"raw", MP_EXPAND_PROPERTIES, 0}, {"repeatable", MP_DISALLOW_REPEAT, MP_ALLOW_REPEAT}, {"nonrepeatable", MP_ALLOW_REPEAT, MP_DISALLOW_REPEAT}, + {"nonscalable", 0, MP_DISALLOW_SCALE}, {"async", MP_SYNC_CMD, MP_ASYNC_CMD}, {"sync", MP_ASYNC_CMD, MP_SYNC_CMD}, {0} @@ -618,7 +619,7 @@ bool mp_input_is_repeatable_cmd(struct mp_cmd *cmd) bool mp_input_is_scalable_cmd(struct mp_cmd *cmd) { - return cmd->def->scalable; + return cmd->def->scalable && !(cmd->flags & MP_DISALLOW_SCALE); } void mp_print_cmd_list(struct mp_log *out) diff --git a/input/cmd.h b/input/cmd.h index c82dd337c8..1244502c54 100644 --- a/input/cmd.h +++ b/input/cmd.h @@ -76,6 +76,7 @@ enum mp_cmd_flags { MP_SYNC_CMD = 64, // block on command completion MP_DISALLOW_REPEAT = 128, // if used as keybinding, disallow key repeat + MP_DISALLOW_SCALE = 256, // if used as keybinding, make it non-scalable MP_ON_OSD_FLAGS = MP_ON_OSD_NO | MP_ON_OSD_AUTO | MP_ON_OSD_BAR | MP_ON_OSD_MSG,