summaryrefslogtreecommitdiffstats
path: root/mpvcore/input/input.c
diff options
context:
space:
mode:
authorAlexander Preisinger <alexander.preisinger@gmail.com>2013-07-25 18:08:57 +0200
committerAlexander Preisinger <alexander.preisinger@gmail.com>2013-08-07 22:15:39 +0200
commit023e5ccd02609c8a2fdcf63ee0a87025beeb79f0 (patch)
tree4846330cd6d36a8d353f2c287fb061e0de3e05bb /mpvcore/input/input.c
parent406241005e3d897b30a5b168a16ad61f0996c43c (diff)
downloadmpv-023e5ccd02609c8a2fdcf63ee0a87025beeb79f0.tar.bz2
mpv-023e5ccd02609c8a2fdcf63ee0a87025beeb79f0.tar.xz
input: add support for precise scroll axes
Support horizontal and vertical axes of input devices. If the input device support precise scrolling with an input value then it should first be scaled to a standard multiplier, where 1.0 is the default. The multiplier will then applied to the following commands if possible: * MP_CMD_SEEK * MP_CMD_SPEED_MULT * MP_CMD_ADD All other commands will triggered on every axis event, without change the values specified in the config file.
Diffstat (limited to 'mpvcore/input/input.c')
-rw-r--r--mpvcore/input/input.c18
1 files changed, 18 insertions, 0 deletions
diff --git a/mpvcore/input/input.c b/mpvcore/input/input.c
index 935ed62f8e..f900b74357 100644
--- a/mpvcore/input/input.c
+++ b/mpvcore/input/input.c
@@ -424,6 +424,11 @@ static const struct key_name key_names[] = {
{ MP_MK_PREV, "MK_PREV" },
{ MP_MK_NEXT, "MK_NEXT" },
+ { MP_AXIS_UP, "AXIS_UP" },
+ { MP_AXIS_DOWN, "AXIS_DOWN" },
+ { MP_AXIS_LEFT, "AXIS_LEFT" },
+ { MP_AXIS_RIGHT, "AXIS_RIGHT" },
+
{ MP_KEY_POWER, "POWER" },
{ MP_KEY_MENU, "MENU" },
{ MP_KEY_PLAY, "PLAY" },
@@ -910,6 +915,7 @@ static int parse_cmd(struct mp_cmd **dest, bstr str, const char *loc)
cmd = talloc_ptrtype(NULL, cmd);
*cmd = mp_cmds[cmd_idx];
+ cmd->scale = 1;
cmd->pausing = pausing;
cmd->on_osd = on_osd;
cmd->raw_args = raw_args;
@@ -1517,6 +1523,18 @@ void mp_input_put_key_utf8(struct input_ctx *ictx, int mods, struct bstr t)
}
}
+void mp_input_put_axis(struct input_ctx *ictx, int direction, double value)
+{
+ struct mp_cmd *cmd = interpret_key(ictx, direction);
+ if (!cmd)
+ return;
+
+ cmd->scale = value;
+
+ ictx->got_new_events = true;
+ add_key_cmd(ictx, cmd);
+}
+
static void trigger_mouse_leave(struct input_ctx *ictx, char *new_section)
{
if (!new_section)