summaryrefslogtreecommitdiffhomepage
path: root/proto-mouse/ftnoir_protocol_mouse.cpp
diff options
context:
space:
mode:
authorStanislaw Halik <sthalik@misaki.pl>2019-01-16 06:21:48 +0100
committerStanislaw Halik <sthalik@misaki.pl>2019-01-16 07:49:13 +0100
commitbdbab6bbfef596011302b595cab9b09aec147c55 (patch)
tree05696f23bad81498bf131f9fe5a93d0ef6bc5809 /proto-mouse/ftnoir_protocol_mouse.cpp
parentb8ea949f768e47624d938d73a5de58b230d59f71 (diff)
proto/mouse: add legacy input method
Diffstat (limited to 'proto-mouse/ftnoir_protocol_mouse.cpp')
-rw-r--r--proto-mouse/ftnoir_protocol_mouse.cpp49
1 files changed, 33 insertions, 16 deletions
diff --git a/proto-mouse/ftnoir_protocol_mouse.cpp b/proto-mouse/ftnoir_protocol_mouse.cpp
index 60c04cbe..2b3af2f0 100644
--- a/proto-mouse/ftnoir_protocol_mouse.cpp
+++ b/proto-mouse/ftnoir_protocol_mouse.cpp
@@ -9,14 +9,11 @@
#include "api/plugin-api.hpp"
#include "compat/math.hpp"
+
#include <cmath>
#include <algorithm>
#include <windows.h>
-#ifndef MOUSEEVENTF_MOVE_NOCOALESCE
-# define MOUSEEVENTF_MOVE_NOCOALESCE 0x2000
-#endif
-
static const double invert[] = {
1., 1., 1.,
1., -1., 1.
@@ -24,8 +21,8 @@ static const double invert[] = {
void mouse::pose(const double* headpose)
{
- const int axis_x = s.Mouse_X - 1;
- const int axis_y = s.Mouse_Y - 1;
+ const int axis_x = s.mouse_x - 1;
+ const int axis_y = s.mouse_y - 1;
int mouse_x = 0, mouse_y = 0;
@@ -42,18 +39,38 @@ void mouse::pose(const double* headpose)
const int dx = get_delta(mouse_x, last_x),
dy = get_delta(mouse_y, last_y);
+ last_x = mouse_x; last_y = mouse_y;
+
if (dx || dy)
{
- INPUT input;
- input.type = INPUT_MOUSE;
- MOUSEINPUT& mi = input.mi;
- mi = {};
- mi.dx = dx;
- mi.dy = dy;
- mi.dwFlags = MOUSEEVENTF_MOVE | MOUSEEVENTF_MOVE_NOCOALESCE;
-
- (void)SendInput(1, &input, sizeof(input));
- last_x = mouse_x; last_y = mouse_y;
+ switch (s.input_method)
+ {
+ default:
+ eval_once(qDebug() << "proto/mouse: invalid input method");
+ [[fallthrough]];
+ case input_direct:
+ {
+ INPUT input;
+ input.type = INPUT_MOUSE;
+ MOUSEINPUT& mi = input.mi;
+ mi = {};
+ mi.dx = dx;
+ mi.dy = dy;
+ mi.dwFlags = MOUSEEVENTF_MOVE;
+
+ (void)SendInput(1, &input, sizeof(input));
+
+ break;
+ }
+ case input_legacy:
+ {
+ POINT pt{};
+ (void)GetCursorPos(&pt);
+ (void)SetCursorPos(pt.x + dx, pt.y + dy);
+
+ break;
+ }
+ }
}
}