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.
This commit is contained in:
nanahi 2024-10-13 14:23:59 -04:00 committed by Kacper Michajłow
parent 228f38606b
commit da0160b0ee
3 changed files with 10 additions and 1 deletions

View File

@ -1832,6 +1832,13 @@ prefixes can be specified. They are separated by whitespace.
``nonrepeatable`` ``nonrepeatable``
For some commands, keeping a key pressed runs the command repeatedly. For some commands, keeping a key pressed runs the command repeatedly.
This prefix forces disabling key repeat in any case. 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`` ``async``
Allow asynchronous execution (if possible). Note that only a few commands Allow asynchronous execution (if possible). Note that only a few commands
will support this (usually this is explicitly documented). Some commands will support this (usually this is explicitly documented). Some commands

View File

@ -53,6 +53,7 @@ static const struct flag cmd_flags[] = {
{"raw", MP_EXPAND_PROPERTIES, 0}, {"raw", MP_EXPAND_PROPERTIES, 0},
{"repeatable", MP_DISALLOW_REPEAT, MP_ALLOW_REPEAT}, {"repeatable", MP_DISALLOW_REPEAT, MP_ALLOW_REPEAT},
{"nonrepeatable", MP_ALLOW_REPEAT, MP_DISALLOW_REPEAT}, {"nonrepeatable", MP_ALLOW_REPEAT, MP_DISALLOW_REPEAT},
{"nonscalable", 0, MP_DISALLOW_SCALE},
{"async", MP_SYNC_CMD, MP_ASYNC_CMD}, {"async", MP_SYNC_CMD, MP_ASYNC_CMD},
{"sync", MP_ASYNC_CMD, MP_SYNC_CMD}, {"sync", MP_ASYNC_CMD, MP_SYNC_CMD},
{0} {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) 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) void mp_print_cmd_list(struct mp_log *out)

View File

@ -76,6 +76,7 @@ enum mp_cmd_flags {
MP_SYNC_CMD = 64, // block on command completion MP_SYNC_CMD = 64, // block on command completion
MP_DISALLOW_REPEAT = 128, // if used as keybinding, disallow key repeat 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_FLAGS = MP_ON_OSD_NO | MP_ON_OSD_AUTO |
MP_ON_OSD_BAR | MP_ON_OSD_MSG, MP_ON_OSD_BAR | MP_ON_OSD_MSG,