diff options
| author | Andre Weissflog <floooh@gmail.com> | 2023-03-18 12:32:15 +0100 |
|---|---|---|
| committer | Andre Weissflog <floooh@gmail.com> | 2023-03-18 12:32:15 +0100 |
| commit | 06e31ae377ccdfd613b1a00665cbe4d0c13fc5aa (patch) | |
| tree | 1f1812606af9b88b28bb42e3220477c6f5e38f6b | |
| parent | 3ebd63e8d13e3d5d4809b5f3b91d31933ba37d5e (diff) | |
sokol_app.h win32: semi-fix for absolute position raw mouse input (fixes #806)
NOTE that this code is still untested and most likely is still
broken when a mouse actually sends raw input data with
absolute mouse positions (apparantly this is the case in
remote desktop sessions - see the links to GLFW issue and
DXTK commit for more info).
| -rw-r--r-- | sokol_app.h | 17 |
1 files changed, 9 insertions, 8 deletions
diff --git a/sokol_app.h b/sokol_app.h index 64e90bc3..b19c501e 100644 --- a/sokol_app.h +++ b/sokol_app.h @@ -7223,19 +7223,20 @@ _SOKOL_PRIVATE LRESULT CALLBACK _sapp_win32_wndproc(HWND hWnd, UINT uMsg, WPARAM const RAWINPUT* raw_mouse_data = (const RAWINPUT*) &_sapp.win32.raw_input_data; if (raw_mouse_data->data.mouse.usFlags & MOUSE_MOVE_ABSOLUTE) { /* mouse only reports absolute position - NOTE: THIS IS UNTESTED, it's unclear from reading the - Win32 RawInput docs under which circumstances absolute - positions are sent. + NOTE: This code is untested and will most likely behave wrong in Remote Desktop sessions. + (such remote desktop sessions are setting the MOUSE_MOVE_ABSOLUTE flag). + See: https://github.com/floooh/sokol/issues/806 and + https://github.com/microsoft/DirectXTK/commit/ef56b63f3739381e451f7a5a5bd2c9779d2a7555) */ + LONG new_x = raw_mouse_data->data.mouse.lLastX; + LONG new_y = raw_mouse_data->data.mouse.lLastY; if (_sapp.win32.raw_input_mousepos_valid) { - LONG new_x = raw_mouse_data->data.mouse.lLastX; - LONG new_y = raw_mouse_data->data.mouse.lLastY; _sapp.mouse.dx = (float) (new_x - _sapp.win32.raw_input_mousepos_x); _sapp.mouse.dy = (float) (new_y - _sapp.win32.raw_input_mousepos_y); - _sapp.win32.raw_input_mousepos_x = new_x; - _sapp.win32.raw_input_mousepos_y = new_y; - _sapp.win32.raw_input_mousepos_valid = true; } + _sapp.win32.raw_input_mousepos_x = new_x; + _sapp.win32.raw_input_mousepos_y = new_y; + _sapp.win32.raw_input_mousepos_valid = true; } else { /* mouse reports movement delta (this seems to be the common case) */ |