summaryrefslogtreecommitdiff
path: root/platform/windows
diff options
context:
space:
mode:
authorJuan Linietsky <reduzio@gmail.com>2018-08-22 21:27:15 -0300
committerJuan Linietsky <reduzio@gmail.com>2018-08-22 21:27:15 -0300
commit2db494267b2924989900e968bdb898d8ab50c8f5 (patch)
treecda94f26970c69f5fa62dc85a2addd3b2c02f479 /platform/windows
parent106e5a8d5ea601f5a37b280e2c1ef61c0e0a2cfb (diff)
Modifications to raw input so the handling of absolute coordinates is more correct.
Diffstat (limited to 'platform/windows')
-rw-r--r--platform/windows/os_windows.cpp32
-rw-r--r--platform/windows/os_windows.h1
2 files changed, 28 insertions, 5 deletions
diff --git a/platform/windows/os_windows.cpp b/platform/windows/os_windows.cpp
index 845628333b..56ac467dc6 100644
--- a/platform/windows/os_windows.cpp
+++ b/platform/windows/os_windows.cpp
@@ -449,12 +449,36 @@ LRESULT OS_Windows::WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
input->set_mouse_position(c);
mm->set_speed(Vector2(0, 0));
- if (raw->data.mouse.usFlags == 0) {
+ if (raw->data.mouse.usFlags ==MOUSE_MOVE_RELATIVE) {
mm->set_relative(Vector2(raw->data.mouse.lLastX, raw->data.mouse.lLastY));
- } else if (raw->data.mouse.usFlags == 1) {
- mm->set_relative(Vector2(raw->data.mouse.lLastX, raw->data.mouse.lLastY) - last_absolute_position);
- last_absolute_position = Vector2(raw->data.mouse.lLastX, raw->data.mouse.lLastY);
+ } else if (raw->data.mouse.usFlags == MOUSE_MOVE_ABSOLUTE) {
+
+ int nScreenWidth = GetSystemMetrics(SM_CXVIRTUALSCREEN);
+ int nScreenHeight = GetSystemMetrics(SM_CYVIRTUALSCREEN);
+ int nScreenLeft = GetSystemMetrics(SM_XVIRTUALSCREEN);
+ int nScreenTop = GetSystemMetrics(SM_YVIRTUALSCREEN);
+
+ Vector2 abs_pos(
+ (double(raw->data.mouse.lLastX) - 65536.0 / (nScreenWidth) ) * nScreenWidth / 65536.0 + nScreenLeft,
+ (double(raw->data.mouse.lLastY) - 65536.0 / (nScreenHeight) ) * nScreenHeight / 65536.0 + nScreenTop
+ );
+
+ POINT coords; //client coords
+ coords.x = abs_pos.x;
+ coords.y = abs_pos.y;
+
+ ScreenToClient(hWnd, &coords);
+
+
+ mm->set_relative(Vector2(coords.x - old_x, coords.y - old_y ));
+ old_x = coords.x;
+ old_y = coords.y;
+
+ /*Input.mi.dx = (int)((((double)(pos.x)-nScreenLeft) * 65536) / nScreenWidth + 65536 / (nScreenWidth));
+ Input.mi.dy = (int)((((double)(pos.y)-nScreenTop) * 65536) / nScreenHeight + 65536 / (nScreenHeight));
+ */
+
}
if (window_has_focus && main_loop)
diff --git a/platform/windows/os_windows.h b/platform/windows/os_windows.h
index e8dd07d650..243d4bb328 100644
--- a/platform/windows/os_windows.h
+++ b/platform/windows/os_windows.h
@@ -125,7 +125,6 @@ class OS_Windows : public OS {
bool force_quit;
bool window_has_focus;
uint32_t last_button_state;
- Vector2 last_absolute_position;
bool use_raw_input;
HCURSOR cursors[CURSOR_MAX] = { NULL };