From 89aa10de245e90156e242ea28112985578741488 Mon Sep 17 00:00:00 2001 From: nanahi <130121847+na-na-hi@users.noreply.github.com> Date: Sat, 27 Apr 2024 02:39:52 -0400 Subject: [PATCH] input: add MP_TOUCH_RELEASE_ALL Release all touch points. Used by some VOs like Wayland touch cancel event. --- input/input.c | 5 +++++ input/keycodes.h | 2 ++ 2 files changed, 7 insertions(+) diff --git a/input/input.c b/input/input.c index 92e2a6d5b9..9890a0252b 100644 --- a/input/input.c +++ b/input/input.c @@ -735,6 +735,11 @@ static void feed_key(struct input_ctx *ictx, int code, double scale, release_down_cmd(ictx, false); return; } + if (code == MP_TOUCH_RELEASE_ALL) { + MP_TRACE(ictx, "release all touch\n"); + ictx->num_touch_points = 0; + return; + } if (!opts->enable_mouse_movements && MP_KEY_IS_MOUSE(unmod) && !force_mouse) return; if (unmod == MP_KEY_MOUSE_LEAVE || unmod == MP_KEY_MOUSE_ENTER) { diff --git a/input/keycodes.h b/input/keycodes.h index 1a21a3c89f..2e63df344f 100644 --- a/input/keycodes.h +++ b/input/keycodes.h @@ -216,6 +216,8 @@ #define MP_KEY_ANY_UNICODE (MP_KEY_INTERN+5) // For mp_input_put_key(): release all keys that are down. #define MP_INPUT_RELEASE_ALL (MP_KEY_INTERN+6) +// For mp_input_put_key(): release all touch points. +#define MP_TOUCH_RELEASE_ALL (MP_KEY_INTERN+7) // Emit a command even on key-up (normally key-up is ignored). This means by // default they binding will be triggered on key-up instead of key-down.