Instead of sometimes using IDirectInputDevice8A.
Signed-off-by: Rémi Bernon rbernon@codeweavers.com --- dlls/dinput/device.c | 12 +++++++----- dlls/dinput/device_private.h | 4 ++-- dlls/dinput/dinput_main.c | 14 +++++++------- dlls/dinput/dinput_private.h | 7 ++++--- dlls/dinput/joystick.c | 8 ++------ dlls/dinput/joystick_linux.c | 6 +++--- dlls/dinput/joystick_linuxinput.c | 6 +++--- dlls/dinput/joystick_osx.c | 4 ++-- dlls/dinput/joystick_private.h | 2 +- dlls/dinput/keyboard.c | 10 +++------- dlls/dinput/mouse.c | 8 ++++---- dlls/dinput/tests/device.c | 29 +++++++++++++++++++++++++++++ 12 files changed, 67 insertions(+), 43 deletions(-)
diff --git a/dlls/dinput/device.c b/dlls/dinput/device.c index 0b1a6d9b96d..c645e033677 100644 --- a/dlls/dinput/device.c +++ b/dlls/dinput/device.c @@ -986,10 +986,10 @@ HRESULT _set_action_map(LPDIRECTINPUTDEVICE8W iface, LPDIACTIONFORMATW lpdiaf, L * queue_event - add new event to the ring queue */
-void queue_event(LPDIRECTINPUTDEVICE8A iface, int inst_id, DWORD data, DWORD time, DWORD seq) +void queue_event( IDirectInputDevice8W *iface, int inst_id, DWORD data, DWORD time, DWORD seq ) { static ULONGLONG notify_ms = 0; - IDirectInputDeviceImpl *This = impl_from_IDirectInputDevice8A(iface); + IDirectInputDeviceImpl *This = impl_from_IDirectInputDevice8W( iface ); int next_pos, ofs = id_to_offset(&This->data_format, inst_id); ULONGLONG time_ms = GetTickCount64();
@@ -1250,8 +1250,8 @@ HRESULT WINAPI IDirectInputDevice2WImpl_QueryInterface(LPDIRECTINPUTDEVICE8W ifa IDirectInputDeviceImpl *This = impl_from_IDirectInputDevice8W(iface);
TRACE("(%p)->(%s,%p)\n", This, debugstr_guid(riid), ppobj); - if (IsEqualGUID(&IID_IUnknown, riid) || - IsEqualGUID(&IID_IDirectInputDeviceA, riid) || + + if (IsEqualGUID(&IID_IDirectInputDeviceA, riid) || IsEqualGUID(&IID_IDirectInputDevice2A, riid) || IsEqualGUID(&IID_IDirectInputDevice7A, riid) || IsEqualGUID(&IID_IDirectInputDevice8A, riid)) @@ -1260,7 +1260,9 @@ HRESULT WINAPI IDirectInputDevice2WImpl_QueryInterface(LPDIRECTINPUTDEVICE8W ifa *ppobj = IDirectInputDevice8A_from_impl(This); return DI_OK; } - if (IsEqualGUID(&IID_IDirectInputDeviceW, riid) || + + if (IsEqualGUID(&IID_IUnknown, riid) || + IsEqualGUID(&IID_IDirectInputDeviceW, riid) || IsEqualGUID(&IID_IDirectInputDevice2W, riid) || IsEqualGUID(&IID_IDirectInputDevice7W, riid) || IsEqualGUID(&IID_IDirectInputDevice8W, riid)) diff --git a/dlls/dinput/device_private.h b/dlls/dinput/device_private.h index 2fac4f0e61e..56718790040 100644 --- a/dlls/dinput/device_private.h +++ b/dlls/dinput/device_private.h @@ -57,8 +57,8 @@ typedef struct typedef struct IDirectInputDeviceImpl IDirectInputDeviceImpl; struct IDirectInputDeviceImpl { - IDirectInputDevice8A IDirectInputDevice8A_iface; IDirectInputDevice8W IDirectInputDevice8W_iface; + IDirectInputDevice8A IDirectInputDevice8A_iface; LONG ref; GUID guid; CRITICAL_SECTION crit; @@ -92,7 +92,7 @@ extern DWORD get_config_key(HKEY, HKEY, const char*, char*, DWORD) DECLSPEC_HIDD /* Routines to do DataFormat / WineFormat conversions */ extern void fill_DataFormat(void *out, DWORD size, const void *in, const DataFormat *df) DECLSPEC_HIDDEN; extern void release_DataFormat(DataFormat *df) DECLSPEC_HIDDEN; -extern void queue_event(LPDIRECTINPUTDEVICE8A iface, int inst_id, DWORD data, DWORD time, DWORD seq) DECLSPEC_HIDDEN; +extern void queue_event( IDirectInputDevice8W *iface, int inst_id, DWORD data, DWORD time, DWORD seq ) DECLSPEC_HIDDEN; /* Helper functions to work with data format */ extern int id_to_object(LPCDIDATAFORMAT df, int id) DECLSPEC_HIDDEN; extern int find_property(const DataFormat *df, LPCDIPROPHEADER ph) DECLSPEC_HIDDEN; diff --git a/dlls/dinput/dinput_main.c b/dlls/dinput/dinput_main.c index 7301b66cb6d..7f59c16c45a 100644 --- a/dlls/dinput/dinput_main.c +++ b/dlls/dinput/dinput_main.c @@ -659,7 +659,7 @@ static LRESULT WINAPI di_em_win_wndproc(HWND hwnd, UINT msg, WPARAM wparam, LPAR { EnterCriticalSection( &dinput_hook_crit ); LIST_FOR_EACH_ENTRY( dev, &acquired_rawmouse_list, IDirectInputDeviceImpl, entry ) - dinput_mouse_rawinput_hook( &dev->IDirectInputDevice8A_iface, wparam, lparam, &ri ); + dinput_mouse_rawinput_hook( &dev->IDirectInputDevice8W_iface, wparam, lparam, &ri ); LeaveCriticalSection( &dinput_hook_crit ); } } @@ -1695,13 +1695,13 @@ static LRESULT CALLBACK LL_hook_proc( int code, WPARAM wparam, LPARAM lparam ) LIST_FOR_EACH_ENTRY( dev, &acquired_mouse_list, IDirectInputDeviceImpl, entry ) { TRACE("calling dinput_mouse_hook (%p %lx %lx)\n", dev, wparam, lparam); - skip |= dinput_mouse_hook( &dev->IDirectInputDevice8A_iface, wparam, lparam ); + skip |= dinput_mouse_hook( &dev->IDirectInputDevice8W_iface, wparam, lparam ); } LIST_FOR_EACH_ENTRY( dev, &acquired_keyboard_list, IDirectInputDeviceImpl, entry ) { if (dev->use_raw_input) continue; TRACE("calling dinput_keyboard_hook (%p %lx %lx)\n", dev, wparam, lparam); - skip |= dinput_keyboard_hook( &dev->IDirectInputDevice8A_iface, wparam, lparam ); + skip |= dinput_keyboard_hook( &dev->IDirectInputDevice8W_iface, wparam, lparam ); } LeaveCriticalSection( &dinput_hook_crit );
@@ -1726,7 +1726,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( &dev->IDirectInputDevice8A_iface ); + IDirectInputDevice_Unacquire( &dev->IDirectInputDevice8W_iface ); } } LIST_FOR_EACH_ENTRY_SAFE( dev, next, &acquired_mouse_list, IDirectInputDeviceImpl, entry ) @@ -1734,7 +1734,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( &dev->IDirectInputDevice8A_iface ); + IDirectInputDevice_Unacquire( &dev->IDirectInputDevice8W_iface ); } } LIST_FOR_EACH_ENTRY_SAFE( dev, next, &acquired_rawmouse_list, IDirectInputDeviceImpl, entry ) @@ -1742,7 +1742,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( &dev->IDirectInputDevice8A_iface ); + IDirectInputDevice_Unacquire( &dev->IDirectInputDevice8W_iface ); } } LIST_FOR_EACH_ENTRY_SAFE( dev, next, &acquired_keyboard_list, IDirectInputDeviceImpl, entry ) @@ -1750,7 +1750,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( &dev->IDirectInputDevice8A_iface ); + IDirectInputDevice_Unacquire( &dev->IDirectInputDevice8W_iface ); } } LeaveCriticalSection( &dinput_hook_crit ); diff --git a/dlls/dinput/dinput_private.h b/dlls/dinput/dinput_private.h index c0c88da9674..3df20a424ab 100644 --- a/dlls/dinput/dinput_private.h +++ b/dlls/dinput/dinput_private.h @@ -71,9 +71,10 @@ extern const struct dinput_device joystick_osx_device DECLSPEC_HIDDEN;
extern void dinput_hooks_acquire_device(LPDIRECTINPUTDEVICE8W iface); extern void dinput_hooks_unacquire_device(LPDIRECTINPUTDEVICE8W iface); -extern int dinput_mouse_hook(LPDIRECTINPUTDEVICE8A iface, WPARAM wparam, LPARAM lparam); -extern int dinput_keyboard_hook(LPDIRECTINPUTDEVICE8A iface, WPARAM wparam, LPARAM lparam); -extern void dinput_mouse_rawinput_hook( LPDIRECTINPUTDEVICE8A iface, WPARAM wparam, LPARAM lparam, RAWINPUT *raw ); +extern int dinput_mouse_hook( IDirectInputDevice8W *iface, WPARAM wparam, LPARAM lparam ); +extern int dinput_keyboard_hook( IDirectInputDevice8W *iface, WPARAM wparam, LPARAM lparam ); +extern void dinput_mouse_rawinput_hook( IDirectInputDevice8W *iface, WPARAM wparam, LPARAM lparam, + RAWINPUT *raw );
extern void check_dinput_hooks(LPDIRECTINPUTDEVICE8W, BOOL) DECLSPEC_HIDDEN; extern void check_dinput_events(void) DECLSPEC_HIDDEN; diff --git a/dlls/dinput/joystick.c b/dlls/dinput/joystick.c index f9b89d2d70c..68428ac0ddd 100644 --- a/dlls/dinput/joystick.c +++ b/dlls/dinput/joystick.c @@ -68,10 +68,6 @@ static inline JoystickGenericImpl *impl_from_IDirectInputDevice8W(IDirectInputDe { return CONTAINING_RECORD(CONTAINING_RECORD(iface, IDirectInputDeviceImpl, IDirectInputDevice8W_iface), JoystickGenericImpl, base); } -static inline IDirectInputDevice8A *IDirectInputDevice8A_from_impl(JoystickGenericImpl *This) -{ - return &This->base.IDirectInputDevice8A_iface; -} static inline IDirectInputDevice8W *IDirectInputDevice8W_from_impl(JoystickGenericImpl *This) { return &This->base.IDirectInputDevice8W_iface; @@ -788,7 +784,7 @@ HRESULT WINAPI JoystickWGenericImpl_Poll(LPDIRECTINPUTDEVICE8W iface) return DIERR_NOTACQUIRED; }
- This->joy_polldev(IDirectInputDevice8A_from_impl(This)); + This->joy_polldev( iface ); return DI_OK; }
@@ -814,7 +810,7 @@ HRESULT WINAPI JoystickWGenericImpl_GetDeviceState(LPDIRECTINPUTDEVICE8W iface, }
/* update joystick state */ - This->joy_polldev(IDirectInputDevice8A_from_impl(This)); + This->joy_polldev( iface );
/* convert and copy data to user supplied buffer */ fill_DataFormat(ptr, len, &This->js, &This->base.data_format); diff --git a/dlls/dinput/joystick_linux.c b/dlls/dinput/joystick_linux.c index 79a077a027c..ee7ad53db11 100644 --- a/dlls/dinput/joystick_linux.c +++ b/dlls/dinput/joystick_linux.c @@ -130,7 +130,7 @@ static const GUID DInput_Wine_Joystick_GUID = { /* 9e573ed9-7734-11d2-8d4a-23903 static INT joystick_devices_count = -1; static struct JoyDev *joystick_devices;
-static void joy_polldev(LPDIRECTINPUTDEVICE8A iface); +static void joy_polldev( IDirectInputDevice8W *iface );
#define SYS_PATH_FORMAT "/sys/class/input/js%d/device/id/%s" static BOOL read_sys_id_variable(int index, const char *property, WORD *value) @@ -850,11 +850,11 @@ static HRESULT WINAPI JoystickLinuxAImpl_Unacquire(LPDIRECTINPUTDEVICE8A iface) return JoystickLinuxWImpl_Unacquire(IDirectInputDevice8W_from_impl(This)); }
-static void joy_polldev(LPDIRECTINPUTDEVICE8A iface) +static void joy_polldev( IDirectInputDevice8W *iface ) { struct pollfd plfd; struct js_event jse; - JoystickImpl *This = impl_from_IDirectInputDevice8A(iface); + JoystickImpl *This = impl_from_IDirectInputDevice8W( iface );
TRACE("(%p)\n", This);
diff --git a/dlls/dinput/joystick_linuxinput.c b/dlls/dinput/joystick_linuxinput.c index f0d2e0dc32b..b3ad195bbef 100644 --- a/dlls/dinput/joystick_linuxinput.c +++ b/dlls/dinput/joystick_linuxinput.c @@ -155,7 +155,7 @@ static inline IDirectInputDevice8W *IDirectInputDevice8W_from_impl(JoystickImpl
static void fake_current_js_state(JoystickImpl *ji); static void find_joydevs(void); -static void joy_polldev(LPDIRECTINPUTDEVICE8A iface); +static void joy_polldev( IDirectInputDevice8W *iface );
/* This GUID is slightly different from the linux joystick one. Take note. */ static const GUID DInput_Wine_Joystick_Base_GUID = { /* 9e573eda-7734-11d2-8d4a-23903fb6bdf7 */ @@ -813,11 +813,11 @@ static void fake_current_js_state(JoystickImpl *ji) #undef CENTER_AXIS
/* convert wine format offset to user format object index */ -static void joy_polldev(LPDIRECTINPUTDEVICE8A iface) +static void joy_polldev( IDirectInputDevice8W *iface ) { struct pollfd plfd; struct input_event ie; - JoystickImpl *This = impl_from_IDirectInputDevice8A(iface); + JoystickImpl *This = impl_from_IDirectInputDevice8W( iface );
if (This->joyfd==-1) return; diff --git a/dlls/dinput/joystick_osx.c b/dlls/dinput/joystick_osx.c index e27357efb32..a2f9e936746 100644 --- a/dlls/dinput/joystick_osx.c +++ b/dlls/dinput/joystick_osx.c @@ -797,9 +797,9 @@ static void get_osx_device_elements_props(JoystickImpl *device) } }
-static void poll_osx_device_state(LPDIRECTINPUTDEVICE8A iface) +static void poll_osx_device_state( IDirectInputDevice8W *iface ) { - JoystickImpl *device = impl_from_IDirectInputDevice8A(iface); + JoystickImpl *device = impl_from_IDirectInputDevice8W( iface ); IOHIDElementRef device_main_element; IOHIDDeviceRef hid_device;
diff --git a/dlls/dinput/joystick_private.h b/dlls/dinput/joystick_private.h index b786c84decb..ae382047fb4 100644 --- a/dlls/dinput/joystick_private.h +++ b/dlls/dinput/joystick_private.h @@ -33,7 +33,7 @@ #define MAX_PROPS 164 struct JoystickGenericImpl;
-typedef void joy_polldev_handler(LPDIRECTINPUTDEVICE8A iface); +typedef void joy_polldev_handler( IDirectInputDevice8W *iface );
typedef struct JoystickGenericImpl { diff --git a/dlls/dinput/keyboard.c b/dlls/dinput/keyboard.c index 9981372d957..4a3606d2c43 100644 --- a/dlls/dinput/keyboard.c +++ b/dlls/dinput/keyboard.c @@ -59,10 +59,6 @@ static inline SysKeyboardImpl *impl_from_IDirectInputDevice8W(IDirectInputDevice { return CONTAINING_RECORD(CONTAINING_RECORD(iface, IDirectInputDeviceImpl, IDirectInputDevice8W_iface), SysKeyboardImpl, base); } -static inline IDirectInputDevice8A *IDirectInputDevice8A_from_impl(SysKeyboardImpl *This) -{ - return &This->base.IDirectInputDevice8A_iface; -} static inline IDirectInputDevice8W *IDirectInputDevice8W_from_impl(SysKeyboardImpl *This) { return &This->base.IDirectInputDevice8W_iface; @@ -103,9 +99,9 @@ static BYTE map_dik_code(DWORD scanCode, DWORD vkCode, DWORD subType, DWORD vers return scanCode; }
-int dinput_keyboard_hook( LPDIRECTINPUTDEVICE8A iface, WPARAM wparam, LPARAM lparam ) +int dinput_keyboard_hook( IDirectInputDevice8W *iface, WPARAM wparam, LPARAM lparam ) { - SysKeyboardImpl *This = impl_from_IDirectInputDevice8A(iface); + SysKeyboardImpl *This = impl_from_IDirectInputDevice8W( iface ); int dik_code, ret = This->base.dwCoopLevel & DISCL_EXCLUSIVE; KBDLLHOOKSTRUCT *hook = (KBDLLHOOKSTRUCT *)lparam; BYTE new_diks; @@ -576,7 +572,7 @@ static HRESULT WINAPI SysKeyboardWImpl_GetProperty(LPDIRECTINPUTDEVICE8W iface, case (DWORD_PTR) DIPROP_RANGE: return DIERR_UNSUPPORTED; default: - return IDirectInputDevice2AImpl_GetProperty( IDirectInputDevice8A_from_impl(This), rguid, pdiph ); + return IDirectInputDevice2WImpl_GetProperty( iface, rguid, pdiph ); } return DI_OK; } diff --git a/dlls/dinput/mouse.c b/dlls/dinput/mouse.c index e50731fda41..46844ffa28d 100644 --- a/dlls/dinput/mouse.c +++ b/dlls/dinput/mouse.c @@ -313,9 +313,9 @@ const struct dinput_device mouse_device = { * SysMouseA (DInput Mouse support) */
-void dinput_mouse_rawinput_hook( LPDIRECTINPUTDEVICE8A iface, WPARAM wparam, LPARAM lparam, RAWINPUT *ri ) +void dinput_mouse_rawinput_hook( IDirectInputDevice8W *iface, WPARAM wparam, LPARAM lparam, RAWINPUT *ri ) { - SysMouseImpl* This = impl_from_IDirectInputDevice8A( iface ); + SysMouseImpl *This = impl_from_IDirectInputDevice8W( iface ); POINT rel, pt; DWORD seq; int i, wdata = 0; @@ -397,10 +397,10 @@ void dinput_mouse_rawinput_hook( LPDIRECTINPUTDEVICE8A iface, WPARAM wparam, LPA }
/* low-level mouse hook */ -int dinput_mouse_hook( LPDIRECTINPUTDEVICE8A iface, WPARAM wparam, LPARAM lparam ) +int dinput_mouse_hook( IDirectInputDevice8W *iface, WPARAM wparam, LPARAM lparam ) { MSLLHOOKSTRUCT *hook = (MSLLHOOKSTRUCT *)lparam; - SysMouseImpl* This = impl_from_IDirectInputDevice8A(iface); + SysMouseImpl *This = impl_from_IDirectInputDevice8W( iface ); int wdata = 0, inst_id = -1, ret = 0;
TRACE("msg %lx @ (%d %d)\n", wparam, hook->pt.x, hook->pt.y); diff --git a/dlls/dinput/tests/device.c b/dlls/dinput/tests/device.c index fd212bf2514..071fc6de6bb 100644 --- a/dlls/dinput/tests/device.c +++ b/dlls/dinput/tests/device.c @@ -206,6 +206,7 @@ static BOOL CALLBACK enum_devices(const DIDEVICEINSTANCEA *lpddi, void *pvRef) IDirectInputDeviceA *device, *obj = NULL; DIDEVICEINSTANCEA ddi2; HRESULT hr; + IUnknown *iface, *tmp_iface;
hr = IDirectInput_GetDeviceStatus(data->pDI, &lpddi->guidInstance); ok(hr == DI_OK, "IDirectInput_GetDeviceStatus() failed: %08x\n", hr); @@ -227,6 +228,34 @@ static BOOL CALLBACK enum_devices(const DIDEVICEINSTANCEA *lpddi, void *pvRef) test_object_info(obj, data->hwnd); IUnknown_Release(obj);
+ hr = IUnknown_QueryInterface( device, &IID_IDirectInputDeviceA, (void **)&iface ); + ok( SUCCEEDED(hr), "IUnknown_QueryInterface(IID_IDirectInputDeviceA) failed: %08x\n", hr ); + hr = IUnknown_QueryInterface( device, &IID_IDirectInputDevice2A, (void **)&tmp_iface ); + ok( SUCCEEDED(hr), "IUnknown_QueryInterface(IID_IDirectInputDevice2A) failed: %08x\n", hr ); + ok( tmp_iface == iface, "IDirectInputDevice2A iface differs from IDirectInputDeviceA\n" ); + IUnknown_Release( tmp_iface ); + hr = IUnknown_QueryInterface( device, &IID_IDirectInputDevice7A, (void **)&tmp_iface ); + ok( SUCCEEDED(hr), "IUnknown_QueryInterface(IID_IDirectInputDevice7A) failed: %08x\n", hr ); + ok( tmp_iface == iface, "IDirectInputDevice7A iface differs from IDirectInputDeviceA\n" ); + IUnknown_Release( tmp_iface ); + IUnknown_Release( iface ); + + hr = IUnknown_QueryInterface( device, &IID_IUnknown, (void **)&iface ); + ok( SUCCEEDED(hr), "IUnknown_QueryInterface(IID_IUnknown) failed: %08x\n", hr ); + hr = IUnknown_QueryInterface( device, &IID_IDirectInputDeviceW, (void **)&tmp_iface ); + ok( SUCCEEDED(hr), "IUnknown_QueryInterface(IID_IDirectInputDeviceW) failed: %08x\n", hr ); + ok( tmp_iface == iface, "IDirectInputDeviceW iface differs from IUnknown\n" ); + IUnknown_Release( tmp_iface ); + hr = IUnknown_QueryInterface( device, &IID_IDirectInputDevice2W, (void **)&tmp_iface ); + ok( SUCCEEDED(hr), "IUnknown_QueryInterface(IID_IDirectInputDevice2W) failed: %08x\n", hr ); + ok( tmp_iface == iface, "IDirectInputDevice2W iface differs from IUnknown\n" ); + IUnknown_Release( tmp_iface ); + hr = IUnknown_QueryInterface( device, &IID_IDirectInputDevice7W, (void **)&tmp_iface ); + ok( SUCCEEDED(hr), "IUnknown_QueryInterface(IID_IDirectInputDevice7W) failed: %08x\n", hr ); + ok( tmp_iface == iface, "IDirectInputDevice7W iface differs from IUnknown\n" ); + IUnknown_Release( tmp_iface ); + IUnknown_Release( iface ); + IUnknown_Release(device);
if (!IsEqualGUID(&lpddi->guidInstance, &lpddi->guidProduct))