From 690dc201ad07aae68b42fd368384990a18ddd86f Mon Sep 17 00:00:00 2001 From: nanahi <130121847+na-na-hi@users.noreply.github.com> Date: Mon, 12 Feb 2024 03:11:02 -0500 Subject: [PATCH] input: add --input-preprocess-wheel option This adds --input-preprocess-wheel option, which can be used to control whether to preprocess received wheel events. Commit 937128697fbbef6b21e2d23a4785f1334f62b9e3 added preprocessing of wheel events to prevent the accidental scrolling of another direction when one direction is being scrolled for touchpads, which is problematic with the default wheel bindings where unrelated functions (seeking and volume) are used for the 2 directions. However, this behavior is undesirable in the following situations: - When custom wheel bindings are used so that the 2 directions are used for closely related actions, such as panning. With preprocessing, diagonal movement is impossible. - Since the wheel deadzone was introduced to prevent accidental scrolling for touchpads, this filtering provides no benefit for high resolution unidirectional mouse wheels, while causing a regression where scrolling at least 0.125 units is required to trigger the event, causing input delay. By adding this option, these two use cases are addressed. --- input/input.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/input/input.c b/input/input.c index c09eccf193..cb58c9ba83 100644 --- a/input/input.c +++ b/input/input.c @@ -179,6 +179,7 @@ struct input_opts { bool vo_key_input; bool test; bool allow_win_drag; + bool preprocess_wheel; }; const struct m_sub_options input_config = { @@ -198,6 +199,7 @@ const struct m_sub_options input_config = { {"input-cursor", OPT_BOOL(enable_mouse_movements)}, {"input-vo-keyboard", OPT_BOOL(vo_key_input)}, {"input-media-keys", OPT_BOOL(use_media_keys)}, + {"input-preprocess-wheel", OPT_BOOL(preprocess_wheel)}, #if HAVE_SDL2_GAMEPAD {"input-gamepad", OPT_BOOL(use_gamepad)}, #endif @@ -217,6 +219,7 @@ const struct m_sub_options input_config = { .builtin_bindings = true, .vo_key_input = true, .allow_win_drag = true, + .preprocess_wheel = true, }, .change_flags = UPDATE_INPUT, }; @@ -731,7 +734,7 @@ static void mp_input_feed_key(struct input_ctx *ictx, int code, double scale, if (!force_mouse && opts->doubleclick_time && MP_KEY_IS_MOUSE_BTN_DBL(unmod)) return; int units = 1; - if (MP_KEY_IS_WHEEL(unmod) && !process_wheel(ictx, unmod, &scale, &units)) + if (MP_KEY_IS_WHEEL(unmod) && opts->preprocess_wheel && !process_wheel(ictx, unmod, &scale, &units)) return; interpret_key(ictx, code, scale, units); if (code & MP_KEY_STATE_DOWN) {