summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJames Ross-Gowan <rossymiles@gmail.com>2017-04-25 22:58:18 +1000
committerJames Ross-Gowan <rossymiles@gmail.com>2017-05-12 22:58:58 +1000
commit18a45a42d524fe5377265485754d6413a8d14799 (patch)
tree6c20af13d1e0346da720ccad9122ae280b3ebd9d
parent89fd3e1d9d25731c6cae8af1b9c5b0bae726c436 (diff)
downloadmpv-18a45a42d524fe5377265485754d6413a8d14799.tar.bz2
mpv-18a45a42d524fe5377265485754d6413a8d14799.tar.xz
w32_common: generate MP_AXIS_* keycodes for scrolling
Windows doesn't have a way to distinguish "precise" mouse wheel events and events from regular notched mouse wheels. A notched wheel should always send events with a delta of 120, but a precise wheel could also happen to send 120 if multiple scroll events are coalesced (and to make things even harder, some buggy Microsoft drivers send deltas less than 120, even for notched wheels.) Since there is no distinction, but MP_AXIS_* keycodes can hold more information (the delta value,) send MP_AXIS_* events for both kinds of mouse wheel scrolling.
-rw-r--r--video/out/w32_common.c26
1 files changed, 18 insertions, 8 deletions
diff --git a/video/out/w32_common.c b/video/out/w32_common.c
index 6b90a0806d..113f27409a 100644
--- a/video/out/w32_common.c
+++ b/video/out/w32_common.c
@@ -428,6 +428,16 @@ static void handle_mouse_up(struct vo_w32_state *w32, int btn)
ReleaseCapture();
}
+static void handle_mouse_wheel(struct vo_w32_state *w32, bool horiz, int val)
+{
+ int code;
+ if (horiz)
+ code = val > 0 ? MP_AXIS_RIGHT : MP_AXIS_LEFT;
+ else
+ code = val > 0 ? MP_AXIS_UP : MP_AXIS_DOWN;
+ mp_input_put_axis(w32->input_ctx, code | mod_state(w32), abs(val) / 120.);
+}
+
static void signal_events(struct vo_w32_state *w32, int events)
{
atomic_fetch_or(&w32->event_flags, events);
@@ -1077,14 +1087,14 @@ static LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam,
case WM_RBUTTONUP:
handle_mouse_up(w32, MP_MOUSE_BTN2);
break;
- case WM_MOUSEWHEEL: {
- int x = GET_WHEEL_DELTA_WPARAM(wParam);
- mp_input_put_key(w32->input_ctx,
- (x > 0 ? MP_MOUSE_BTN3 : MP_MOUSE_BTN4) |
- mod_state(w32));
- ReleaseCapture();
- break;
- }
+ case WM_MOUSEWHEEL:
+ handle_mouse_wheel(w32, false, GET_WHEEL_DELTA_WPARAM(wParam));
+ return 0;
+ case WM_MOUSEHWHEEL:
+ handle_mouse_wheel(w32, true, GET_WHEEL_DELTA_WPARAM(wParam));
+ // Some buggy mouse drivers (SetPoint) stop delivering WM_MOUSEHWHEEL
+ // events when the message loop doesn't return TRUE (even on Windows 7)
+ return TRUE;
case WM_XBUTTONDOWN:
handle_mouse_down(w32,
HIWORD(wParam) == 1 ? MP_MOUSE_BTN5 : MP_MOUSE_BTN6,