From f0859f18b398a895286105a7b6a1ba9d8b2248af Mon Sep 17 00:00:00 2001 From: Daniel Scharrer 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 #include +#include + #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