1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
|
From f0859f18b398a895286105a7b6a1ba9d8b2248af Mon Sep 17 00:00:00 2001
From: Daniel Scharrer <dscharrer@gmail.com>
Date: Tue, 13 Jan 2009 18:19:26 +0100
Subject: dinput: Read raw relative mouse movements from /dev/input/mice.
---
dlls/dinput/mouse.c | 26 ++++++++++++++++++++++----
1 files changed, 22 insertions(+), 4 deletions(-)
diff --git a/dlls/dinput/mouse.c b/dlls/dinput/mouse.c
index 178b8fb..273d605 100644
--- a/dlls/dinput/mouse.c
+++ b/dlls/dinput/mouse.c
@@ -25,6 +25,8 @@
#include <stdarg.h>
#include <string.h>
+#include <fcntl.h>
+
#include "windef.h"
#include "winbase.h"
#include "wingdi.h"
@@ -76,6 +78,8 @@ struct SysMouseImpl
DIMOUSESTATE2 m_state;
WARP_MOUSE warp_override;
+
+ int mouse;
};
static void dinput_mouse_hook( LPDIRECTINPUTDEVICE8A iface, WPARAM wparam, LPARAM lparam );
@@ -198,6 +202,11 @@ static SysMouseImpl *alloc_device(REFGUID rguid, const void *mvt, IDirectInputIm
newDevice->base.dinput = dinput;
newDevice->base.event_proc = dinput_mouse_hook;
+ newDevice->mouse = open("/dev/input/mice", O_RDONLY);
+
+ if(newDevice->mouse < 0)
+ WARN("unable to open /dev/input/mice for reading");
+
get_app_key(&hkey, &appkey);
if (!get_config_key(hkey, appkey, "MouseWarpOverride", buffer, sizeof(buffer)))
{
@@ -303,9 +312,17 @@ static void dinput_mouse_hook( LPDIRECTINPUTDEVICE8A iface, WPARAM wparam, LPARA
{
POINT pt, pt1;
- GetCursorPos(&pt);
- This->m_state.lX += pt.x = hook->pt.x - pt.x;
- This->m_state.lY += pt.y = hook->pt.y - pt.y;
+ if(This->mouse >= 0)
+ {
+ char input[3] = {0,0,0};
+ read(This->mouse, input, 3);
+ This->m_state.lX += pt.x = input[1];
+ This->m_state.lY += pt.y = input[2];
+ } else {
+ GetCursorPos(&pt);
+ This->m_state.lX += pt.x = hook->pt.x - pt.x;
+ This->m_state.lY += pt.y = hook->pt.y - pt.y;
+ }
if (This->base.data_format.user_df->dwFlags & DIDF_ABSAXIS)
{
@@ -331,7 +348,8 @@ static void dinput_mouse_hook( LPDIRECTINPUTDEVICE8A iface, WPARAM wparam, LPARA
This->need_warp = This->warp_override != WARP_DISABLE &&
(pt.x || pt.y) &&
- (dwCoop & DISCL_EXCLUSIVE || This->warp_override == WARP_FORCE_ON);
+ (dwCoop & DISCL_EXCLUSIVE || This->warp_override == WARP_FORCE_ON) &&
+ This->mouse < 0;
break;
}
case WM_MOUSEWHEEL:
--
1.6.0.6
|