dinput: COM cleanup - use interfaces instead of vtbl. Combine both Unicode and ASCII interfaces into the same classes.
This commit is contained in:
parent
e6a8aa67d0
commit
6b30480021
|
@ -43,20 +43,20 @@ WINE_DEFAULT_DEBUG_CHANNEL(dinput);
|
|||
|
||||
static inline IDirectInputDeviceImpl *impl_from_IDirectInputDevice8A(IDirectInputDevice8A *iface)
|
||||
{
|
||||
return (IDirectInputDeviceImpl *) iface;
|
||||
return CONTAINING_RECORD(iface, IDirectInputDeviceImpl, IDirectInputDevice8A_iface);
|
||||
}
|
||||
static inline IDirectInputDeviceImpl *impl_from_IDirectInputDevice8W(IDirectInputDevice8W *iface)
|
||||
{
|
||||
return (IDirectInputDeviceImpl *) iface;
|
||||
return CONTAINING_RECORD(iface, IDirectInputDeviceImpl, IDirectInputDevice8W_iface);
|
||||
}
|
||||
|
||||
static inline IDirectInputDevice8A *IDirectInputDevice8A_from_impl(IDirectInputDeviceImpl *This)
|
||||
{
|
||||
return (IDirectInputDevice8A *)This;
|
||||
return &This->IDirectInputDevice8A_iface;
|
||||
}
|
||||
static inline IDirectInputDevice8W *IDirectInputDevice8W_from_impl(IDirectInputDeviceImpl *This)
|
||||
{
|
||||
return (IDirectInputDevice8W *)This;
|
||||
return &This->IDirectInputDevice8W_iface;
|
||||
}
|
||||
|
||||
/******************************************************************************
|
||||
|
|
|
@ -51,7 +51,8 @@ typedef struct
|
|||
typedef struct IDirectInputDeviceImpl IDirectInputDeviceImpl;
|
||||
struct IDirectInputDeviceImpl
|
||||
{
|
||||
const void *lpVtbl;
|
||||
IDirectInputDevice8A IDirectInputDevice8A_iface;
|
||||
IDirectInputDevice8W IDirectInputDevice8W_iface;
|
||||
LONG ref;
|
||||
GUID guid;
|
||||
CRITICAL_SECTION crit;
|
||||
|
|
|
@ -76,6 +76,15 @@ static inline IDirectInputImpl *impl_from_IDirectInput8W( IDirectInput8W *iface
|
|||
return CONTAINING_RECORD( iface, IDirectInputImpl, IDirectInput8W_iface );
|
||||
}
|
||||
|
||||
static inline IDirectInputDeviceImpl *impl_from_IDirectInputDevice8A(IDirectInputDevice8A *iface)
|
||||
{
|
||||
return CONTAINING_RECORD(iface, IDirectInputDeviceImpl, IDirectInputDevice8A_iface);
|
||||
}
|
||||
static inline IDirectInputDeviceImpl *impl_from_IDirectInputDevice8W(IDirectInputDevice8W *iface)
|
||||
{
|
||||
return CONTAINING_RECORD(iface, IDirectInputDeviceImpl, IDirectInputDevice8W_iface);
|
||||
}
|
||||
|
||||
static const struct dinput_device *dinput_devices[] =
|
||||
{
|
||||
&mouse_device,
|
||||
|
@ -498,8 +507,10 @@ static HRESULT WINAPI IDirectInput7AImpl_CreateDeviceEx(LPDIRECTINPUT7A iface, R
|
|||
if (!dinput_devices[i]->create_deviceA) continue;
|
||||
if ((ret = dinput_devices[i]->create_deviceA(This, rguid, riid, (LPDIRECTINPUTDEVICEA*) pvOut)) == DI_OK)
|
||||
{
|
||||
IDirectInputDeviceImpl *dev = impl_from_IDirectInputDevice8A(*pvOut);
|
||||
|
||||
EnterCriticalSection( &This->crit );
|
||||
list_add_tail( &This->devices_list, &(*(IDirectInputDeviceImpl**)pvOut)->entry );
|
||||
list_add_tail( &This->devices_list, &dev->entry );
|
||||
LeaveCriticalSection( &This->crit );
|
||||
return DI_OK;
|
||||
}
|
||||
|
@ -534,8 +545,10 @@ static HRESULT WINAPI IDirectInput7WImpl_CreateDeviceEx(LPDIRECTINPUT7W iface, R
|
|||
if (!dinput_devices[i]->create_deviceW) continue;
|
||||
if ((ret = dinput_devices[i]->create_deviceW(This, rguid, riid, (LPDIRECTINPUTDEVICEW*) pvOut)) == DI_OK)
|
||||
{
|
||||
IDirectInputDeviceImpl *dev = impl_from_IDirectInputDevice8W(*pvOut);
|
||||
|
||||
EnterCriticalSection( &This->crit );
|
||||
list_add_tail( &This->devices_list, &(*(IDirectInputDeviceImpl**)pvOut)->entry );
|
||||
list_add_tail( &This->devices_list, &dev->entry );
|
||||
LeaveCriticalSection( &This->crit );
|
||||
return DI_OK;
|
||||
}
|
||||
|
@ -922,7 +935,7 @@ static LRESULT CALLBACK LL_hook_proc( int code, WPARAM wparam, LPARAM lparam )
|
|||
if (dev->acquired && dev->event_proc)
|
||||
{
|
||||
TRACE("calling %p->%p (%lx %lx)\n", dev, dev->event_proc, wparam, lparam);
|
||||
skip |= dev->event_proc( (LPDIRECTINPUTDEVICE8A)dev, wparam, lparam );
|
||||
skip |= dev->event_proc( &dev->IDirectInputDevice8A_iface, wparam, lparam );
|
||||
}
|
||||
LeaveCriticalSection( &dinput->crit );
|
||||
}
|
||||
|
@ -957,7 +970,7 @@ static LRESULT CALLBACK callwndproc_proc( int code, WPARAM wparam, LPARAM lparam
|
|||
if (msg->hwnd == dev->win && msg->hwnd != foreground)
|
||||
{
|
||||
TRACE( "%p window is not foreground - unacquiring %p\n", dev->win, dev );
|
||||
IDirectInputDevice_Unacquire( (LPDIRECTINPUTDEVICE8A)dev );
|
||||
IDirectInputDevice_Unacquire( &dev->IDirectInputDevice8A_iface );
|
||||
}
|
||||
}
|
||||
LeaveCriticalSection( &dinput->crit );
|
||||
|
@ -1097,7 +1110,7 @@ void check_dinput_hooks(LPDIRECTINPUTDEVICE8W iface)
|
|||
{
|
||||
static HHOOK callwndproc_hook;
|
||||
static ULONG foreground_cnt;
|
||||
IDirectInputDeviceImpl *dev = (IDirectInputDeviceImpl *)iface;
|
||||
IDirectInputDeviceImpl *dev = impl_from_IDirectInputDevice8W(iface);
|
||||
|
||||
EnterCriticalSection(&dinput_hook_crit);
|
||||
|
||||
|
|
|
@ -34,19 +34,19 @@ WINE_DEFAULT_DEBUG_CHANNEL(dinput);
|
|||
|
||||
static inline JoystickGenericImpl *impl_from_IDirectInputDevice8A(IDirectInputDevice8A *iface)
|
||||
{
|
||||
return (JoystickGenericImpl *) iface;
|
||||
return CONTAINING_RECORD(CONTAINING_RECORD(iface, IDirectInputDeviceImpl, IDirectInputDevice8A_iface), JoystickGenericImpl, base);
|
||||
}
|
||||
static inline JoystickGenericImpl *impl_from_IDirectInputDevice8W(IDirectInputDevice8W *iface)
|
||||
{
|
||||
return (JoystickGenericImpl *) iface;
|
||||
return CONTAINING_RECORD(CONTAINING_RECORD(iface, IDirectInputDeviceImpl, IDirectInputDevice8W_iface), JoystickGenericImpl, base);
|
||||
}
|
||||
static inline IDirectInputDevice8A *IDirectInputDevice8A_from_impl(JoystickGenericImpl *This)
|
||||
{
|
||||
return (IDirectInputDevice8A *)This;
|
||||
return &This->base.IDirectInputDevice8A_iface;
|
||||
}
|
||||
static inline IDirectInputDevice8W *IDirectInputDevice8W_from_impl(JoystickGenericImpl *This)
|
||||
{
|
||||
return (IDirectInputDevice8W *)This;
|
||||
return &This->base.IDirectInputDevice8W_iface;
|
||||
}
|
||||
|
||||
/******************************************************************************
|
||||
|
|
|
@ -101,19 +101,21 @@ struct JoystickImpl
|
|||
|
||||
static inline JoystickImpl *impl_from_IDirectInputDevice8A(IDirectInputDevice8A *iface)
|
||||
{
|
||||
return (JoystickImpl *) iface;
|
||||
return CONTAINING_RECORD(CONTAINING_RECORD(CONTAINING_RECORD(iface, IDirectInputDeviceImpl, IDirectInputDevice8A_iface),
|
||||
JoystickGenericImpl, base), JoystickImpl, generic);
|
||||
}
|
||||
static inline JoystickImpl *impl_from_IDirectInputDevice8W(IDirectInputDevice8W *iface)
|
||||
{
|
||||
return (JoystickImpl *) iface;
|
||||
return CONTAINING_RECORD(CONTAINING_RECORD(CONTAINING_RECORD(iface, IDirectInputDeviceImpl, IDirectInputDevice8W_iface),
|
||||
JoystickGenericImpl, base), JoystickImpl, generic);
|
||||
}
|
||||
static inline IDirectInputDevice8A *IDirectInputDevice8A_from_impl(JoystickImpl *This)
|
||||
{
|
||||
return (IDirectInputDevice8A *)This;
|
||||
return &This->generic.base.IDirectInputDevice8A_iface;
|
||||
}
|
||||
static inline IDirectInputDevice8W *IDirectInputDevice8W_from_impl(JoystickImpl *This)
|
||||
{
|
||||
return (IDirectInputDevice8W *)This;
|
||||
return &This->generic.base.IDirectInputDevice8W_iface;
|
||||
}
|
||||
|
||||
static const GUID DInput_Wine_Joystick_GUID = { /* 9e573ed9-7734-11d2-8d4a-23903fb6bdf7 */
|
||||
|
@ -296,8 +298,8 @@ static BOOL joydev_enum_deviceW(DWORD dwDevType, DWORD dwFlags, LPDIDEVICEINSTAN
|
|||
return FALSE;
|
||||
}
|
||||
|
||||
static HRESULT alloc_device(REFGUID rguid, const void *jvt, IDirectInputImpl *dinput,
|
||||
LPDIRECTINPUTDEVICEA* pdev, unsigned short index)
|
||||
static HRESULT alloc_device(REFGUID rguid, IDirectInputImpl *dinput,
|
||||
JoystickImpl **pdev, unsigned short index)
|
||||
{
|
||||
DWORD i;
|
||||
JoystickImpl* newDevice;
|
||||
|
@ -305,7 +307,7 @@ static HRESULT alloc_device(REFGUID rguid, const void *jvt, IDirectInputImpl *di
|
|||
LPDIDATAFORMAT df = NULL;
|
||||
int idx = 0;
|
||||
|
||||
TRACE("%s %p %p %p %hu\n", debugstr_guid(rguid), jvt, dinput, pdev, index);
|
||||
TRACE("%s %p %p %hu\n", debugstr_guid(rguid), dinput, pdev, index);
|
||||
|
||||
newDevice = HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY,sizeof(JoystickImpl));
|
||||
if (newDevice == 0) {
|
||||
|
@ -330,7 +332,8 @@ static HRESULT alloc_device(REFGUID rguid, const void *jvt, IDirectInputImpl *di
|
|||
newDevice->generic.devcaps.dwButtons = 128;
|
||||
}
|
||||
|
||||
newDevice->generic.base.lpVtbl = jvt;
|
||||
newDevice->generic.base.IDirectInputDevice8A_iface.lpVtbl = &JoystickAvt;
|
||||
newDevice->generic.base.IDirectInputDevice8W_iface.lpVtbl = &JoystickWvt;
|
||||
newDevice->generic.base.ref = 1;
|
||||
newDevice->generic.base.dinput = dinput;
|
||||
newDevice->generic.base.guid = *rguid;
|
||||
|
@ -406,7 +409,7 @@ static HRESULT alloc_device(REFGUID rguid, const void *jvt, IDirectInputImpl *di
|
|||
_dump_DIDEVCAPS(&newDevice->generic.devcaps);
|
||||
}
|
||||
|
||||
*pdev = (LPDIRECTINPUTDEVICEA)newDevice;
|
||||
*pdev = newDevice;
|
||||
|
||||
return DI_OK;
|
||||
|
||||
|
@ -460,7 +463,11 @@ static HRESULT joydev_create_deviceA(IDirectInputImpl *dinput, REFGUID rguid, RE
|
|||
IsEqualGUID(&IID_IDirectInputDevice7A, riid) ||
|
||||
IsEqualGUID(&IID_IDirectInputDevice8A, riid))
|
||||
{
|
||||
return alloc_device(rguid, &JoystickAvt, dinput, pdev, index);
|
||||
JoystickImpl *This;
|
||||
HRESULT hr = alloc_device(rguid, dinput, &This, index);
|
||||
|
||||
*pdev = (LPDIRECTINPUTDEVICEA)(This ? &This->generic.base.IDirectInputDevice8A_iface : NULL);
|
||||
return hr;
|
||||
}
|
||||
|
||||
WARN("no interface\n");
|
||||
|
@ -487,7 +494,11 @@ static HRESULT joydev_create_deviceW(IDirectInputImpl *dinput, REFGUID rguid, RE
|
|||
IsEqualGUID(&IID_IDirectInputDevice7W, riid) ||
|
||||
IsEqualGUID(&IID_IDirectInputDevice8W, riid))
|
||||
{
|
||||
return alloc_device(rguid, &JoystickWvt, dinput, (LPDIRECTINPUTDEVICEA *)pdev, index);
|
||||
JoystickImpl *This;
|
||||
HRESULT hr = alloc_device(rguid, dinput, &This, index);
|
||||
|
||||
*pdev = (LPDIRECTINPUTDEVICEW)(This ? &This->generic.base.IDirectInputDevice8W_iface : NULL);
|
||||
return hr;
|
||||
}
|
||||
WARN("no interface\n");
|
||||
return DIERR_NOINTERFACE;
|
||||
|
|
|
@ -135,19 +135,21 @@ struct JoystickImpl
|
|||
|
||||
static inline JoystickImpl *impl_from_IDirectInputDevice8A(IDirectInputDevice8A *iface)
|
||||
{
|
||||
return (JoystickImpl *) iface;
|
||||
return CONTAINING_RECORD(CONTAINING_RECORD(CONTAINING_RECORD(iface, IDirectInputDeviceImpl, IDirectInputDevice8A_iface),
|
||||
JoystickGenericImpl, base), JoystickImpl, generic);
|
||||
}
|
||||
static inline JoystickImpl *impl_from_IDirectInputDevice8W(IDirectInputDevice8W *iface)
|
||||
{
|
||||
return (JoystickImpl *) iface;
|
||||
return CONTAINING_RECORD(CONTAINING_RECORD(CONTAINING_RECORD(iface, IDirectInputDeviceImpl, IDirectInputDevice8W_iface),
|
||||
JoystickGenericImpl, base), JoystickImpl, generic);
|
||||
}
|
||||
static inline IDirectInputDevice8A *IDirectInputDevice8A_from_impl(JoystickImpl *This)
|
||||
{
|
||||
return (IDirectInputDevice8A *) This;
|
||||
return &This->generic.base.IDirectInputDevice8A_iface;
|
||||
}
|
||||
static inline IDirectInputDevice8W *IDirectInputDevice8W_from_impl(JoystickImpl *This)
|
||||
{
|
||||
return (IDirectInputDevice8W *) This;
|
||||
return &This->generic.base.IDirectInputDevice8W_iface;
|
||||
}
|
||||
|
||||
static void fake_current_js_state(JoystickImpl *ji);
|
||||
|
@ -390,7 +392,7 @@ static BOOL joydev_enum_deviceW(DWORD dwDevType, DWORD dwFlags, LPDIDEVICEINSTAN
|
|||
return FALSE;
|
||||
}
|
||||
|
||||
static JoystickImpl *alloc_device(REFGUID rguid, const void *jvt, IDirectInputImpl *dinput, unsigned short index)
|
||||
static JoystickImpl *alloc_device(REFGUID rguid, IDirectInputImpl *dinput, unsigned short index)
|
||||
{
|
||||
JoystickImpl* newDevice;
|
||||
LPDIDATAFORMAT df = NULL;
|
||||
|
@ -400,7 +402,8 @@ static JoystickImpl *alloc_device(REFGUID rguid, const void *jvt, IDirectInputIm
|
|||
newDevice = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(JoystickImpl));
|
||||
if (!newDevice) return NULL;
|
||||
|
||||
newDevice->generic.base.lpVtbl = jvt;
|
||||
newDevice->generic.base.IDirectInputDevice8A_iface.lpVtbl = &JoystickAvt;
|
||||
newDevice->generic.base.IDirectInputDevice8W_iface.lpVtbl = &JoystickWvt;
|
||||
newDevice->generic.base.ref = 1;
|
||||
newDevice->generic.base.guid = *rguid;
|
||||
newDevice->generic.base.dinput = dinput;
|
||||
|
@ -567,14 +570,16 @@ static HRESULT joydev_create_deviceA(IDirectInputImpl *dinput, REFGUID rguid, RE
|
|||
IsEqualGUID(&IID_IDirectInputDevice7A, riid) ||
|
||||
IsEqualGUID(&IID_IDirectInputDevice8A, riid))
|
||||
{
|
||||
*pdev = (IDirectInputDeviceA*) alloc_device(rguid, &JoystickAvt, dinput, index);
|
||||
TRACE("Created a Joystick device (%p)\n", *pdev);
|
||||
JoystickImpl *This = alloc_device(rguid, dinput, index);
|
||||
TRACE("Created a Joystick device (%p)\n", This);
|
||||
|
||||
if (*pdev == NULL)
|
||||
if (!This)
|
||||
{
|
||||
ERR("out of memory\n");
|
||||
*pdev = NULL;
|
||||
return DIERR_OUTOFMEMORY;
|
||||
}
|
||||
*pdev = (IDirectInputDeviceA*) &This->generic.base.IDirectInputDevice8A_iface;
|
||||
return DI_OK;
|
||||
}
|
||||
|
||||
|
@ -601,14 +606,15 @@ static HRESULT joydev_create_deviceW(IDirectInputImpl *dinput, REFGUID rguid, RE
|
|||
IsEqualGUID(&IID_IDirectInputDevice7W, riid) ||
|
||||
IsEqualGUID(&IID_IDirectInputDevice8W, riid))
|
||||
{
|
||||
*pdev = (IDirectInputDeviceW*) alloc_device(rguid, &JoystickWvt, dinput, index);
|
||||
TRACE("Created a Joystick device (%p)\n", *pdev);
|
||||
JoystickImpl *This = alloc_device(rguid, dinput, index);
|
||||
TRACE("Created a Joystick device (%p)\n", This);
|
||||
|
||||
if (*pdev == NULL)
|
||||
if (!This)
|
||||
{
|
||||
ERR("out of memory\n");
|
||||
return DIERR_OUTOFMEMORY;
|
||||
}
|
||||
*pdev = (IDirectInputDeviceW*) &This->generic.base.IDirectInputDevice8W_iface;
|
||||
return DI_OK;
|
||||
}
|
||||
WARN("no interface\n");
|
||||
|
|
|
@ -137,11 +137,13 @@ struct JoystickImpl
|
|||
|
||||
static inline JoystickImpl *impl_from_IDirectInputDevice8A(IDirectInputDevice8A *iface)
|
||||
{
|
||||
return (JoystickImpl *) iface;
|
||||
return CONTAINING_RECORD(CONTAINING_RECORD(CONTAINING_RECORD(iface, IDirectInputDeviceImpl, IDirectInputDevice8A_iface),
|
||||
JoystickGenericImpl, base), JoystickImpl, generic);
|
||||
}
|
||||
static inline JoystickImpl *impl_from_IDirectInputDevice8W(IDirectInputDevice8W *iface)
|
||||
{
|
||||
return (JoystickImpl *) iface;
|
||||
return CONTAINING_RECORD(CONTAINING_RECORD(CONTAINING_RECORD(iface, IDirectInputDeviceImpl, IDirectInputDevice8W_iface),
|
||||
JoystickGenericImpl, base), JoystickImpl, generic);
|
||||
}
|
||||
|
||||
static const GUID DInput_Wine_OsX_Joystick_GUID = { /* 59CAD8F6-E617-41E2-8EB7-47B23EEEDC5A */
|
||||
|
@ -716,8 +718,8 @@ static BOOL joydev_enum_deviceW(DWORD dwDevType, DWORD dwFlags, LPDIDEVICEINSTAN
|
|||
return FALSE;
|
||||
}
|
||||
|
||||
static HRESULT alloc_device(REFGUID rguid, const void *jvt, IDirectInputImpl *dinput,
|
||||
LPDIRECTINPUTDEVICEA* pdev, unsigned short index)
|
||||
static HRESULT alloc_device(REFGUID rguid, IDirectInputImpl *dinput,
|
||||
JoystickImpl **pdev, unsigned short index)
|
||||
{
|
||||
DWORD i;
|
||||
JoystickImpl* newDevice;
|
||||
|
@ -728,7 +730,7 @@ static HRESULT alloc_device(REFGUID rguid, const void *jvt, IDirectInputImpl *di
|
|||
int axis_map[8]; /* max axes */
|
||||
int slider_count = 0;
|
||||
|
||||
TRACE("%s %p %p %p %hu\n", debugstr_guid(rguid), jvt, dinput, pdev, index);
|
||||
TRACE("%s %p %p %hu\n", debugstr_guid(rguid), dinput, pdev, index);
|
||||
|
||||
newDevice = HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY,sizeof(JoystickImpl));
|
||||
if (newDevice == 0) {
|
||||
|
@ -763,7 +765,8 @@ static HRESULT alloc_device(REFGUID rguid, const void *jvt, IDirectInputImpl *di
|
|||
newDevice->generic.devcaps.dwButtons = 128;
|
||||
}
|
||||
|
||||
newDevice->generic.base.lpVtbl = jvt;
|
||||
newDevice->generic.base.IDirectInputDevice8A_iface.lpVtbl = &JoystickAvt;
|
||||
newDevice->generic.base.IDirectInputDevice8W_iface.lpVtbl = &JoystickWvt;
|
||||
newDevice->generic.base.ref = 1;
|
||||
newDevice->generic.base.dinput = dinput;
|
||||
newDevice->generic.base.guid = *rguid;
|
||||
|
@ -835,7 +838,7 @@ static HRESULT alloc_device(REFGUID rguid, const void *jvt, IDirectInputImpl *di
|
|||
_dump_DIDEVCAPS(&newDevice->generic.devcaps);
|
||||
}
|
||||
|
||||
*pdev = (LPDIRECTINPUTDEVICEA)newDevice;
|
||||
*pdev = newDevice;
|
||||
|
||||
return DI_OK;
|
||||
|
||||
|
@ -891,7 +894,11 @@ static HRESULT joydev_create_deviceA(IDirectInputImpl *dinput, REFGUID rguid, RE
|
|||
IsEqualGUID(&IID_IDirectInputDevice7A, riid) ||
|
||||
IsEqualGUID(&IID_IDirectInputDevice8A, riid))
|
||||
{
|
||||
return alloc_device(rguid, &JoystickAvt, dinput, pdev, index);
|
||||
JoystickImpl *This;
|
||||
HRESULT hr = alloc_device(rguid, dinput, &This, index);
|
||||
|
||||
*pdev = (LPDIRECTINPUTDEVICEA)(This ? &This->generic.base.IDirectInputDevice8A_iface : NULL);
|
||||
return hr;
|
||||
}
|
||||
|
||||
WARN("no interface\n");
|
||||
|
@ -921,7 +928,11 @@ static HRESULT joydev_create_deviceW(IDirectInputImpl *dinput, REFGUID rguid, RE
|
|||
IsEqualGUID(&IID_IDirectInputDevice7W, riid) ||
|
||||
IsEqualGUID(&IID_IDirectInputDevice8W, riid))
|
||||
{
|
||||
return alloc_device(rguid, &JoystickWvt, dinput, (LPDIRECTINPUTDEVICEA *)pdev, index);
|
||||
JoystickImpl *This;
|
||||
HRESULT hr = alloc_device(rguid, dinput, &This, index);
|
||||
|
||||
*pdev = (LPDIRECTINPUTDEVICEW)(This ? &This->generic.base.IDirectInputDevice8W_iface : NULL);
|
||||
return hr;
|
||||
}
|
||||
WARN("no interface\n");
|
||||
return DIERR_NOINTERFACE;
|
||||
|
|
|
@ -52,19 +52,19 @@ struct SysKeyboardImpl
|
|||
|
||||
static inline SysKeyboardImpl *impl_from_IDirectInputDevice8A(IDirectInputDevice8A *iface)
|
||||
{
|
||||
return (SysKeyboardImpl *) iface;
|
||||
return CONTAINING_RECORD(CONTAINING_RECORD(iface, IDirectInputDeviceImpl, IDirectInputDevice8A_iface), SysKeyboardImpl, base);
|
||||
}
|
||||
static inline SysKeyboardImpl *impl_from_IDirectInputDevice8W(IDirectInputDevice8W *iface)
|
||||
{
|
||||
return (SysKeyboardImpl *) iface;
|
||||
return CONTAINING_RECORD(CONTAINING_RECORD(iface, IDirectInputDeviceImpl, IDirectInputDevice8W_iface), SysKeyboardImpl, base);
|
||||
}
|
||||
static inline IDirectInputDevice8A *IDirectInputDevice8A_from_impl(SysKeyboardImpl *This)
|
||||
{
|
||||
return (IDirectInputDevice8A *)This;
|
||||
return &This->base.IDirectInputDevice8A_iface;
|
||||
}
|
||||
static inline IDirectInputDevice8W *IDirectInputDevice8W_from_impl(SysKeyboardImpl *This)
|
||||
{
|
||||
return (IDirectInputDevice8W *)This;
|
||||
return &This->base.IDirectInputDevice8W_iface;
|
||||
}
|
||||
|
||||
static BYTE map_dik_code(DWORD scanCode, DWORD vkCode)
|
||||
|
@ -220,14 +220,15 @@ static BOOL keyboarddev_enum_deviceW(DWORD dwDevType, DWORD dwFlags, LPDIDEVICEI
|
|||
return FALSE;
|
||||
}
|
||||
|
||||
static SysKeyboardImpl *alloc_device(REFGUID rguid, const void *kvt, IDirectInputImpl *dinput)
|
||||
static SysKeyboardImpl *alloc_device(REFGUID rguid, IDirectInputImpl *dinput)
|
||||
{
|
||||
SysKeyboardImpl* newDevice;
|
||||
LPDIDATAFORMAT df = NULL;
|
||||
int i, idx = 0;
|
||||
|
||||
newDevice = HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY,sizeof(SysKeyboardImpl));
|
||||
newDevice->base.lpVtbl = kvt;
|
||||
newDevice->base.IDirectInputDevice8A_iface.lpVtbl = &SysKeyboardAvt;
|
||||
newDevice->base.IDirectInputDevice8W_iface.lpVtbl = &SysKeyboardWvt;
|
||||
newDevice->base.ref = 1;
|
||||
memcpy(&newDevice->base.guid, rguid, sizeof(*rguid));
|
||||
newDevice->base.dinput = dinput;
|
||||
|
@ -273,9 +274,14 @@ static HRESULT keyboarddev_create_deviceA(IDirectInputImpl *dinput, REFGUID rgui
|
|||
IsEqualGUID(&IID_IDirectInputDevice2A,riid) ||
|
||||
IsEqualGUID(&IID_IDirectInputDevice7A,riid) ||
|
||||
IsEqualGUID(&IID_IDirectInputDevice8A,riid)) {
|
||||
*pdev = (IDirectInputDeviceA*) alloc_device(rguid, &SysKeyboardAvt, dinput);
|
||||
|
||||
SysKeyboardImpl *This = alloc_device(rguid, dinput);
|
||||
if (!This) {
|
||||
*pdev = NULL;
|
||||
return DIERR_OUTOFMEMORY;
|
||||
}
|
||||
*pdev = (IDirectInputDeviceA*) &This->base.IDirectInputDevice8A_iface;
|
||||
TRACE("Creating a Keyboard device (%p)\n", *pdev);
|
||||
if (!*pdev) return DIERR_OUTOFMEMORY;
|
||||
return DI_OK;
|
||||
} else
|
||||
return DIERR_NOINTERFACE;
|
||||
|
@ -292,9 +298,14 @@ static HRESULT keyboarddev_create_deviceW(IDirectInputImpl *dinput, REFGUID rgui
|
|||
IsEqualGUID(&IID_IDirectInputDevice2W,riid) ||
|
||||
IsEqualGUID(&IID_IDirectInputDevice7W,riid) ||
|
||||
IsEqualGUID(&IID_IDirectInputDevice8W,riid)) {
|
||||
*pdev = (IDirectInputDeviceW*) alloc_device(rguid, &SysKeyboardWvt, dinput);
|
||||
|
||||
SysKeyboardImpl *This = alloc_device(rguid, dinput);
|
||||
if (!This) {
|
||||
*pdev = NULL;
|
||||
return DIERR_OUTOFMEMORY;
|
||||
}
|
||||
*pdev = (IDirectInputDeviceW*) &This->base.IDirectInputDevice8W_iface;
|
||||
TRACE("Creating a Keyboard device (%p)\n", *pdev);
|
||||
if (!*pdev) return DIERR_OUTOFMEMORY;
|
||||
return DI_OK;
|
||||
} else
|
||||
return DIERR_NOINTERFACE;
|
||||
|
|
|
@ -80,19 +80,19 @@ struct SysMouseImpl
|
|||
|
||||
static inline SysMouseImpl *impl_from_IDirectInputDevice8A(IDirectInputDevice8A *iface)
|
||||
{
|
||||
return (SysMouseImpl *) iface;
|
||||
return CONTAINING_RECORD(CONTAINING_RECORD(iface, IDirectInputDeviceImpl, IDirectInputDevice8A_iface), SysMouseImpl, base);
|
||||
}
|
||||
static inline SysMouseImpl *impl_from_IDirectInputDevice8W(IDirectInputDevice8W *iface)
|
||||
{
|
||||
return (SysMouseImpl *) iface;
|
||||
return CONTAINING_RECORD(CONTAINING_RECORD(iface, IDirectInputDeviceImpl, IDirectInputDevice8W_iface), SysMouseImpl, base);
|
||||
}
|
||||
static inline IDirectInputDevice8A *IDirectInputDevice8A_from_impl(SysMouseImpl *This)
|
||||
{
|
||||
return (IDirectInputDevice8A *)This;
|
||||
return &This->base.IDirectInputDevice8A_iface;
|
||||
}
|
||||
static inline IDirectInputDevice8W *IDirectInputDevice8W_from_impl(SysMouseImpl *This)
|
||||
{
|
||||
return (IDirectInputDevice8W *)This;
|
||||
return &This->base.IDirectInputDevice8W_iface;
|
||||
}
|
||||
|
||||
static int dinput_mouse_hook( LPDIRECTINPUTDEVICE8A iface, WPARAM wparam, LPARAM lparam );
|
||||
|
@ -196,7 +196,7 @@ static BOOL mousedev_enum_deviceW(DWORD dwDevType, DWORD dwFlags, LPDIDEVICEINST
|
|||
return FALSE;
|
||||
}
|
||||
|
||||
static SysMouseImpl *alloc_device(REFGUID rguid, const void *mvt, IDirectInputImpl *dinput)
|
||||
static SysMouseImpl *alloc_device(REFGUID rguid, IDirectInputImpl *dinput)
|
||||
{
|
||||
SysMouseImpl* newDevice;
|
||||
LPDIDATAFORMAT df = NULL;
|
||||
|
@ -206,7 +206,8 @@ static SysMouseImpl *alloc_device(REFGUID rguid, const void *mvt, IDirectInputIm
|
|||
|
||||
newDevice = HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY,sizeof(SysMouseImpl));
|
||||
if (!newDevice) return NULL;
|
||||
newDevice->base.lpVtbl = mvt;
|
||||
newDevice->base.IDirectInputDevice8A_iface.lpVtbl = &SysMouseAvt;
|
||||
newDevice->base.IDirectInputDevice8W_iface.lpVtbl = &SysMouseWvt;
|
||||
newDevice->base.ref = 1;
|
||||
newDevice->base.dwCoopLevel = DISCL_NONEXCLUSIVE | DISCL_BACKGROUND;
|
||||
newDevice->base.guid = *rguid;
|
||||
|
@ -259,9 +260,15 @@ static HRESULT mousedev_create_deviceA(IDirectInputImpl *dinput, REFGUID rguid,
|
|||
IsEqualGUID(&IID_IDirectInputDevice2A,riid) ||
|
||||
IsEqualGUID(&IID_IDirectInputDevice7A,riid) ||
|
||||
IsEqualGUID(&IID_IDirectInputDevice8A,riid)) {
|
||||
*pdev = (IDirectInputDeviceA*) alloc_device(rguid, &SysMouseAvt, dinput);
|
||||
TRACE("Creating a Mouse device (%p)\n", *pdev);
|
||||
if (!*pdev) return DIERR_OUTOFMEMORY;
|
||||
|
||||
SysMouseImpl* This = alloc_device(rguid, dinput);
|
||||
TRACE("Created a Mouse device (%p)\n", This);
|
||||
|
||||
if (!This) {
|
||||
*pdev = NULL;
|
||||
return DIERR_OUTOFMEMORY;
|
||||
}
|
||||
*pdev = (IDirectInputDeviceA*) &This->base.IDirectInputDevice8A_iface;
|
||||
return DI_OK;
|
||||
} else
|
||||
return DIERR_NOINTERFACE;
|
||||
|
@ -279,9 +286,15 @@ static HRESULT mousedev_create_deviceW(IDirectInputImpl *dinput, REFGUID rguid,
|
|||
IsEqualGUID(&IID_IDirectInputDevice2W,riid) ||
|
||||
IsEqualGUID(&IID_IDirectInputDevice7W,riid) ||
|
||||
IsEqualGUID(&IID_IDirectInputDevice8W,riid)) {
|
||||
*pdev = (IDirectInputDeviceW*) alloc_device(rguid, &SysMouseWvt, dinput);
|
||||
TRACE("Creating a Mouse device (%p)\n", *pdev);
|
||||
if (!*pdev) return DIERR_OUTOFMEMORY;
|
||||
|
||||
SysMouseImpl* This = alloc_device(rguid, dinput);
|
||||
TRACE("Created a Mouse device (%p)\n", This);
|
||||
|
||||
if (!This) {
|
||||
*pdev = NULL;
|
||||
return DIERR_OUTOFMEMORY;
|
||||
}
|
||||
*pdev = (IDirectInputDeviceW*) &This->base.IDirectInputDevice8W_iface;
|
||||
return DI_OK;
|
||||
} else
|
||||
return DIERR_NOINTERFACE;
|
||||
|
|
Loading…
Reference in New Issue