summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorStanislaw Halik <sthalik@misaki.pl>2015-05-22 07:52:24 +0200
committerStanislaw Halik <sthalik@misaki.pl>2015-05-22 07:52:24 +0200
commit9a2538d46b90d10b5a902b128a74a15142efd758 (patch)
tree89a0351fa27cebdadacb7bf432f6cb3497ac641e
parent45f332f61e687a01129d482c57c880ec7c2f7cac (diff)
mouse: use different API to make it work in gamesopentrack-2.3-rc11
-rw-r--r--ftnoir_protocol_mouse/ftnoir_protocol_mouse.cpp30
1 files changed, 20 insertions, 10 deletions
diff --git a/ftnoir_protocol_mouse/ftnoir_protocol_mouse.cpp b/ftnoir_protocol_mouse/ftnoir_protocol_mouse.cpp
index e26f6cbf..ebf1ad19 100644
--- a/ftnoir_protocol_mouse/ftnoir_protocol_mouse.cpp
+++ b/ftnoir_protocol_mouse/ftnoir_protocol_mouse.cpp
@@ -29,6 +29,10 @@
#include "ftnoir_protocol_mouse.h"
#include "opentrack/plugin-api.hpp"
+#ifndef MOUSEEVENTF_MOVE_NOCOALESCE
+# define MOUSEEVENTF_MOVE_NOCOALESCE 0x2000
+#endif
+
void FTNoIR_Protocol::pose(const double *headpose ) {
RECT desktop;
const HWND hDesktop = GetDesktopWindow();
@@ -38,22 +42,28 @@ void FTNoIR_Protocol::pose(const double *headpose ) {
int axis_x = s.Mouse_X;
int axis_y = s.Mouse_Y;
- int mouse_x, mouse_y;
+ int mouse_x = 0, mouse_y = 0;
if (axis_x > 0 && axis_x <= 6)
- mouse_x = headpose[axis_x-1] / (axis_x < 3 ? 100 : 180) * 10 * desktop.right/2;
+ mouse_x = headpose[axis_x-1] / (axis_x <= 3 ? 100 : 180) * 10 * desktop.right/2;
if (axis_y > 0 && axis_y <= 6)
- mouse_y = headpose[axis_y-1] / (axis_y < 3 ? 100 : 180) * 10 * desktop.bottom/2;
+ mouse_y = headpose[axis_y-1] / (axis_y <= 3 ? 100 : 180) * 10 * desktop.bottom/2;
- POINT pt;
+ MOUSEINPUT mi;
+ mi.dx = mouse_x - last_x;
+ mi.dy = mouse_y - last_y;
+ mi.mouseData = 0;
+ mi.dwFlags = MOUSEEVENTF_MOVE | MOUSEEVENTF_MOVE_NOCOALESCE;
+ mi.time = 0;
+ mi.dwExtraInfo = 0;
+ INPUT input;
+ input.type = INPUT_MOUSE;
+ input.mi = mi;
+ (void) SendInput(1, &input, sizeof(INPUT));
- if (GetCursorPos(&pt))
- {
- SetCursorPos(pt.x + mouse_x - last_x, pt.y + mouse_y - last_y);
- last_x = mouse_x;
- last_y = mouse_y;
- }
+ last_x = mouse_x;
+ last_y = mouse_y;
}
}