diff options
author | Andrey Kleshchev <andreykproductengine@lindenlab.com> | 2022-08-15 20:10:17 +0300 |
---|---|---|
committer | Andrey Kleshchev <andreykproductengine@lindenlab.com> | 2022-08-16 00:09:50 +0300 |
commit | aa5c4d45aa36df1c4dad7b68b4e1b760420409ad (patch) | |
tree | 5cce4e30a249ab6777cff56092677fed2bcfadf5 /indra/llwindow | |
parent | ff895e96b249171644aa3fc352128fedd944248a (diff) |
SL-17719 Windows support for absolute mouse positioning #2
Better touch screen handling
Diffstat (limited to 'indra/llwindow')
-rw-r--r-- | indra/llwindow/llwindowwin32.cpp | 35 |
1 files changed, 23 insertions, 12 deletions
diff --git a/indra/llwindow/llwindowwin32.cpp b/indra/llwindow/llwindowwin32.cpp index f2dd46fee7..6d5b42f2f1 100644 --- a/indra/llwindow/llwindowwin32.cpp +++ b/indra/llwindow/llwindowwin32.cpp @@ -3062,23 +3062,34 @@ LRESULT CALLBACK LLWindowWin32::mainWindowProc(HWND h_wnd, UINT u_msg, WPARAM w_ if (absolute_coordinates) { - bool v_desktop = (raw->data.mouse.usFlags & MOUSE_VIRTUAL_DESKTOP) == MOUSE_VIRTUAL_DESKTOP; + static S32 prev_absolute_x = 0; + static S32 prev_absolute_y = 0; + S32 absolute_x; + S32 absolute_y; + + if ((raw->data.mouse.usFlags & 0x10) == 0x10) // touch screen? touch? Not defined in header + { + // touch screen spams (0,0) coordinates in a number of situations + // (0,0) might need to be filtered + absolute_x = raw->data.mouse.lLastX; + absolute_y = raw->data.mouse.lLastY; + } + else + { + bool v_desktop = (raw->data.mouse.usFlags & MOUSE_VIRTUAL_DESKTOP) == MOUSE_VIRTUAL_DESKTOP; - S32 width = GetSystemMetrics(v_desktop ? SM_CXVIRTUALSCREEN : SM_CXSCREEN); - S32 height = GetSystemMetrics(v_desktop ? SM_CYVIRTUALSCREEN : SM_CYSCREEN); + S32 width = GetSystemMetrics(v_desktop ? SM_CXVIRTUALSCREEN : SM_CXSCREEN); + S32 height = GetSystemMetrics(v_desktop ? SM_CYVIRTUALSCREEN : SM_CYSCREEN); - S32 absolute_x = (raw->data.mouse.lLastX / 65535.0f) * width; - S32 absolute_y = (raw->data.mouse.lLastY / 65535.0f) * height; + absolute_x = (raw->data.mouse.lLastX / 65535.0f) * width; + absolute_y = (raw->data.mouse.lLastY / 65535.0f) * height; + } + + window_imp->mRawMouseDelta.mX += absolute_x - prev_absolute_x; + window_imp->mRawMouseDelta.mY -= absolute_y - prev_absolute_y; - static S32 prev_absolute_x = 0; - static S32 prev_absolute_y = 0; - S32 delta_x = absolute_x - prev_absolute_x; - S32 delta_y = absolute_y - prev_absolute_y; prev_absolute_x = absolute_x; prev_absolute_y = absolute_y; - - window_imp->mRawMouseDelta.mX += delta_x; - window_imp->mRawMouseDelta.mY -= delta_y; } else { |