Vitaliy Margolen : dinput: Use dinput device as a base class for keyboard, mouse and joystick.
Module: wine Branch: master Commit: 7d838d9e6f3e45c9335526c764681b9ce01ba387 URL: http://source.winehq.org/git/wine.git/?a=commit;h=7d838d9e6f3e45c9335526c764... Author: Vitaliy Margolen <wine-patch(a)kievinfo.com> Date: Sun Oct 15 11:29:30 2006 -0600 dinput: Use dinput device as a base class for keyboard, mouse and joystick. --- dlls/dinput/device_private.h | 6 +++--- dlls/dinput/joystick_linux.c | 13 ++++++------- dlls/dinput/joystick_linuxinput.c | 13 ++++++------- dlls/dinput/keyboard.c | 12 +++++------- dlls/dinput/mouse.c | 12 +++++------- 5 files changed, 25 insertions(+), 31 deletions(-) diff --git a/dlls/dinput/device_private.h b/dlls/dinput/device_private.h index a2777c2..b5c88bf 100644 --- a/dlls/dinput/device_private.h +++ b/dlls/dinput/device_private.h @@ -30,9 +30,9 @@ #include "dinput.h" typedef struct IDirectInputDevice2AImpl IDirectInputDevice2AImpl; struct IDirectInputDevice2AImpl { - const IDirectInputDevice2AVtbl *lpVtbl; - LONG ref; - GUID guid; + const void *lpVtbl; + LONG ref; + GUID guid; }; /* Routines to do DataFormat / WineFormat conversions */ diff --git a/dlls/dinput/joystick_linux.c b/dlls/dinput/joystick_linux.c index 62a59c1..885d91f 100644 --- a/dlls/dinput/joystick_linux.c +++ b/dlls/dinput/joystick_linux.c @@ -89,9 +89,8 @@ static const IDirectInputDevice8AVtbl Jo static const IDirectInputDevice8WVtbl JoystickWvt; struct JoystickImpl { - const void *lpVtbl; - LONG ref; - GUID guid; + struct IDirectInputDevice2AImpl base; + char dev[32]; /* The 'parent' DInput */ @@ -495,12 +494,12 @@ #ifdef JSIOCGBUTTONS } #endif - newDevice->lpVtbl = jvt; - newDevice->ref = 1; + newDevice->base.lpVtbl = jvt; + newDevice->base.ref = 1; newDevice->dinput = dinput; newDevice->acquired = FALSE; newDevice->overflow = FALSE; - CopyMemory(&(newDevice->guid),rguid,sizeof(*rguid)); + CopyMemory(&newDevice->base.guid, rguid, sizeof(*rguid)); /* setup_dinput_options may change these */ newDevice->deadzone = 5000; @@ -672,7 +671,7 @@ static ULONG WINAPI JoystickAImpl_Releas JoystickImpl *This = (JoystickImpl *)iface; ULONG ref; - ref = InterlockedDecrement((&This->ref)); + ref = InterlockedDecrement(&This->base.ref); if (ref) return ref; diff --git a/dlls/dinput/joystick_linuxinput.c b/dlls/dinput/joystick_linuxinput.c index ef8af3d..335dc89 100644 --- a/dlls/dinput/joystick_linuxinput.c +++ b/dlls/dinput/joystick_linuxinput.c @@ -118,9 +118,8 @@ #define AXE_ABSFLAT 4 struct JoystickImpl { - const void *lpVtbl; - LONG ref; - GUID guid; + struct IDirectInputDevice2AImpl base; + struct JoyDev *joydev; /* The 'parent' DInput */ @@ -373,15 +372,15 @@ static JoystickImpl *alloc_device(REFGUI return NULL; } - newDevice->lpVtbl = jvt; - newDevice->ref = 1; + newDevice->base.lpVtbl = jvt; + newDevice->base.ref = 1; + memcpy(&newDevice->base.guid, rguid, sizeof(*rguid)); newDevice->joyfd = -1; newDevice->dinput = dinput; newDevice->joydev = joydev; #ifdef HAVE_STRUCT_FF_EFFECT_DIRECTION newDevice->ff_state = FF_STATUS_STOPPED; #endif - memcpy(&(newDevice->guid),rguid,sizeof(*rguid)); for (i=0;i<ABS_MAX;i++) { /* apps expect the range to be the same they would get from the * GetProperty/range method */ @@ -522,7 +521,7 @@ static ULONG WINAPI JoystickAImpl_Releas JoystickImpl *This = (JoystickImpl *)iface; ULONG ref; - ref = InterlockedDecrement(&(This->ref)); + ref = InterlockedDecrement(&This->base.ref); if (ref) return ref; diff --git a/dlls/dinput/keyboard.c b/dlls/dinput/keyboard.c index 8cff814..8dcf063 100644 --- a/dlls/dinput/keyboard.c +++ b/dlls/dinput/keyboard.c @@ -46,9 +46,7 @@ static const IDirectInputDevice8WVtbl Sy typedef struct SysKeyboardImpl SysKeyboardImpl; struct SysKeyboardImpl { - const void *lpVtbl; - LONG ref; - GUID guid; + struct IDirectInputDevice2AImpl base; IDirectInputImpl* dinput; @@ -204,9 +202,9 @@ static SysKeyboardImpl *alloc_device(REF SysKeyboardImpl* newDevice; newDevice = HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY,sizeof(SysKeyboardImpl)); - newDevice->lpVtbl = kvt; - newDevice->ref = 1; - memcpy(&(newDevice->guid),rguid,sizeof(*rguid)); + newDevice->base.lpVtbl = kvt; + newDevice->base.ref = 1; + memcpy(&newDevice->base.guid, rguid, sizeof(*rguid)); newDevice->dinput = dinput; InitializeCriticalSection(&(newDevice->crit)); @@ -263,7 +261,7 @@ static ULONG WINAPI SysKeyboardAImpl_Rel SysKeyboardImpl *This = (SysKeyboardImpl *)iface; ULONG ref; - ref = InterlockedDecrement(&(This->ref)); + ref = InterlockedDecrement(&This->base.ref); if (ref) return ref; set_dinput_hook(WH_KEYBOARD_LL, NULL); diff --git a/dlls/dinput/mouse.c b/dlls/dinput/mouse.c index b426af1..894dcb2 100644 --- a/dlls/dinput/mouse.c +++ b/dlls/dinput/mouse.c @@ -108,9 +108,7 @@ typedef enum { struct SysMouseImpl { - const void *lpVtbl; - LONG ref; - GUID guid; + struct IDirectInputDevice2AImpl base; IDirectInputImpl *dinput; @@ -251,10 +249,10 @@ static SysMouseImpl *alloc_device(REFGUI }; SysMouseImpl* newDevice; newDevice = HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY,sizeof(SysMouseImpl)); - newDevice->ref = 1; - newDevice->lpVtbl = mvt; + newDevice->base.lpVtbl = mvt; + newDevice->base.ref = 1; + memcpy(&newDevice->base.guid, rguid, sizeof(*rguid)); InitializeCriticalSection(&(newDevice->crit)); - memcpy(&(newDevice->guid),rguid,sizeof(*rguid)); /* Per default, Wine uses its internal data format */ newDevice->df = (DIDATAFORMAT *) &Wine_InternalMouseFormat; @@ -327,7 +325,7 @@ static ULONG WINAPI SysMouseAImpl_Releas SysMouseImpl *This = (SysMouseImpl *)iface; ULONG ref; - ref = InterlockedDecrement(&(This->ref)); + ref = InterlockedDecrement(&This->base.ref); if (ref) return ref;
participants (1)
-
Alexandre Julliard