summaryrefslogtreecommitdiffstats
path: root/mpvcore/input
diff options
context:
space:
mode:
Diffstat (limited to 'mpvcore/input')
-rw-r--r--mpvcore/input/input.c18
-rw-r--r--mpvcore/input/input.h5
-rw-r--r--mpvcore/input/keycodes.h7
3 files changed, 30 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)
diff --git a/mpvcore/input/input.h b/mpvcore/input/input.h
index 2c8441c7c0..022ebb3881 100644
--- a/mpvcore/input/input.h
+++ b/mpvcore/input/input.h
@@ -146,6 +146,7 @@ typedef struct mp_cmd {
bool mouse_move;
int mouse_x, mouse_y;
struct mp_cmd *queue_next;
+ double scale; // for scaling numeric arguments
} mp_cmd_t;
@@ -181,6 +182,10 @@ void mp_input_put_key(struct input_ctx *ictx, int code);
// string as key events.
void mp_input_put_key_utf8(struct input_ctx *ictx, int mods, struct bstr t);
+// Process scrolling input. Support for precise scrolling. Scales the given
+// scroll amount add multiplies it with the command (seeking, sub-delay, etc)
+void mp_input_put_axis(struct input_ctx *ictx, int direction, double value);
+
// Update mouse position (in window coordinates).
void mp_input_set_mouse_pos(struct input_ctx *ictx, int x, int y);
diff --git a/mpvcore/input/keycodes.h b/mpvcore/input/keycodes.h
index d91465f3be..cfc011f40a 100644
--- a/mpvcore/input/keycodes.h
+++ b/mpvcore/input/keycodes.h
@@ -201,6 +201,13 @@
#define MP_MK_PREV (MP_MK_BASE + 1)
#define MP_MK_NEXT (MP_MK_BASE + 2)
+// Mouse wheels or touchpad input
+#define MP_AXIS_BASE (MP_KEY_BASE+0x100)
+#define MP_AXIS_UP (MP_AXIS_BASE+0)
+#define MP_AXIS_DOWN (MP_AXIS_BASE+1)
+#define MP_AXIS_LEFT (MP_AXIS_BASE+2)
+#define MP_AXIS_RIGHT (MP_AXIS_BASE+3)
+
/* Special keys */
#define MP_KEY_INTERN (MP_KEY_BASE+0x1000)
#define MP_KEY_CLOSE_WIN (MP_KEY_INTERN+0)