dlls/dinput/mouse.c warp handling
James Dean Anderson
petr at pantek.org
Wed Jun 16 13:29:45 CDT 2004
hello
this is a more complete version of my mouse patch in which I tried to
remove this funny mouse-warping-stuff.
the mouse feels much better this way, but I am new to wine and maybe I
missed something important and/or did not remove the mousewarping cleanly.
jda
-------------- next part --------------
? programs/winetest/gui.res
? programs/winetest/winetest.rc
Index: dlls/dinput/mouse.c
===================================================================
RCS file: /home/wine/wine/dlls/dinput/mouse.c,v
retrieving revision 1.3
diff -u -d -r1.3 mouse.c
--- dlls/dinput/mouse.c 4 Jun 2004 18:06:37 -0000 1.3
+++ dlls/dinput/mouse.c 16 Jun 2004 18:19:08 -0000
@@ -37,8 +37,6 @@
#include "wine/debug.h"
#include "wine/unicode.h"
-#define MOUSE_HACK
-
WINE_DEFAULT_DEBUG_CHANNEL(dinput);
/* Wine mouse driver object instances */
@@ -438,54 +436,26 @@
if (wparam == WM_MOUSEMOVE) {
if (This->absolute) {
- if (hook->pt.x != This->prevX)
- GEN_EVENT(This->offset_array[WINE_MOUSE_X_POSITION], hook->pt.x, hook->time, 0);
- if (hook->pt.y != This->prevY)
- GEN_EVENT(This->offset_array[WINE_MOUSE_Y_POSITION], hook->pt.y, hook->time, 0);
- } else {
- /* Now, warp handling */
- if ((This->need_warp == WARP_STARTED) &&
- (hook->pt.x == This->mapped_center.x) && (hook->pt.y == This->mapped_center.y)) {
- /* Warp has been done... */
- This->need_warp = WARP_DONE;
- goto end;
- }
-
- /* Relative mouse input with absolute mouse event : the real fun starts here... */
- if ((This->need_warp == WARP_NEEDED) ||
- (This->need_warp == WARP_STARTED)) {
- if (hook->pt.x != This->prevX)
- GEN_EVENT(This->offset_array[WINE_MOUSE_X_POSITION], hook->pt.x - This->prevX,
- hook->time, (This->dinput->evsequence)++);
- if (hook->pt.y != This->prevY)
- GEN_EVENT(This->offset_array[WINE_MOUSE_Y_POSITION], hook->pt.y - This->prevY,
- hook->time, (This->dinput->evsequence)++);
- } else {
- /* This is the first time the event handler has been called after a
- GetDeviceData or GetDeviceState. */
- if (hook->pt.x != This->mapped_center.x) {
- GEN_EVENT(This->offset_array[WINE_MOUSE_X_POSITION], hook->pt.x - This->mapped_center.x,
- hook->time, (This->dinput->evsequence)++);
- This->need_warp = WARP_NEEDED;
- }
-
- if (hook->pt.y != This->mapped_center.y) {
- GEN_EVENT(This->offset_array[WINE_MOUSE_Y_POSITION], hook->pt.y - This->mapped_center.y,
- hook->time, (This->dinput->evsequence)++);
- This->need_warp = WARP_NEEDED;
- }
- }
- }
-
- This->prevX = hook->pt.x;
- This->prevY = hook->pt.y;
-
- if (This->absolute) {
+ if (hook->pt.x != This->prevX)
+ GEN_EVENT(This->offset_array[WINE_MOUSE_X_POSITION], hook->pt.x, hook->time, 0);
+ if (hook->pt.y != This->prevY)
+ GEN_EVENT(This->offset_array[WINE_MOUSE_Y_POSITION], hook->pt.y, hook->time, 0);
+
This->m_state.lX = hook->pt.x;
This->m_state.lY = hook->pt.y;
+
+ This->prevX = hook->pt.x;
+ This->prevY = hook->pt.y;
} else {
- This->m_state.lX = hook->pt.x - This->mapped_center.x;
- This->m_state.lY = hook->pt.y - This->mapped_center.y;
+ if(hook->pt.x != This->mapped_center.x)
+ GEN_EVENT(This->offset_array[WINE_MOUSE_X_POSITION], hook->pt.x - This->mapped_center.x, hook->time, (This->dinput->evsequence)++);
+ if (hook->pt.y != This->mapped_center.y)
+ GEN_EVENT(This->offset_array[WINE_MOUSE_X_POSITION], hook->pt.x - This->mapped_center.y, hook->time, (This->dinput->evsequence)++);
+
+ This->m_state.lX += hook->pt.x - This->mapped_center.x;
+ This->m_state.lY += hook->pt.y - This->mapped_center.y;
+
+ SetCursorPos(This->mapped_center.x,This->mapped_center.y);
}
}
@@ -557,12 +527,10 @@
GetWindowRect(This->win, &rect);
centerX = (rect.right - rect.left) / 2;
centerY = (rect.bottom - rect.top ) / 2;
- if (This->win_centerX != centerX || This->win_centerY != centerY) {
- This->win_centerX = centerX;
- This->win_centerY = centerY;
- }
- This->mapped_center.x = This->win_centerX;
- This->mapped_center.y = This->win_centerY;
+ This->win_centerX = centerX;
+ This->win_centerY = centerY;
+ This->mapped_center.x = centerX;
+ This->mapped_center.y = centerY;
MapWindowPoints(This->win, HWND_DESKTOP, &This->mapped_center, 1);
}
@@ -617,11 +585,6 @@
MapWindowPoints(This->win, HWND_DESKTOP, &This->mapped_center, 1);
TRACE("Warping mouse to %ld - %ld\n", This->mapped_center.x, This->mapped_center.y);
SetCursorPos( This->mapped_center.x, This->mapped_center.y );
-#ifdef MOUSE_HACK
- This->need_warp = WARP_DONE;
-#else
- This->need_warp = WARP_STARTED;
-#endif
}
This->acquired = 1;
@@ -677,6 +640,8 @@
LPDIRECTINPUTDEVICE8A iface,DWORD len,LPVOID ptr
) {
ICOM_THIS(SysMouseImpl,iface);
+
+ if(This->acquired == 0) return DIERR_NOTACQUIRED;
EnterCriticalSection(&(This->crit));
TRACE("(this=%p,0x%08lx,%p): \n",This,len,ptr);
@@ -691,19 +656,6 @@
This->m_state.lZ = 0;
}
- /* Check if we need to do a mouse warping */
- if (This->need_warp == WARP_NEEDED) {
- dinput_window_check(This);
- TRACE("Warping mouse to %ld - %ld\n", This->mapped_center.x, This->mapped_center.y);
- SetCursorPos( This->mapped_center.x, This->mapped_center.y );
-
-#ifdef MOUSE_HACK
- This->need_warp = WARP_DONE;
-#else
- This->need_warp = WARP_STARTED;
-#endif
- }
-
LeaveCriticalSection(&(This->crit));
TRACE("(X: %ld - Y: %ld - Z: %ld L: %02x M: %02x R: %02x)\n",
@@ -714,7 +666,7 @@
}
/******************************************************************************
- * GetDeviceState : gets buffered input data.
+ * GetDeviceData : gets buffered input data.
*/
static HRESULT WINAPI SysMouseAImpl_GetDeviceData(LPDIRECTINPUTDEVICE8A iface,
DWORD dodsize,
@@ -776,18 +728,6 @@
LeaveCriticalSection(&(This->crit));
- /* Check if we need to do a mouse warping */
- if (This->need_warp == WARP_NEEDED) {
- dinput_window_check(This);
- TRACE("Warping mouse to %ld - %ld\n", This->mapped_center.x, This->mapped_center.y);
- SetCursorPos( This->mapped_center.x, This->mapped_center.y );
-
-#ifdef MOUSE_HACK
- This->need_warp = WARP_DONE;
-#else
- This->need_warp = WARP_STARTED;
-#endif
- }
return DI_OK;
}
More information about the wine-patches
mailing list