Commit d2966c2d authored by Vitaliy Margolen's avatar Vitaliy Margolen Committed by Alexandre Julliard

dinput: Move parent dinput reference into base class.

parent 75a17709
......@@ -25,6 +25,7 @@
#include "windef.h"
#include "winbase.h"
#include "dinput.h"
#include "dinput_private.h"
typedef struct
{
......@@ -53,6 +54,7 @@ struct IDirectInputDevice2AImpl
LONG ref;
GUID guid;
CRITICAL_SECTION crit;
IDirectInputImpl *dinput;
HANDLE hEvent;
DWORD dwCoopLevel;
HWND win;
......
......@@ -97,9 +97,6 @@ struct JoystickImpl
char dev[32];
/* The 'parent' DInput */
IDirectInputImpl *dinput;
/* joystick private */
int joyfd;
DIJOYSTATE2 js; /* wine data */
......@@ -468,7 +465,7 @@ static HRESULT alloc_device(REFGUID rguid, const void *jvt, IDirectInputImpl *di
newDevice->base.lpVtbl = jvt;
newDevice->base.ref = 1;
newDevice->dinput = dinput;
newDevice->base.dinput = dinput;
CopyMemory(&newDevice->base.guid, rguid, sizeof(*rguid));
InitializeCriticalSection(&newDevice->base.crit);
newDevice->base.crit.DebugInfo->Spare[0] = (DWORD_PTR)(__FILE__ ": JoystickImpl*->base.crit");
......@@ -531,11 +528,11 @@ static HRESULT alloc_device(REFGUID rguid, const void *jvt, IDirectInputImpl *di
newDevice->props[i].lSaturation = 0;
}
IDirectInput_AddRef((LPDIRECTINPUTDEVICE8A)newDevice->dinput);
IDirectInput_AddRef((LPDIRECTINPUTDEVICE8A)newDevice->base.dinput);
newDevice->devcaps.dwSize = sizeof(newDevice->devcaps);
newDevice->devcaps.dwFlags = DIDC_ATTACHED;
if (newDevice->dinput->dwVersion >= 0x0800)
if (newDevice->base.dinput->dwVersion >= 0x0800)
newDevice->devcaps.dwDevType = DI8DEVTYPE_JOYSTICK | (DI8DEVTYPEJOYSTICK_STANDARD << 8);
else
newDevice->devcaps.dwDevType = DIDEVTYPE_JOYSTICK | (DIDEVTYPEJOYSTICK_TRADITIONAL << 8);
......@@ -666,7 +663,7 @@ static ULONG WINAPI JoystickAImpl_Release(LPDIRECTINPUTDEVICE8A iface)
release_DataFormat(&This->base.data_format);
This->base.crit.DebugInfo->Spare[0] = 0;
IDirectInput_Release((LPDIRECTINPUTDEVICE8A)This->dinput);
IDirectInput_Release((LPDIRECTINPUTDEVICE8A)This->base.dinput);
DeleteCriticalSection(&This->base.crit);
HeapFree(GetProcessHeap(),0,This);
......@@ -871,7 +868,7 @@ static void joy_polldev(JoystickImpl *This) {
if (inst_id >= 0)
queue_event((LPDIRECTINPUTDEVICE8A)This,
id_to_offset(&This->base.data_format, inst_id),
value, jse.time, This->dinput->evsequence++);
value, jse.time, This->base.dinput->evsequence++);
}
}
......
......@@ -131,9 +131,6 @@ struct JoystickImpl
struct JoyDev *joydev;
/* The 'parent' DInput */
IDirectInputImpl *dinput;
/* joystick private */
int joyfd;
......@@ -367,7 +364,7 @@ static JoystickImpl *alloc_device(REFGUID rguid, const void *jvt, IDirectInputIm
InitializeCriticalSection(&newDevice->base.crit);
newDevice->base.crit.DebugInfo->Spare[0] = (DWORD_PTR)(__FILE__ ": JoystickImpl*->base.crit");
newDevice->joyfd = -1;
newDevice->dinput = dinput;
newDevice->base.dinput = dinput;
newDevice->joydev = joydev;
#ifdef HAVE_STRUCT_FF_EFFECT_DIRECTION
newDevice->ff_state = FF_STATUS_STOPPED;
......@@ -423,7 +420,7 @@ static JoystickImpl *alloc_device(REFGUID rguid, const void *jvt, IDirectInputIm
fake_current_js_state(newDevice);
newDevice->base.data_format.wine_df = df;
IDirectInput_AddRef((LPDIRECTINPUTDEVICE8A)newDevice->dinput);
IDirectInput_AddRef((LPDIRECTINPUTDEVICE8A)newDevice->base.dinput);
return newDevice;
failed:
......@@ -529,7 +526,7 @@ static ULONG WINAPI JoystickAImpl_Release(LPDIRECTINPUTDEVICE8A iface)
HeapFree(GetProcessHeap(), 0, This->base.data_format.wine_df);
release_DataFormat(&This->base.data_format);
IDirectInput_Release((LPDIRECTINPUTDEVICE8A)This->dinput);
IDirectInput_Release((LPDIRECTINPUTDEVICE8A)This->base.dinput);
This->base.crit.DebugInfo->Spare[0] = 0;
DeleteCriticalSection(&This->base.crit);
......@@ -753,7 +750,7 @@ static void joy_polldev(JoystickImpl *This)
if (inst_id >= 0)
queue_event((LPDIRECTINPUTDEVICE8A)This,
id_to_offset(&This->base.data_format, inst_id),
value, ie.time.tv_usec, This->dinput->evsequence++);
value, ie.time.tv_usec, This->base.dinput->evsequence++);
}
}
......@@ -873,7 +870,7 @@ static HRESULT WINAPI JoystickAImpl_GetCapabilities(
}
lpDIDevCaps->dwFlags = DIDC_ATTACHED;
if (This->dinput->dwVersion >= 0x0800)
if (This->base.dinput->dwVersion >= 0x0800)
lpDIDevCaps->dwDevType = DI8DEVTYPE_JOYSTICK | (DI8DEVTYPEJOYSTICK_STANDARD << 8);
else
lpDIDevCaps->dwDevType = DIDEVTYPE_JOYSTICK | (DIDEVTYPEJOYSTICK_TRADITIONAL << 8);
......
......@@ -47,8 +47,6 @@ typedef struct SysKeyboardImpl SysKeyboardImpl;
struct SysKeyboardImpl
{
struct IDirectInputDevice2AImpl base;
IDirectInputImpl* dinput;
};
static SysKeyboardImpl* current_lock = NULL;
......@@ -87,7 +85,7 @@ static LRESULT CALLBACK KeyboardCallback( int code, WPARAM wparam, LPARAM lparam
dik_code = id_to_offset(&This->base.data_format, DIDFT_MAKEINSTANCE(dik_code) | DIDFT_PSHBUTTON);
EnterCriticalSection(&This->base.crit);
queue_event((LPDIRECTINPUTDEVICE8A)This, dik_code, new_diks, hook->time, This->dinput->evsequence++);
queue_event((LPDIRECTINPUTDEVICE8A)This, dik_code, new_diks, hook->time, This->base.dinput->evsequence++);
LeaveCriticalSection(&This->base.crit);
return CallNextHookEx(0, code, wparam, lparam);
......@@ -194,7 +192,7 @@ static SysKeyboardImpl *alloc_device(REFGUID rguid, const void *kvt, IDirectInpu
newDevice->base.lpVtbl = kvt;
newDevice->base.ref = 1;
memcpy(&newDevice->base.guid, rguid, sizeof(*rguid));
newDevice->dinput = dinput;
newDevice->base.dinput = dinput;
InitializeCriticalSection(&newDevice->base.crit);
newDevice->base.crit.DebugInfo->Spare[0] = (DWORD_PTR)(__FILE__ ": SysKeyboardImpl*->base.crit");
......@@ -216,7 +214,7 @@ static SysKeyboardImpl *alloc_device(REFGUID rguid, const void *kvt, IDirectInpu
df->dwNumObjs = idx;
newDevice->base.data_format.wine_df = df;
IDirectInput_AddRef((LPDIRECTINPUTDEVICE8A)newDevice->dinput);
IDirectInput_AddRef((LPDIRECTINPUTDEVICE8A)newDevice->base.dinput);
return newDevice;
failed:
......@@ -290,7 +288,7 @@ static ULONG WINAPI SysKeyboardAImpl_Release(LPDIRECTINPUTDEVICE8A iface)
HeapFree(GetProcessHeap(), 0, This->base.data_format.wine_df);
release_DataFormat(&This->base.data_format);
IDirectInput_Release((LPDIRECTINPUTDEVICE8A)This->dinput);
IDirectInput_Release((LPDIRECTINPUTDEVICE8A)This->base.dinput);
This->base.crit.DebugInfo->Spare[0] = 0;
DeleteCriticalSection(&This->base.crit);
HeapFree(GetProcessHeap(), 0, This);
......@@ -388,7 +386,7 @@ static HRESULT WINAPI SysKeyboardAImpl_GetCapabilities(
devcaps.dwSize = lpDIDevCaps->dwSize;
devcaps.dwFlags = DIDC_ATTACHED;
if (This->dinput->dwVersion >= 0x0800)
if (This->base.dinput->dwVersion >= 0x0800)
devcaps.dwDevType = DI8DEVTYPE_KEYBOARD | (DI8DEVTYPEKEYBOARD_UNKNOWN << 8);
else
devcaps.dwDevType = DIDEVTYPE_KEYBOARD | (DIDEVTYPEKEYBOARD_UNKNOWN << 8);
......@@ -465,7 +463,7 @@ static HRESULT WINAPI SysKeyboardAImpl_GetDeviceInfo(
return DI_OK;
}
fill_keyboard_dideviceinstanceA(pdidi, This->dinput->dwVersion);
fill_keyboard_dideviceinstanceA(pdidi, This->base.dinput->dwVersion);
return DI_OK;
}
......@@ -480,7 +478,7 @@ static HRESULT WINAPI SysKeyboardWImpl_GetDeviceInfo(LPDIRECTINPUTDEVICE8W iface
return DI_OK;
}
fill_keyboard_dideviceinstanceW(pdidi, This->dinput->dwVersion);
fill_keyboard_dideviceinstanceW(pdidi, This->base.dinput->dwVersion);
return DI_OK;
}
......
......@@ -54,8 +54,6 @@ struct SysMouseImpl
{
struct IDirectInputDevice2AImpl base;
IDirectInputImpl *dinput;
/* SysMouseAImpl */
/* These are used in case of relative -> absolute transitions */
POINT org_coords;
......@@ -178,7 +176,7 @@ static SysMouseImpl *alloc_device(REFGUID rguid, const void *mvt, IDirectInputIm
memcpy(&newDevice->base.guid, rguid, sizeof(*rguid));
InitializeCriticalSection(&newDevice->base.crit);
newDevice->base.crit.DebugInfo->Spare[0] = (DWORD_PTR)(__FILE__ ": SysMouseImpl*->base.crit");
newDevice->dinput = dinput;
newDevice->base.dinput = dinput;
/* Create copy of default data format */
if (!(df = HeapAlloc(GetProcessHeap(), 0, c_dfDIMouse2.dwSize))) goto failed;
......@@ -194,7 +192,7 @@ static SysMouseImpl *alloc_device(REFGUID rguid, const void *mvt, IDirectInputIm
df->rgodf[i].dwType = DIDFT_MAKEINSTANCE(i) | DIDFT_PSHBUTTON;
newDevice->base.data_format.wine_df = df;
IDirectInput_AddRef((LPDIRECTINPUTDEVICE8A)newDevice->dinput);
IDirectInput_AddRef((LPDIRECTINPUTDEVICE8A)newDevice->base.dinput);
return newDevice;
failed:
......@@ -278,7 +276,7 @@ static ULONG WINAPI SysMouseAImpl_Release(LPDIRECTINPUTDEVICE8A iface)
HeapFree(GetProcessHeap(), 0, This->base.data_format.wine_df);
release_DataFormat(&This->base.data_format);
IDirectInput_Release((LPDIRECTINPUTDEVICE8A)This->dinput);
IDirectInput_Release((LPDIRECTINPUTDEVICE8A)This->base.dinput);
This->base.crit.DebugInfo->Spare[0] = 0;
DeleteCriticalSection(&This->base.crit);
HeapFree(GetProcessHeap(),0,This);
......@@ -317,7 +315,7 @@ static LRESULT CALLBACK dinput_mouse_hook( int code, WPARAM wparam, LPARAM lpara
if (pt.x)
queue_event((LPDIRECTINPUTDEVICE8A)This, id_to_offset(&This->base.data_format,
DIDFT_MAKEINSTANCE(WINE_MOUSE_X_AXIS_INSTANCE) | DIDFT_RELAXIS),
pt1.x, hook->time, This->dinput->evsequence);
pt1.x, hook->time, This->base.dinput->evsequence);
if (pt.y)
{
inst_id = DIDFT_MAKEINSTANCE(WINE_MOUSE_Y_AXIS_INSTANCE) | DIDFT_RELAXIS;
......@@ -376,7 +374,7 @@ static LRESULT CALLBACK dinput_mouse_hook( int code, WPARAM wparam, LPARAM lpara
}
if (inst_id != -1)
queue_event((LPDIRECTINPUTDEVICE8A)This, id_to_offset(&This->base.data_format, inst_id),
wdata, hook->time, This->dinput->evsequence++);
wdata, hook->time, This->base.dinput->evsequence++);
LeaveCriticalSection(&This->base.crit);
......@@ -636,7 +634,7 @@ static HRESULT WINAPI SysMouseAImpl_GetCapabilities(
devcaps.dwSize = lpDIDevCaps->dwSize;
devcaps.dwFlags = DIDC_ATTACHED;
if (This->dinput->dwVersion >= 0x0800)
if (This->base.dinput->dwVersion >= 0x0800)
devcaps.dwDevType = DI8DEVTYPE_MOUSE | (DI8DEVTYPEMOUSE_TRADITIONAL << 8);
else
devcaps.dwDevType = DIDEVTYPE_MOUSE | (DIDEVTYPEMOUSE_TRADITIONAL << 8);
......@@ -715,7 +713,7 @@ static HRESULT WINAPI SysMouseAImpl_GetDeviceInfo(
return DI_OK;
}
fill_mouse_dideviceinstanceA(pdidi, This->dinput->dwVersion);
fill_mouse_dideviceinstanceA(pdidi, This->base.dinput->dwVersion);
return DI_OK;
}
......@@ -730,7 +728,7 @@ static HRESULT WINAPI SysMouseWImpl_GetDeviceInfo(LPDIRECTINPUTDEVICE8W iface, L
return DI_OK;
}
fill_mouse_dideviceinstanceW(pdidi, This->dinput->dwVersion);
fill_mouse_dideviceinstanceW(pdidi, This->base.dinput->dwVersion);
return DI_OK;
}
......
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