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,9 +30,9 @@
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 */
......
......@@ -89,9 +89,8 @@ static const IDirectInputDevice8AVtbl JoystickAvt;
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 @@ static HRESULT alloc_device(REFGUID rguid, const void *jvt, IDirectInputImpl *di
}
#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_Release(LPDIRECTINPUTDEVICE8A iface)
JoystickImpl *This = (JoystickImpl *)iface;
ULONG ref;
ref = InterlockedDecrement((&This->ref));
ref = InterlockedDecrement(&This->base.ref);
if (ref)
return ref;
......
......@@ -118,9 +118,8 @@ struct JoyDev {
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(REFGUID rguid, const void *jvt, IDirectInputIm
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_Release(LPDIRECTINPUTDEVICE8A iface)
JoystickImpl *This = (JoystickImpl *)iface;
ULONG ref;
ref = InterlockedDecrement(&(This->ref));
ref = InterlockedDecrement(&This->base.ref);
if (ref)
return ref;
......
......@@ -46,9 +46,7 @@ static const IDirectInputDevice8WVtbl SysKeyboardWvt;
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(REFGUID rguid, const void *kvt, IDirectInpu
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_Release(LPDIRECTINPUTDEVICE8A iface)
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);
......
......@@ -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(REFGUID rguid, const void *mvt, IDirectInputIm
};
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_Release(LPDIRECTINPUTDEVICE8A iface)
SysMouseImpl *This = (SysMouseImpl *)iface;
ULONG ref;
ref = InterlockedDecrement(&(This->ref));
ref = InterlockedDecrement(&This->base.ref);
if (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