Commit 7d838d9e authored by Vitaliy Margolen's avatar Vitaliy Margolen Committed by Alexandre Julliard

dinput: Use dinput device as a base class for keyboard, mouse and joystick.

parent 4205c64e
...@@ -30,7 +30,7 @@ ...@@ -30,7 +30,7 @@
typedef struct IDirectInputDevice2AImpl IDirectInputDevice2AImpl; typedef struct IDirectInputDevice2AImpl IDirectInputDevice2AImpl;
struct IDirectInputDevice2AImpl struct IDirectInputDevice2AImpl
{ {
const IDirectInputDevice2AVtbl *lpVtbl; const void *lpVtbl;
LONG ref; LONG ref;
GUID guid; GUID guid;
}; };
......
...@@ -89,9 +89,8 @@ static const IDirectInputDevice8AVtbl JoystickAvt; ...@@ -89,9 +89,8 @@ static const IDirectInputDevice8AVtbl JoystickAvt;
static const IDirectInputDevice8WVtbl JoystickWvt; static const IDirectInputDevice8WVtbl JoystickWvt;
struct JoystickImpl struct JoystickImpl
{ {
const void *lpVtbl; struct IDirectInputDevice2AImpl base;
LONG ref;
GUID guid;
char dev[32]; char dev[32];
/* The 'parent' DInput */ /* The 'parent' DInput */
...@@ -495,12 +494,12 @@ static HRESULT alloc_device(REFGUID rguid, const void *jvt, IDirectInputImpl *di ...@@ -495,12 +494,12 @@ static HRESULT alloc_device(REFGUID rguid, const void *jvt, IDirectInputImpl *di
} }
#endif #endif
newDevice->lpVtbl = jvt; newDevice->base.lpVtbl = jvt;
newDevice->ref = 1; newDevice->base.ref = 1;
newDevice->dinput = dinput; newDevice->dinput = dinput;
newDevice->acquired = FALSE; newDevice->acquired = FALSE;
newDevice->overflow = FALSE; newDevice->overflow = FALSE;
CopyMemory(&(newDevice->guid),rguid,sizeof(*rguid)); CopyMemory(&newDevice->base.guid, rguid, sizeof(*rguid));
/* setup_dinput_options may change these */ /* setup_dinput_options may change these */
newDevice->deadzone = 5000; newDevice->deadzone = 5000;
...@@ -672,7 +671,7 @@ static ULONG WINAPI JoystickAImpl_Release(LPDIRECTINPUTDEVICE8A iface) ...@@ -672,7 +671,7 @@ static ULONG WINAPI JoystickAImpl_Release(LPDIRECTINPUTDEVICE8A iface)
JoystickImpl *This = (JoystickImpl *)iface; JoystickImpl *This = (JoystickImpl *)iface;
ULONG ref; ULONG ref;
ref = InterlockedDecrement((&This->ref)); ref = InterlockedDecrement(&This->base.ref);
if (ref) if (ref)
return ref; return ref;
......
...@@ -118,9 +118,8 @@ struct JoyDev { ...@@ -118,9 +118,8 @@ struct JoyDev {
struct JoystickImpl struct JoystickImpl
{ {
const void *lpVtbl; struct IDirectInputDevice2AImpl base;
LONG ref;
GUID guid;
struct JoyDev *joydev; struct JoyDev *joydev;
/* The 'parent' DInput */ /* The 'parent' DInput */
...@@ -373,15 +372,15 @@ static JoystickImpl *alloc_device(REFGUID rguid, const void *jvt, IDirectInputIm ...@@ -373,15 +372,15 @@ static JoystickImpl *alloc_device(REFGUID rguid, const void *jvt, IDirectInputIm
return NULL; return NULL;
} }
newDevice->lpVtbl = jvt; newDevice->base.lpVtbl = jvt;
newDevice->ref = 1; newDevice->base.ref = 1;
memcpy(&newDevice->base.guid, rguid, sizeof(*rguid));
newDevice->joyfd = -1; newDevice->joyfd = -1;
newDevice->dinput = dinput; newDevice->dinput = dinput;
newDevice->joydev = joydev; newDevice->joydev = joydev;
#ifdef HAVE_STRUCT_FF_EFFECT_DIRECTION #ifdef HAVE_STRUCT_FF_EFFECT_DIRECTION
newDevice->ff_state = FF_STATUS_STOPPED; newDevice->ff_state = FF_STATUS_STOPPED;
#endif #endif
memcpy(&(newDevice->guid),rguid,sizeof(*rguid));
for (i=0;i<ABS_MAX;i++) { for (i=0;i<ABS_MAX;i++) {
/* apps expect the range to be the same they would get from the /* apps expect the range to be the same they would get from the
* GetProperty/range method */ * GetProperty/range method */
...@@ -522,7 +521,7 @@ static ULONG WINAPI JoystickAImpl_Release(LPDIRECTINPUTDEVICE8A iface) ...@@ -522,7 +521,7 @@ static ULONG WINAPI JoystickAImpl_Release(LPDIRECTINPUTDEVICE8A iface)
JoystickImpl *This = (JoystickImpl *)iface; JoystickImpl *This = (JoystickImpl *)iface;
ULONG ref; ULONG ref;
ref = InterlockedDecrement(&(This->ref)); ref = InterlockedDecrement(&This->base.ref);
if (ref) if (ref)
return ref; return ref;
......
...@@ -46,9 +46,7 @@ static const IDirectInputDevice8WVtbl SysKeyboardWvt; ...@@ -46,9 +46,7 @@ static const IDirectInputDevice8WVtbl SysKeyboardWvt;
typedef struct SysKeyboardImpl SysKeyboardImpl; typedef struct SysKeyboardImpl SysKeyboardImpl;
struct SysKeyboardImpl struct SysKeyboardImpl
{ {
const void *lpVtbl; struct IDirectInputDevice2AImpl base;
LONG ref;
GUID guid;
IDirectInputImpl* dinput; IDirectInputImpl* dinput;
...@@ -204,9 +202,9 @@ static SysKeyboardImpl *alloc_device(REFGUID rguid, const void *kvt, IDirectInpu ...@@ -204,9 +202,9 @@ static SysKeyboardImpl *alloc_device(REFGUID rguid, const void *kvt, IDirectInpu
SysKeyboardImpl* newDevice; SysKeyboardImpl* newDevice;
newDevice = HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY,sizeof(SysKeyboardImpl)); newDevice = HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY,sizeof(SysKeyboardImpl));
newDevice->lpVtbl = kvt; newDevice->base.lpVtbl = kvt;
newDevice->ref = 1; newDevice->base.ref = 1;
memcpy(&(newDevice->guid),rguid,sizeof(*rguid)); memcpy(&newDevice->base.guid, rguid, sizeof(*rguid));
newDevice->dinput = dinput; newDevice->dinput = dinput;
InitializeCriticalSection(&(newDevice->crit)); InitializeCriticalSection(&(newDevice->crit));
...@@ -263,7 +261,7 @@ static ULONG WINAPI SysKeyboardAImpl_Release(LPDIRECTINPUTDEVICE8A iface) ...@@ -263,7 +261,7 @@ static ULONG WINAPI SysKeyboardAImpl_Release(LPDIRECTINPUTDEVICE8A iface)
SysKeyboardImpl *This = (SysKeyboardImpl *)iface; SysKeyboardImpl *This = (SysKeyboardImpl *)iface;
ULONG ref; ULONG ref;
ref = InterlockedDecrement(&(This->ref)); ref = InterlockedDecrement(&This->base.ref);
if (ref) return ref; if (ref) return ref;
set_dinput_hook(WH_KEYBOARD_LL, NULL); set_dinput_hook(WH_KEYBOARD_LL, NULL);
......
...@@ -108,9 +108,7 @@ typedef enum { ...@@ -108,9 +108,7 @@ typedef enum {
struct SysMouseImpl struct SysMouseImpl
{ {
const void *lpVtbl; struct IDirectInputDevice2AImpl base;
LONG ref;
GUID guid;
IDirectInputImpl *dinput; IDirectInputImpl *dinput;
...@@ -251,10 +249,10 @@ static SysMouseImpl *alloc_device(REFGUID rguid, const void *mvt, IDirectInputIm ...@@ -251,10 +249,10 @@ static SysMouseImpl *alloc_device(REFGUID rguid, const void *mvt, IDirectInputIm
}; };
SysMouseImpl* newDevice; SysMouseImpl* newDevice;
newDevice = HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY,sizeof(SysMouseImpl)); newDevice = HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY,sizeof(SysMouseImpl));
newDevice->ref = 1; newDevice->base.lpVtbl = mvt;
newDevice->lpVtbl = mvt; newDevice->base.ref = 1;
memcpy(&newDevice->base.guid, rguid, sizeof(*rguid));
InitializeCriticalSection(&(newDevice->crit)); InitializeCriticalSection(&(newDevice->crit));
memcpy(&(newDevice->guid),rguid,sizeof(*rguid));
/* Per default, Wine uses its internal data format */ /* Per default, Wine uses its internal data format */
newDevice->df = (DIDATAFORMAT *) &Wine_InternalMouseFormat; newDevice->df = (DIDATAFORMAT *) &Wine_InternalMouseFormat;
...@@ -327,7 +325,7 @@ static ULONG WINAPI SysMouseAImpl_Release(LPDIRECTINPUTDEVICE8A iface) ...@@ -327,7 +325,7 @@ static ULONG WINAPI SysMouseAImpl_Release(LPDIRECTINPUTDEVICE8A iface)
SysMouseImpl *This = (SysMouseImpl *)iface; SysMouseImpl *This = (SysMouseImpl *)iface;
ULONG ref; ULONG ref;
ref = InterlockedDecrement(&(This->ref)); ref = InterlockedDecrement(&This->base.ref);
if (ref) if (ref)
return ref; return ref;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment