To make it more likely it gets focused on X11 and fix spurious failures.
Signed-off-by: Rémi Bernon rbernon@codeweavers.com ---
This is the first part of a refactoring series to wrap ANSI interfaces around the unicode interfaces in a generic and more consistent way.
Right now simple wrappers exists, at different levels, sometimes duplicated between the generic device base and specializations.
The goal is mostly to cleanup the code but also eventually simplify the implementation of an HID joystick device.
dlls/dinput/tests/mouse.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+)
diff --git a/dlls/dinput/tests/mouse.c b/dlls/dinput/tests/mouse.c index 2e0b8cdf2e9..69051bb2a34 100644 --- a/dlls/dinput/tests/mouse.c +++ b/dlls/dinput/tests/mouse.c @@ -48,6 +48,21 @@ static const HRESULT SetCoop_child_window[16] = { E_INVALIDARG, E_HANDLE, E_HANDLE, E_INVALIDARG, E_INVALIDARG, E_INVALIDARG, E_INVALIDARG, E_INVALIDARG};
+static void flush_events(void) +{ + MSG msg; + int diff = 200; + int min_timeout = 100; + DWORD time = GetTickCount() + diff; + + while (diff > 0) + { + if (MsgWaitForMultipleObjects( 0, NULL, FALSE, min_timeout, QS_ALLINPUT ) == WAIT_TIMEOUT) break; + while (PeekMessageA( &msg, 0, 0, 0, PM_REMOVE )) DispatchMessageA( &msg ); + diff = time - GetTickCount(); + } +} + static void test_set_coop(IDirectInputA *pDI, HWND hwnd) { HRESULT hr; @@ -131,6 +146,7 @@ static void test_acquire(IDirectInputA *pDI, HWND hwnd) hwnd2 = CreateWindowA("static", "Temporary", WS_VISIBLE, 10, 210, 200, 200, NULL, NULL, NULL, NULL); ok(hwnd2 != NULL, "CreateWindowA failed with %u\n", GetLastError()); + flush_events();
hr = IDirectInputDevice_GetDeviceState(pMouse, sizeof(m_state), &m_state); ok(hr == DIERR_NOTACQUIRED, "GetDeviceState() should have failed: %08x\n", hr);
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))
Signed-off-by: Rémi Bernon rbernon@codeweavers.com --- dlls/dinput/device.c | 20 ++++----- dlls/dinput/joystick.c | 18 -------- dlls/dinput/joystick_linux.c | 33 +++----------- dlls/dinput/joystick_linuxinput.c | 75 ++++--------------------------- dlls/dinput/joystick_osx.c | 61 +++---------------------- dlls/dinput/joystick_private.h | 3 -- dlls/dinput/keyboard.c | 17 +------ dlls/dinput/mouse.c | 33 ++------------ 8 files changed, 35 insertions(+), 225 deletions(-)
diff --git a/dlls/dinput/device.c b/dlls/dinput/device.c index c645e033677..d1c198d1807 100644 --- a/dlls/dinput/device.c +++ b/dlls/dinput/device.c @@ -1070,7 +1070,7 @@ HRESULT WINAPI IDirectInputDevice2WImpl_Acquire(LPDIRECTINPUTDEVICE8W iface) HRESULT WINAPI IDirectInputDevice2AImpl_Acquire(LPDIRECTINPUTDEVICE8A iface) { IDirectInputDeviceImpl *This = impl_from_IDirectInputDevice8A(iface); - return IDirectInputDevice2WImpl_Acquire(IDirectInputDevice8W_from_impl(This)); + return IDirectInputDevice_Acquire(IDirectInputDevice8W_from_impl(This)); }
@@ -1100,7 +1100,7 @@ HRESULT WINAPI IDirectInputDevice2WImpl_Unacquire(LPDIRECTINPUTDEVICE8W iface) HRESULT WINAPI IDirectInputDevice2AImpl_Unacquire(LPDIRECTINPUTDEVICE8A iface) { IDirectInputDeviceImpl *This = impl_from_IDirectInputDevice8A(iface); - return IDirectInputDevice2WImpl_Unacquire(IDirectInputDevice8W_from_impl(This)); + return IDirectInputDevice_Unacquire(IDirectInputDevice8W_from_impl(This)); }
/****************************************************************************** @@ -1417,7 +1417,7 @@ HRESULT WINAPI IDirectInputDevice2WImpl_GetProperty(LPDIRECTINPUTDEVICE8W iface, HRESULT WINAPI IDirectInputDevice2AImpl_GetProperty(LPDIRECTINPUTDEVICE8A iface, REFGUID rguid, LPDIPROPHEADER pdiph) { IDirectInputDeviceImpl *This = impl_from_IDirectInputDevice8A(iface); - return IDirectInputDevice2WImpl_GetProperty(IDirectInputDevice8W_from_impl(This), rguid, pdiph); + return IDirectInputDevice_GetProperty(IDirectInputDevice8W_from_impl(This), rguid, pdiph); }
/****************************************************************************** @@ -1534,7 +1534,7 @@ HRESULT WINAPI IDirectInputDevice2AImpl_SetProperty( LPDIRECTINPUTDEVICE8A iface, REFGUID rguid, LPCDIPROPHEADER pdiph) { IDirectInputDeviceImpl *This = impl_from_IDirectInputDevice8A(iface); - return IDirectInputDevice2WImpl_SetProperty(IDirectInputDevice8W_from_impl(This), rguid, pdiph); + return IDirectInputDevice_SetProperty(IDirectInputDevice8W_from_impl(This), rguid, pdiph); }
HRESULT WINAPI IDirectInputDevice2AImpl_GetObjectInfo( @@ -1682,7 +1682,7 @@ HRESULT WINAPI IDirectInputDevice2AImpl_GetDeviceData(LPDIRECTINPUTDEVICE8A ifac LPDIDEVICEOBJECTDATA dod, LPDWORD entries, DWORD flags) { IDirectInputDeviceImpl *This = impl_from_IDirectInputDevice8A(iface); - return IDirectInputDevice2WImpl_GetDeviceData(IDirectInputDevice8W_from_impl(This), dodsize, dod, entries, flags); + return IDirectInputDevice_GetDeviceData(IDirectInputDevice8W_from_impl(This), dodsize, dod, entries, flags); }
HRESULT WINAPI IDirectInputDevice2WImpl_RunControlPanel(LPDIRECTINPUTDEVICE8W iface, HWND hwndOwner, DWORD dwFlags) @@ -1733,7 +1733,7 @@ HRESULT WINAPI IDirectInputDevice2AImpl_CreateEffect(LPDIRECTINPUTDEVICE8A iface LPDIRECTINPUTEFFECT *ppdef, LPUNKNOWN pUnkOuter) { IDirectInputDeviceImpl *This = impl_from_IDirectInputDevice8A(iface); - return IDirectInputDevice2WImpl_CreateEffect(IDirectInputDevice8W_from_impl(This), rguid, lpeff, ppdef, pUnkOuter); + return IDirectInputDevice2_CreateEffect(IDirectInputDevice8W_from_impl(This), rguid, lpeff, ppdef, pUnkOuter); }
HRESULT WINAPI IDirectInputDevice2AImpl_EnumEffects( @@ -1790,7 +1790,7 @@ HRESULT WINAPI IDirectInputDevice2WImpl_GetForceFeedbackState(LPDIRECTINPUTDEVIC HRESULT WINAPI IDirectInputDevice2AImpl_GetForceFeedbackState(LPDIRECTINPUTDEVICE8A iface, LPDWORD pdwOut) { IDirectInputDeviceImpl *This = impl_from_IDirectInputDevice8A(iface); - return IDirectInputDevice2WImpl_GetForceFeedbackState(IDirectInputDevice8W_from_impl(This), pdwOut); + return IDirectInputDevice2_GetForceFeedbackState(IDirectInputDevice8W_from_impl(This), pdwOut); }
HRESULT WINAPI IDirectInputDevice2WImpl_SendForceFeedbackCommand(LPDIRECTINPUTDEVICE8W iface, DWORD dwFlags) @@ -1803,7 +1803,7 @@ HRESULT WINAPI IDirectInputDevice2WImpl_SendForceFeedbackCommand(LPDIRECTINPUTDE HRESULT WINAPI IDirectInputDevice2AImpl_SendForceFeedbackCommand(LPDIRECTINPUTDEVICE8A iface, DWORD dwFlags) { IDirectInputDeviceImpl *This = impl_from_IDirectInputDevice8A(iface); - return IDirectInputDevice2WImpl_SendForceFeedbackCommand(IDirectInputDevice8W_from_impl(This), dwFlags); + return IDirectInputDevice2_SendForceFeedbackCommand(IDirectInputDevice8W_from_impl(This), dwFlags); }
HRESULT WINAPI IDirectInputDevice2WImpl_EnumCreatedEffectObjects(LPDIRECTINPUTDEVICE8W iface, @@ -1818,7 +1818,7 @@ HRESULT WINAPI IDirectInputDevice2AImpl_EnumCreatedEffectObjects(LPDIRECTINPUTDE LPDIENUMCREATEDEFFECTOBJECTSCALLBACK lpCallback, LPVOID lpvRef, DWORD dwFlags) { IDirectInputDeviceImpl *This = impl_from_IDirectInputDevice8A(iface); - return IDirectInputDevice2WImpl_EnumCreatedEffectObjects(IDirectInputDevice8W_from_impl(This), lpCallback, lpvRef, dwFlags); + return IDirectInputDevice2_EnumCreatedEffectObjects(IDirectInputDevice8W_from_impl(This), lpCallback, lpvRef, dwFlags); }
HRESULT WINAPI IDirectInputDevice2WImpl_Escape(LPDIRECTINPUTDEVICE8W iface, LPDIEFFESCAPE lpDIEEsc) @@ -1847,7 +1847,7 @@ HRESULT WINAPI IDirectInputDevice2WImpl_Poll(LPDIRECTINPUTDEVICE8W iface) HRESULT WINAPI IDirectInputDevice2AImpl_Poll(LPDIRECTINPUTDEVICE8A iface) { IDirectInputDeviceImpl *This = impl_from_IDirectInputDevice8A(iface); - return IDirectInputDevice2WImpl_Poll(IDirectInputDevice8W_from_impl(This)); + return IDirectInputDevice2_Poll(IDirectInputDevice8W_from_impl(This)); }
HRESULT WINAPI IDirectInputDevice2WImpl_SendDeviceData(LPDIRECTINPUTDEVICE8W iface, DWORD cbObjectData, diff --git a/dlls/dinput/joystick.c b/dlls/dinput/joystick.c index 68428ac0ddd..3749eed7efe 100644 --- a/dlls/dinput/joystick.c +++ b/dlls/dinput/joystick.c @@ -467,12 +467,6 @@ HRESULT WINAPI JoystickWGenericImpl_SetProperty(LPDIRECTINPUTDEVICE8W iface, REF return DI_OK; }
-HRESULT WINAPI JoystickAGenericImpl_SetProperty(LPDIRECTINPUTDEVICE8A iface, REFGUID rguid, LPCDIPROPHEADER ph) -{ - JoystickGenericImpl *This = impl_from_IDirectInputDevice8A(iface); - return JoystickWGenericImpl_SetProperty(IDirectInputDevice8W_from_impl(This), rguid, ph); -} - #define DEBUG_TYPE(x) case (x): str = #x; break void _dump_DIDEVCAPS(const DIDEVCAPS *lpDIDevCaps) { @@ -674,12 +668,6 @@ HRESULT WINAPI JoystickWGenericImpl_GetProperty(LPDIRECTINPUTDEVICE8W iface, REF return DI_OK; }
-HRESULT WINAPI JoystickAGenericImpl_GetProperty(LPDIRECTINPUTDEVICE8A iface, REFGUID rguid, LPDIPROPHEADER pdiph) -{ - JoystickGenericImpl *This = impl_from_IDirectInputDevice8A(iface); - return JoystickWGenericImpl_GetProperty(IDirectInputDevice8W_from_impl(This), rguid, pdiph); -} - /****************************************************************************** * GetDeviceInfo : get information about a device's identity */ @@ -788,12 +776,6 @@ HRESULT WINAPI JoystickWGenericImpl_Poll(LPDIRECTINPUTDEVICE8W iface) return DI_OK; }
-HRESULT WINAPI JoystickAGenericImpl_Poll(LPDIRECTINPUTDEVICE8A iface) -{ - JoystickGenericImpl *This = impl_from_IDirectInputDevice8A(iface); - return JoystickWGenericImpl_Poll(IDirectInputDevice8W_from_impl(This)); -} - /****************************************************************************** * GetDeviceState : returns the "state" of the joystick. * diff --git a/dlls/dinput/joystick_linux.c b/dlls/dinput/joystick_linux.c index ee7ad53db11..ec4cb94c034 100644 --- a/dlls/dinput/joystick_linux.c +++ b/dlls/dinput/joystick_linux.c @@ -114,11 +114,6 @@ static inline JoystickImpl *impl_from_IDirectInputDevice8W(IDirectInputDevice8W JoystickGenericImpl, base), JoystickImpl, generic); }
-static inline IDirectInputDevice8W *IDirectInputDevice8W_from_impl(JoystickImpl *This) -{ - return &This->generic.base.IDirectInputDevice8W_iface; -} - static const GUID DInput_Wine_Joystick_GUID = { /* 9e573ed9-7734-11d2-8d4a-23903fb6bdf7 */ 0x9e573ed9, 0x7734, @@ -703,12 +698,6 @@ static HRESULT WINAPI JoystickLinuxWImpl_Acquire(LPDIRECTINPUTDEVICE8W iface) return DI_OK; }
-static HRESULT WINAPI JoystickLinuxAImpl_Acquire(LPDIRECTINPUTDEVICE8A iface) -{ - JoystickImpl *This = impl_from_IDirectInputDevice8A(iface); - return JoystickLinuxWImpl_Acquire(IDirectInputDevice8W_from_impl(This)); -} - /****************************************************************************** * GetProperty : get input device properties */ @@ -772,12 +761,6 @@ static HRESULT WINAPI JoystickLinuxWImpl_GetProperty(LPDIRECTINPUTDEVICE8W iface return DI_OK; }
-static HRESULT WINAPI JoystickLinuxAImpl_GetProperty(LPDIRECTINPUTDEVICE8A iface, REFGUID rguid, LPDIPROPHEADER pdiph) -{ - JoystickImpl *This = impl_from_IDirectInputDevice8A(iface); - return JoystickLinuxWImpl_GetProperty(IDirectInputDevice8W_from_impl(This), rguid, pdiph); -} - /****************************************************************************** * GetDeviceInfo : get information about a device's identity */ @@ -844,12 +827,6 @@ static HRESULT WINAPI JoystickLinuxWImpl_Unacquire(LPDIRECTINPUTDEVICE8W iface) return DI_NOEFFECT; }
-static HRESULT WINAPI JoystickLinuxAImpl_Unacquire(LPDIRECTINPUTDEVICE8A iface) -{ - JoystickImpl *This = impl_from_IDirectInputDevice8A(iface); - return JoystickLinuxWImpl_Unacquire(IDirectInputDevice8W_from_impl(This)); -} - static void joy_polldev( IDirectInputDevice8W *iface ) { struct pollfd plfd; @@ -932,10 +909,10 @@ static const IDirectInputDevice8AVtbl JoystickAvt = IDirectInputDevice2AImpl_Release, JoystickAGenericImpl_GetCapabilities, IDirectInputDevice2AImpl_EnumObjects, - JoystickLinuxAImpl_GetProperty, - JoystickAGenericImpl_SetProperty, - JoystickLinuxAImpl_Acquire, - JoystickLinuxAImpl_Unacquire, + IDirectInputDevice2AImpl_GetProperty, + IDirectInputDevice2AImpl_SetProperty, + IDirectInputDevice2AImpl_Acquire, + IDirectInputDevice2AImpl_Unacquire, JoystickAGenericImpl_GetDeviceState, IDirectInputDevice2AImpl_GetDeviceData, IDirectInputDevice2AImpl_SetDataFormat, @@ -952,7 +929,7 @@ static const IDirectInputDevice8AVtbl JoystickAvt = IDirectInputDevice2AImpl_SendForceFeedbackCommand, IDirectInputDevice2AImpl_EnumCreatedEffectObjects, IDirectInputDevice2AImpl_Escape, - JoystickAGenericImpl_Poll, + IDirectInputDevice2AImpl_Poll, IDirectInputDevice2AImpl_SendDeviceData, IDirectInputDevice7AImpl_EnumEffectsInFile, IDirectInputDevice7AImpl_WriteEffectToFile, diff --git a/dlls/dinput/joystick_linuxinput.c b/dlls/dinput/joystick_linuxinput.c index b3ad195bbef..14acbb5cd8c 100644 --- a/dlls/dinput/joystick_linuxinput.c +++ b/dlls/dinput/joystick_linuxinput.c @@ -148,11 +148,6 @@ static inline JoystickImpl *impl_from_IDirectInputDevice8W(IDirectInputDevice8W JoystickGenericImpl, base), JoystickImpl, generic); }
-static inline IDirectInputDevice8W *IDirectInputDevice8W_from_impl(JoystickImpl *This) -{ - return &This->generic.base.IDirectInputDevice8W_iface; -} - static void fake_current_js_state(JoystickImpl *ji); static void find_joydevs(void); static void joy_polldev( IDirectInputDevice8W *iface ); @@ -741,12 +736,6 @@ static HRESULT WINAPI JoystickWImpl_Acquire(LPDIRECTINPUTDEVICE8W iface) return DI_OK; }
-static HRESULT WINAPI JoystickAImpl_Acquire(LPDIRECTINPUTDEVICE8A iface) -{ - JoystickImpl *This = impl_from_IDirectInputDevice8A(iface); - return JoystickWImpl_Acquire(IDirectInputDevice8W_from_impl(This)); -} - /****************************************************************************** * Unacquire : frees the joystick */ @@ -779,12 +768,6 @@ static HRESULT WINAPI JoystickWImpl_Unacquire(LPDIRECTINPUTDEVICE8W iface) return res; }
-static HRESULT WINAPI JoystickAImpl_Unacquire(LPDIRECTINPUTDEVICE8A iface) -{ - JoystickImpl *This = impl_from_IDirectInputDevice8A(iface); - return JoystickWImpl_Unacquire(IDirectInputDevice8W_from_impl(This)); -} - /* * set the current state of the js device as it would be with the middle * values on the axes @@ -966,12 +949,6 @@ static HRESULT WINAPI JoystickWImpl_SetProperty(LPDIRECTINPUTDEVICE8W iface, REF return DI_OK; }
-static HRESULT WINAPI JoystickAImpl_SetProperty(LPDIRECTINPUTDEVICE8A iface, REFGUID rguid, LPCDIPROPHEADER ph) -{ - JoystickImpl *This = impl_from_IDirectInputDevice8A(iface); - return JoystickWImpl_SetProperty(IDirectInputDevice8W_from_impl(This), rguid, ph); -} - /****************************************************************************** * GetProperty : get input device properties */ @@ -1052,12 +1029,6 @@ static HRESULT WINAPI JoystickWImpl_GetProperty(LPDIRECTINPUTDEVICE8W iface, REF return DI_OK; }
-static HRESULT WINAPI JoystickAImpl_GetProperty(LPDIRECTINPUTDEVICE8A iface, REFGUID rguid, LPDIPROPHEADER pdiph) -{ - JoystickImpl *This = impl_from_IDirectInputDevice8A(iface); - return JoystickWImpl_GetProperty(IDirectInputDevice8W_from_impl(This), rguid, pdiph); -} - /****************************************************************************** * CreateEffect - Create a new FF effect with the specified params */ @@ -1120,14 +1091,6 @@ static HRESULT WINAPI JoystickWImpl_CreateEffect(LPDIRECTINPUTDEVICE8W iface, RE #endif /* HAVE_STRUCT_FF_EFFECT_DIRECTION */ }
-static HRESULT WINAPI JoystickAImpl_CreateEffect(LPDIRECTINPUTDEVICE8A iface, REFGUID rguid, - LPCDIEFFECT lpeff, LPDIRECTINPUTEFFECT *ppdef, - LPUNKNOWN pUnkOuter) -{ - JoystickImpl *This = impl_from_IDirectInputDevice8A(iface); - return JoystickWImpl_CreateEffect(IDirectInputDevice8W_from_impl(This), rguid, lpeff, ppdef, pUnkOuter); -} - /******************************************************************************* * EnumEffects - Enumerate available FF effects */ @@ -1338,12 +1301,6 @@ static HRESULT WINAPI JoystickWImpl_GetForceFeedbackState(LPDIRECTINPUTDEVICE8W return DI_OK; }
-static HRESULT WINAPI JoystickAImpl_GetForceFeedbackState(LPDIRECTINPUTDEVICE8A iface, LPDWORD pdwOut) -{ - JoystickImpl *This = impl_from_IDirectInputDevice8A(iface); - return JoystickWImpl_GetForceFeedbackState(IDirectInputDevice8W_from_impl(This), pdwOut); -} - /******************************************************************************* * SendForceFeedbackCommand - Send a command to the device's FF system */ @@ -1397,12 +1354,6 @@ static HRESULT WINAPI JoystickWImpl_SendForceFeedbackCommand(LPDIRECTINPUTDEVICE #endif }
-static HRESULT WINAPI JoystickAImpl_SendForceFeedbackCommand(LPDIRECTINPUTDEVICE8A iface, DWORD dwFlags) -{ - JoystickImpl *This = impl_from_IDirectInputDevice8A(iface); - return JoystickWImpl_SendForceFeedbackCommand(IDirectInputDevice8W_from_impl(This), dwFlags); -} - /******************************************************************************* * EnumCreatedEffectObjects - Enumerate all the effects that have been * created for this device. @@ -1429,14 +1380,6 @@ static HRESULT WINAPI JoystickWImpl_EnumCreatedEffectObjects(LPDIRECTINPUTDEVICE return DI_OK; }
-static HRESULT WINAPI JoystickAImpl_EnumCreatedEffectObjects(LPDIRECTINPUTDEVICE8A iface, - LPDIENUMCREATEDEFFECTOBJECTSCALLBACK lpCallback, - LPVOID pvRef, DWORD dwFlags) -{ - JoystickImpl *This = impl_from_IDirectInputDevice8A(iface); - return JoystickWImpl_EnumCreatedEffectObjects(IDirectInputDevice8W_from_impl(This), lpCallback, pvRef, dwFlags); -} - /****************************************************************************** * GetDeviceInfo : get information about a device's identity */ @@ -1487,10 +1430,10 @@ static const IDirectInputDevice8AVtbl JoystickAvt = IDirectInputDevice2AImpl_Release, JoystickAGenericImpl_GetCapabilities, IDirectInputDevice2AImpl_EnumObjects, - JoystickAImpl_GetProperty, - JoystickAImpl_SetProperty, - JoystickAImpl_Acquire, - JoystickAImpl_Unacquire, + IDirectInputDevice2AImpl_GetProperty, + IDirectInputDevice2AImpl_SetProperty, + IDirectInputDevice2AImpl_Acquire, + IDirectInputDevice2AImpl_Unacquire, JoystickAGenericImpl_GetDeviceState, IDirectInputDevice2AImpl_GetDeviceData, IDirectInputDevice2AImpl_SetDataFormat, @@ -1500,14 +1443,14 @@ static const IDirectInputDevice8AVtbl JoystickAvt = JoystickAImpl_GetDeviceInfo, IDirectInputDevice2AImpl_RunControlPanel, IDirectInputDevice2AImpl_Initialize, - JoystickAImpl_CreateEffect, + IDirectInputDevice2AImpl_CreateEffect, JoystickAImpl_EnumEffects, JoystickAImpl_GetEffectInfo, - JoystickAImpl_GetForceFeedbackState, - JoystickAImpl_SendForceFeedbackCommand, - JoystickAImpl_EnumCreatedEffectObjects, + IDirectInputDevice2AImpl_GetForceFeedbackState, + IDirectInputDevice2AImpl_SendForceFeedbackCommand, + IDirectInputDevice2AImpl_EnumCreatedEffectObjects, IDirectInputDevice2AImpl_Escape, - JoystickAGenericImpl_Poll, + IDirectInputDevice2AImpl_Poll, IDirectInputDevice2AImpl_SendDeviceData, IDirectInputDevice7AImpl_EnumEffectsInFile, IDirectInputDevice7AImpl_WriteEffectToFile, diff --git a/dlls/dinput/joystick_osx.c b/dlls/dinput/joystick_osx.c index a2f9e936746..174a78b7fd4 100644 --- a/dlls/dinput/joystick_osx.c +++ b/dlls/dinput/joystick_osx.c @@ -127,11 +127,6 @@ static inline JoystickImpl *impl_from_IDirectInputDevice8W(IDirectInputDevice8W JoystickGenericImpl, base), JoystickImpl, generic); }
-static inline IDirectInputDevice8W *IDirectInputDevice8W_from_impl(JoystickImpl *This) -{ - return &This->generic.base.IDirectInputDevice8W_iface; -} - typedef struct _EffectImpl { IDirectInputEffect IDirectInputEffect_iface; LONG ref; @@ -1444,12 +1439,6 @@ static HRESULT WINAPI JoystickWImpl_GetProperty(LPDIRECTINPUTDEVICE8W iface, REF return DI_OK; }
-static HRESULT WINAPI JoystickAImpl_GetProperty(LPDIRECTINPUTDEVICE8A iface, REFGUID rguid, LPDIPROPHEADER pdiph) -{ - JoystickImpl *This = impl_from_IDirectInputDevice8A(iface); - return JoystickWImpl_GetProperty(IDirectInputDevice8W_from_impl(This), rguid, pdiph); -} - static HRESULT osx_set_autocenter(JoystickImpl *This, const DIPROPDWORD *header) { @@ -1493,24 +1482,6 @@ static HRESULT WINAPI JoystickWImpl_SetProperty(IDirectInputDevice8W *iface, return JoystickWGenericImpl_SetProperty(iface, prop, header); }
-static HRESULT WINAPI JoystickAImpl_SetProperty(IDirectInputDevice8A *iface, - const GUID *prop, const DIPROPHEADER *header) -{ - JoystickImpl *This = impl_from_IDirectInputDevice8A(iface); - - TRACE("%p %s %p\n", This, debugstr_guid(prop), header); - - switch(LOWORD(prop)) - { - case (DWORD_PTR)DIPROP_AUTOCENTER: - return osx_set_autocenter(This, (const DIPROPDWORD *)header); - case (DWORD_PTR)DIPROP_FFGAIN: - return osx_set_ffgain(This, (const DIPROPDWORD *)header); - } - - return JoystickAGenericImpl_SetProperty(iface, prop, header); -} - static CFUUIDRef effect_win_to_mac(const GUID *effect) { #define DO_MAP(X) \ @@ -1576,18 +1547,6 @@ static HRESULT WINAPI JoystickWImpl_CreateEffect(IDirectInputDevice8W *iface, return S_OK; }
-static HRESULT WINAPI JoystickAImpl_CreateEffect(IDirectInputDevice8A *iface, - const GUID *type, const DIEFFECT *params, IDirectInputEffect **out, - IUnknown *outer) -{ - JoystickImpl *This = impl_from_IDirectInputDevice8A(iface); - - TRACE("(%p)->(%s %p %p %p)\n", This, debugstr_guid(type), params, out, outer); - - return JoystickWImpl_CreateEffect(&This->generic.base.IDirectInputDevice8W_iface, - type, params, out, outer); -} - static HRESULT WINAPI JoystickWImpl_SendForceFeedbackCommand(IDirectInputDevice8W *iface, DWORD flags) { @@ -1608,16 +1567,6 @@ static HRESULT WINAPI JoystickWImpl_SendForceFeedbackCommand(IDirectInputDevice8 return S_OK; }
-static HRESULT WINAPI JoystickAImpl_SendForceFeedbackCommand(IDirectInputDevice8A *iface, - DWORD flags) -{ - JoystickImpl *This = impl_from_IDirectInputDevice8A(iface); - - TRACE("%p 0x%x\n", This, flags); - - return JoystickWImpl_SendForceFeedbackCommand(&This->generic.base.IDirectInputDevice8W_iface, flags); -} - const struct dinput_device joystick_osx_device = { "Wine OS X joystick driver", joydev_enum_deviceA, @@ -1632,8 +1581,8 @@ static const IDirectInputDevice8AVtbl JoystickAvt = IDirectInputDevice2AImpl_Release, JoystickAGenericImpl_GetCapabilities, IDirectInputDevice2AImpl_EnumObjects, - JoystickAImpl_GetProperty, - JoystickAImpl_SetProperty, + IDirectInputDevice2AImpl_GetProperty, + IDirectInputDevice2AImpl_SetProperty, IDirectInputDevice2AImpl_Acquire, IDirectInputDevice2AImpl_Unacquire, JoystickAGenericImpl_GetDeviceState, @@ -1645,14 +1594,14 @@ static const IDirectInputDevice8AVtbl JoystickAvt = JoystickAGenericImpl_GetDeviceInfo, IDirectInputDevice2AImpl_RunControlPanel, IDirectInputDevice2AImpl_Initialize, - JoystickAImpl_CreateEffect, + IDirectInputDevice2AImpl_CreateEffect, IDirectInputDevice2AImpl_EnumEffects, IDirectInputDevice2AImpl_GetEffectInfo, IDirectInputDevice2AImpl_GetForceFeedbackState, - JoystickAImpl_SendForceFeedbackCommand, + IDirectInputDevice2AImpl_SendForceFeedbackCommand, IDirectInputDevice2AImpl_EnumCreatedEffectObjects, IDirectInputDevice2AImpl_Escape, - JoystickAGenericImpl_Poll, + IDirectInputDevice2AImpl_Poll, IDirectInputDevice2AImpl_SendDeviceData, IDirectInputDevice7AImpl_EnumEffectsInFile, IDirectInputDevice7AImpl_WriteEffectToFile, diff --git a/dlls/dinput/joystick_private.h b/dlls/dinput/joystick_private.h index ae382047fb4..0f191787158 100644 --- a/dlls/dinput/joystick_private.h +++ b/dlls/dinput/joystick_private.h @@ -65,7 +65,6 @@ HRESULT WINAPI JoystickWGenericImpl_GetObjectInfo(LPDIRECTINPUTDEVICE8W iface, HRESULT WINAPI JoystickAGenericImpl_GetObjectInfo(LPDIRECTINPUTDEVICE8A iface, LPDIDEVICEOBJECTINSTANCEA pdidoi, DWORD dwObj, DWORD dwHow) DECLSPEC_HIDDEN;
-HRESULT WINAPI JoystickAGenericImpl_GetProperty(LPDIRECTINPUTDEVICE8A iface, REFGUID rguid, LPDIPROPHEADER pdiph) DECLSPEC_HIDDEN; HRESULT WINAPI JoystickWGenericImpl_GetProperty(LPDIRECTINPUTDEVICE8W iface, REFGUID rguid, LPDIPROPHEADER pdiph) DECLSPEC_HIDDEN;
HRESULT WINAPI JoystickAGenericImpl_GetCapabilities(LPDIRECTINPUTDEVICE8A iface, LPDIDEVCAPS lpDIDevCaps) DECLSPEC_HIDDEN; @@ -73,7 +72,6 @@ HRESULT WINAPI JoystickWGenericImpl_GetCapabilities(LPDIRECTINPUTDEVICE8W iface,
void _dump_DIDEVCAPS(const DIDEVCAPS *lpDIDevCaps) DECLSPEC_HIDDEN;
-HRESULT WINAPI JoystickAGenericImpl_SetProperty(LPDIRECTINPUTDEVICE8A iface, REFGUID rguid, LPCDIPROPHEADER ph) DECLSPEC_HIDDEN; HRESULT WINAPI JoystickWGenericImpl_SetProperty(LPDIRECTINPUTDEVICE8W iface, REFGUID rguid, LPCDIPROPHEADER ph) DECLSPEC_HIDDEN;
HRESULT WINAPI JoystickAGenericImpl_GetDeviceInfo( LPDIRECTINPUTDEVICE8A iface, @@ -82,7 +80,6 @@ HRESULT WINAPI JoystickAGenericImpl_GetDeviceInfo( LPDIRECTINPUTDEVICE8A iface, HRESULT WINAPI JoystickWGenericImpl_GetDeviceInfo( LPDIRECTINPUTDEVICE8W iface, LPDIDEVICEINSTANCEW pdidi) DECLSPEC_HIDDEN;
-HRESULT WINAPI JoystickAGenericImpl_Poll(LPDIRECTINPUTDEVICE8A iface) DECLSPEC_HIDDEN; HRESULT WINAPI JoystickWGenericImpl_Poll(LPDIRECTINPUTDEVICE8W iface) DECLSPEC_HIDDEN;
HRESULT WINAPI JoystickAGenericImpl_GetDeviceState(LPDIRECTINPUTDEVICE8A iface, DWORD len, LPVOID ptr) DECLSPEC_HIDDEN; diff --git a/dlls/dinput/keyboard.c b/dlls/dinput/keyboard.c index 4a3606d2c43..ca3b1dad669 100644 --- a/dlls/dinput/keyboard.c +++ b/dlls/dinput/keyboard.c @@ -577,13 +577,6 @@ static HRESULT WINAPI SysKeyboardWImpl_GetProperty(LPDIRECTINPUTDEVICE8W iface, return DI_OK; }
-static HRESULT WINAPI SysKeyboardAImpl_GetProperty(LPDIRECTINPUTDEVICE8A iface, - REFGUID rguid, LPDIPROPHEADER pdiph) -{ - SysKeyboardImpl *This = impl_from_IDirectInputDevice8A(iface); - return SysKeyboardWImpl_GetProperty(IDirectInputDevice8W_from_impl(This), rguid, pdiph); -} - static HRESULT WINAPI SysKeyboardWImpl_Acquire(LPDIRECTINPUTDEVICE8W iface) { SysKeyboardImpl *This = impl_from_IDirectInputDevice8W(iface); @@ -601,12 +594,6 @@ static HRESULT WINAPI SysKeyboardWImpl_Acquire(LPDIRECTINPUTDEVICE8W iface) return res; }
-static HRESULT WINAPI SysKeyboardAImpl_Acquire(LPDIRECTINPUTDEVICE8A iface) -{ - SysKeyboardImpl *This = impl_from_IDirectInputDevice8A(iface); - return SysKeyboardWImpl_Acquire(IDirectInputDevice8W_from_impl(This)); -} - static HRESULT WINAPI SysKeyboardWImpl_BuildActionMap(LPDIRECTINPUTDEVICE8W iface, LPDIACTIONFORMATW lpdiaf, LPCWSTR lpszUserName, @@ -695,9 +682,9 @@ static const IDirectInputDevice8AVtbl SysKeyboardAvt = IDirectInputDevice2AImpl_Release, SysKeyboardAImpl_GetCapabilities, IDirectInputDevice2AImpl_EnumObjects, - SysKeyboardAImpl_GetProperty, + IDirectInputDevice2AImpl_GetProperty, IDirectInputDevice2AImpl_SetProperty, - SysKeyboardAImpl_Acquire, + IDirectInputDevice2AImpl_Acquire, IDirectInputDevice2AImpl_Unacquire, SysKeyboardAImpl_GetDeviceState, IDirectInputDevice2AImpl_GetDeviceData, diff --git a/dlls/dinput/mouse.c b/dlls/dinput/mouse.c index 46844ffa28d..65f173daa81 100644 --- a/dlls/dinput/mouse.c +++ b/dlls/dinput/mouse.c @@ -584,12 +584,6 @@ static HRESULT WINAPI SysMouseWImpl_Acquire(LPDIRECTINPUTDEVICE8W iface) return DI_OK; }
-static HRESULT WINAPI SysMouseAImpl_Acquire(LPDIRECTINPUTDEVICE8A iface) -{ - SysMouseImpl *This = impl_from_IDirectInputDevice8A(iface); - return SysMouseWImpl_Acquire(IDirectInputDevice8W_from_impl(This)); -} - /****************************************************************************** * Unacquire : frees the mouse */ @@ -619,12 +613,6 @@ static HRESULT WINAPI SysMouseWImpl_Unacquire(LPDIRECTINPUTDEVICE8W iface) return DI_OK; }
-static HRESULT WINAPI SysMouseAImpl_Unacquire(LPDIRECTINPUTDEVICE8A iface) -{ - SysMouseImpl *This = impl_from_IDirectInputDevice8A(iface); - return SysMouseWImpl_Unacquire(IDirectInputDevice8W_from_impl(This)); -} - /****************************************************************************** * GetDeviceState : returns the "state" of the mouse. * @@ -679,13 +667,6 @@ static HRESULT WINAPI SysMouseWImpl_GetDeviceData(LPDIRECTINPUTDEVICE8W iface, return res; }
-static HRESULT WINAPI SysMouseAImpl_GetDeviceData(LPDIRECTINPUTDEVICE8A iface, - DWORD dodsize, LPDIDEVICEOBJECTDATA dod, LPDWORD entries, DWORD flags) -{ - SysMouseImpl *This = impl_from_IDirectInputDevice8A(iface); - return SysMouseWImpl_GetDeviceData(IDirectInputDevice8W_from_impl(This), dodsize, dod, entries, flags); -} - /****************************************************************************** * GetProperty : get input device properties */ @@ -745,12 +726,6 @@ static HRESULT WINAPI SysMouseWImpl_GetProperty(LPDIRECTINPUTDEVICE8W iface, REF return DI_OK; }
-static HRESULT WINAPI SysMouseAImpl_GetProperty(LPDIRECTINPUTDEVICE8A iface, REFGUID rguid, LPDIPROPHEADER pdiph) -{ - SysMouseImpl *This = impl_from_IDirectInputDevice8A(iface); - return SysMouseWImpl_GetProperty(IDirectInputDevice8W_from_impl(This), rguid, pdiph); -} - /****************************************************************************** * GetCapabilities : get the device capabilities */ @@ -959,12 +934,12 @@ static const IDirectInputDevice8AVtbl SysMouseAvt = IDirectInputDevice2AImpl_Release, SysMouseAImpl_GetCapabilities, IDirectInputDevice2AImpl_EnumObjects, - SysMouseAImpl_GetProperty, + IDirectInputDevice2AImpl_GetProperty, IDirectInputDevice2AImpl_SetProperty, - SysMouseAImpl_Acquire, - SysMouseAImpl_Unacquire, + IDirectInputDevice2AImpl_Acquire, + IDirectInputDevice2AImpl_Unacquire, SysMouseAImpl_GetDeviceState, - SysMouseAImpl_GetDeviceData, + IDirectInputDevice2AImpl_GetDeviceData, IDirectInputDevice2AImpl_SetDataFormat, IDirectInputDevice2AImpl_SetEventNotification, IDirectInputDevice2AImpl_SetCooperativeLevel,
Signed-off-by: Rémi Bernon rbernon@codeweavers.com --- dlls/dinput/Makefile.in | 1 + dlls/dinput/ansi.c | 188 +++++++++++++++++++++++++++++++++++++++ dlls/dinput/device.c | 129 --------------------------- dlls/dinput8/Makefile.in | 1 + 4 files changed, 190 insertions(+), 129 deletions(-) create mode 100644 dlls/dinput/ansi.c
diff --git a/dlls/dinput/Makefile.in b/dlls/dinput/Makefile.in index ae65fd4d93e..a22c8a72180 100644 --- a/dlls/dinput/Makefile.in +++ b/dlls/dinput/Makefile.in @@ -5,6 +5,7 @@ EXTRADEFS = -DDIRECTINPUT_VERSION=0x0700 EXTRALIBS = $(IOKIT_LIBS) $(FORCEFEEDBACK_LIBS)
C_SRCS = \ + ansi.c \ config.c \ data_formats.c \ device.c \ diff --git a/dlls/dinput/ansi.c b/dlls/dinput/ansi.c new file mode 100644 index 00000000000..99156195423 --- /dev/null +++ b/dlls/dinput/ansi.c @@ -0,0 +1,188 @@ +/* + * Direct Input ANSI interface wrappers + * + * Copyright 2021 Rémi Bernon for CodeWeavers + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA + */ + +#include <stdarg.h> +#include <string.h> + +#include "windef.h" +#include "winbase.h" +#include "winreg.h" +#include "winuser.h" +#include "winerror.h" +#include "dinput.h" + +#include "device_private.h" +#include "dinput_private.h" + +#include "wine/debug.h" + +static IDirectInputDeviceImpl *impl_from_IDirectInputDevice8A( IDirectInputDevice8A *iface ) +{ + return CONTAINING_RECORD( iface, IDirectInputDeviceImpl, IDirectInputDevice8A_iface ); +} + +static IDirectInputDevice8W *IDirectInputDevice8W_from_impl( IDirectInputDeviceImpl *impl ) +{ + return &impl->IDirectInputDevice8W_iface; +} + +HRESULT WINAPI IDirectInputDevice2AImpl_QueryInterface( IDirectInputDevice8A *iface_a, REFIID iid, void **out ) +{ + IDirectInputDeviceImpl *impl = impl_from_IDirectInputDevice8A( iface_a ); + IDirectInputDevice8W *iface_w = IDirectInputDevice8W_from_impl( impl ); + return IDirectInputDevice8_QueryInterface( iface_w, iid, out ); +} + +ULONG WINAPI IDirectInputDevice2AImpl_AddRef( IDirectInputDevice8A *iface_a ) +{ + IDirectInputDeviceImpl *impl = impl_from_IDirectInputDevice8A( iface_a ); + IDirectInputDevice8W *iface_w = IDirectInputDevice8W_from_impl( impl ); + return IDirectInputDevice8_AddRef( iface_w ); +} + +ULONG WINAPI IDirectInputDevice2AImpl_Release( IDirectInputDevice8A *iface_a ) +{ + IDirectInputDeviceImpl *impl = impl_from_IDirectInputDevice8A( iface_a ); + IDirectInputDevice8W *iface_w = IDirectInputDevice8W_from_impl( impl ); + return IDirectInputDevice8_Release( iface_w ); +} + +HRESULT WINAPI IDirectInputDevice2AImpl_GetProperty( IDirectInputDevice8A *iface_a, REFGUID guid, DIPROPHEADER *header ) +{ + IDirectInputDeviceImpl *impl = impl_from_IDirectInputDevice8A( iface_a ); + IDirectInputDevice8W *iface_w = IDirectInputDevice8W_from_impl( impl ); + return IDirectInputDevice8_GetProperty( iface_w, guid, header ); +} + +HRESULT WINAPI IDirectInputDevice2AImpl_SetProperty( IDirectInputDevice8A *iface_a, REFGUID guid, const DIPROPHEADER *header ) +{ + IDirectInputDeviceImpl *impl = impl_from_IDirectInputDevice8A( iface_a ); + IDirectInputDevice8W *iface_w = IDirectInputDevice8W_from_impl( impl ); + return IDirectInputDevice8_SetProperty( iface_w, guid, header ); +} + +HRESULT WINAPI IDirectInputDevice2AImpl_Acquire( IDirectInputDevice8A *iface_a ) +{ + IDirectInputDeviceImpl *impl = impl_from_IDirectInputDevice8A( iface_a ); + IDirectInputDevice8W *iface_w = IDirectInputDevice8W_from_impl( impl ); + return IDirectInputDevice8_Acquire( iface_w ); +} + +HRESULT WINAPI IDirectInputDevice2AImpl_Unacquire( IDirectInputDevice8A *iface_a ) +{ + IDirectInputDeviceImpl *impl = impl_from_IDirectInputDevice8A( iface_a ); + IDirectInputDevice8W *iface_w = IDirectInputDevice8W_from_impl( impl ); + return IDirectInputDevice8_Unacquire( iface_w ); +} + +HRESULT WINAPI IDirectInputDevice2AImpl_GetDeviceData( IDirectInputDevice8A *iface_a, DWORD data_size, DIDEVICEOBJECTDATA *data, + DWORD *entries, DWORD flags ) +{ + IDirectInputDeviceImpl *impl = impl_from_IDirectInputDevice8A( iface_a ); + IDirectInputDevice8W *iface_w = IDirectInputDevice8W_from_impl( impl ); + return IDirectInputDevice8_GetDeviceData( iface_w, data_size, data, entries, flags ); +} + +HRESULT WINAPI IDirectInputDevice2AImpl_SetDataFormat( IDirectInputDevice8A *iface_a, const DIDATAFORMAT *format ) +{ + IDirectInputDeviceImpl *impl = impl_from_IDirectInputDevice8A( iface_a ); + IDirectInputDevice8W *iface_w = IDirectInputDevice8W_from_impl( impl ); + return IDirectInputDevice8_SetDataFormat( iface_w, format ); +} + +HRESULT WINAPI IDirectInputDevice2AImpl_SetEventNotification( IDirectInputDevice8A *iface_a, HANDLE event ) +{ + IDirectInputDeviceImpl *impl = impl_from_IDirectInputDevice8A( iface_a ); + IDirectInputDevice8W *iface_w = IDirectInputDevice8W_from_impl( impl ); + return IDirectInputDevice8_SetEventNotification( iface_w, event ); +} + +HRESULT WINAPI IDirectInputDevice2AImpl_SetCooperativeLevel( IDirectInputDevice8A *iface_a, HWND window, DWORD flags ) +{ + IDirectInputDeviceImpl *impl = impl_from_IDirectInputDevice8A( iface_a ); + IDirectInputDevice8W *iface_w = IDirectInputDevice8W_from_impl( impl ); + return IDirectInputDevice8_SetCooperativeLevel( iface_w, window, flags ); +} + +HRESULT WINAPI IDirectInputDevice2AImpl_RunControlPanel( IDirectInputDevice8A *iface_a, HWND owner, DWORD flags ) +{ + IDirectInputDeviceImpl *impl = impl_from_IDirectInputDevice8A( iface_a ); + IDirectInputDevice8W *iface_w = IDirectInputDevice8W_from_impl( impl ); + return IDirectInputDevice8_RunControlPanel( iface_w, owner, flags ); +} + +HRESULT WINAPI IDirectInputDevice2AImpl_Initialize( IDirectInputDevice8A *iface_a, HINSTANCE instance, DWORD version, REFGUID guid ) +{ + IDirectInputDeviceImpl *impl = impl_from_IDirectInputDevice8A( iface_a ); + IDirectInputDevice8W *iface_w = IDirectInputDevice8W_from_impl( impl ); + return IDirectInputDevice8_Initialize( iface_w, instance, version, guid ); +} + +HRESULT WINAPI IDirectInputDevice2AImpl_CreateEffect( IDirectInputDevice8A *iface_a, REFGUID guid, const DIEFFECT *effect, + IDirectInputEffect **out, IUnknown *outer ) +{ + IDirectInputDeviceImpl *impl = impl_from_IDirectInputDevice8A( iface_a ); + IDirectInputDevice8W *iface_w = IDirectInputDevice8W_from_impl( impl ); + return IDirectInputDevice8_CreateEffect( iface_w, guid, effect, out, outer ); +} + +HRESULT WINAPI IDirectInputDevice2AImpl_GetForceFeedbackState( IDirectInputDevice8A *iface_a, DWORD *state ) +{ + IDirectInputDeviceImpl *impl = impl_from_IDirectInputDevice8A( iface_a ); + IDirectInputDevice8W *iface_w = IDirectInputDevice8W_from_impl( impl ); + return IDirectInputDevice8_GetForceFeedbackState( iface_w, state ); +} + +HRESULT WINAPI IDirectInputDevice2AImpl_SendForceFeedbackCommand( IDirectInputDevice8A *iface_a, DWORD flags ) +{ + IDirectInputDeviceImpl *impl = impl_from_IDirectInputDevice8A( iface_a ); + IDirectInputDevice8W *iface_w = IDirectInputDevice8W_from_impl( impl ); + return IDirectInputDevice8_SendForceFeedbackCommand( iface_w, flags ); +} + +HRESULT WINAPI IDirectInputDevice2AImpl_EnumCreatedEffectObjects( IDirectInputDevice8A *iface_a, LPDIENUMCREATEDEFFECTOBJECTSCALLBACK callback, + void *ref, DWORD flags ) +{ + IDirectInputDeviceImpl *impl = impl_from_IDirectInputDevice8A( iface_a ); + IDirectInputDevice8W *iface_w = IDirectInputDevice8W_from_impl( impl ); + return IDirectInputDevice8_EnumCreatedEffectObjects( iface_w, callback, ref, flags ); +} + +HRESULT WINAPI IDirectInputDevice2AImpl_Escape( IDirectInputDevice8A *iface_a, DIEFFESCAPE *escape ) +{ + IDirectInputDeviceImpl *impl = impl_from_IDirectInputDevice8A( iface_a ); + IDirectInputDevice8W *iface_w = IDirectInputDevice8W_from_impl( impl ); + return IDirectInputDevice8_Escape( iface_w, escape ); +} + +HRESULT WINAPI IDirectInputDevice2AImpl_Poll( IDirectInputDevice8A *iface_a ) +{ + IDirectInputDeviceImpl *impl = impl_from_IDirectInputDevice8A( iface_a ); + IDirectInputDevice8W *iface_w = IDirectInputDevice8W_from_impl( impl ); + return IDirectInputDevice8_Poll( iface_w ); +} + +HRESULT WINAPI IDirectInputDevice2AImpl_SendDeviceData( IDirectInputDevice8A *iface_a, DWORD count, const DIDEVICEOBJECTDATA *data, + DWORD *inout, DWORD flags ) +{ + IDirectInputDeviceImpl *impl = impl_from_IDirectInputDevice8A( iface_a ); + IDirectInputDevice8W *iface_w = IDirectInputDevice8W_from_impl( impl ); + return IDirectInputDevice8_SendDeviceData( iface_w, count, data, inout, flags ); +} diff --git a/dlls/dinput/device.c b/dlls/dinput/device.c index d1c198d1807..972cfd604c7 100644 --- a/dlls/dinput/device.c +++ b/dlls/dinput/device.c @@ -1067,13 +1067,6 @@ HRESULT WINAPI IDirectInputDevice2WImpl_Acquire(LPDIRECTINPUTDEVICE8W iface) return res; }
-HRESULT WINAPI IDirectInputDevice2AImpl_Acquire(LPDIRECTINPUTDEVICE8A iface) -{ - IDirectInputDeviceImpl *This = impl_from_IDirectInputDevice8A(iface); - return IDirectInputDevice_Acquire(IDirectInputDevice8W_from_impl(This)); -} - - /****************************************************************************** * Unacquire */ @@ -1097,12 +1090,6 @@ HRESULT WINAPI IDirectInputDevice2WImpl_Unacquire(LPDIRECTINPUTDEVICE8W iface) return res; }
-HRESULT WINAPI IDirectInputDevice2AImpl_Unacquire(LPDIRECTINPUTDEVICE8A iface) -{ - IDirectInputDeviceImpl *This = impl_from_IDirectInputDevice8A(iface); - return IDirectInputDevice_Unacquire(IDirectInputDevice8W_from_impl(This)); -} - /****************************************************************************** * IDirectInputDeviceA */ @@ -1132,12 +1119,6 @@ HRESULT WINAPI IDirectInputDevice2WImpl_SetDataFormat(LPDIRECTINPUTDEVICE8W ifac return res; }
-HRESULT WINAPI IDirectInputDevice2AImpl_SetDataFormat(LPDIRECTINPUTDEVICE8A iface, LPCDIDATAFORMAT df) -{ - IDirectInputDeviceImpl *This = impl_from_IDirectInputDevice8A(iface); - return IDirectInputDevice2WImpl_SetDataFormat(IDirectInputDevice8W_from_impl(This), df); -} - /****************************************************************************** * SetCooperativeLevel * @@ -1179,12 +1160,6 @@ HRESULT WINAPI IDirectInputDevice2WImpl_SetCooperativeLevel(LPDIRECTINPUTDEVICE8 return DI_OK; }
-HRESULT WINAPI IDirectInputDevice2AImpl_SetCooperativeLevel(LPDIRECTINPUTDEVICE8A iface, HWND hwnd, DWORD dwflags) -{ - IDirectInputDeviceImpl *This = impl_from_IDirectInputDevice8A(iface); - return IDirectInputDevice2WImpl_SetCooperativeLevel(IDirectInputDevice8W_from_impl(This), hwnd, dwflags); -} - /****************************************************************************** * SetEventNotification : specifies event to be sent on state change */ @@ -1200,12 +1175,6 @@ HRESULT WINAPI IDirectInputDevice2WImpl_SetEventNotification(LPDIRECTINPUTDEVICE return DI_OK; }
-HRESULT WINAPI IDirectInputDevice2AImpl_SetEventNotification(LPDIRECTINPUTDEVICE8A iface, HANDLE event) -{ - IDirectInputDeviceImpl *This = impl_from_IDirectInputDevice8A(iface); - return IDirectInputDevice2WImpl_SetEventNotification(IDirectInputDevice8W_from_impl(This), event); -} -
ULONG WINAPI IDirectInputDevice2WImpl_Release(LPDIRECTINPUTDEVICE8W iface) { @@ -1239,12 +1208,6 @@ ULONG WINAPI IDirectInputDevice2WImpl_Release(LPDIRECTINPUTDEVICE8W iface) return ref; }
-ULONG WINAPI IDirectInputDevice2AImpl_Release(LPDIRECTINPUTDEVICE8A iface) -{ - IDirectInputDeviceImpl *This = impl_from_IDirectInputDevice8A(iface); - return IDirectInputDevice2WImpl_Release(IDirectInputDevice8W_from_impl(This)); -} - HRESULT WINAPI IDirectInputDevice2WImpl_QueryInterface(LPDIRECTINPUTDEVICE8W iface, REFIID riid, LPVOID *ppobj) { IDirectInputDeviceImpl *This = impl_from_IDirectInputDevice8W(iface); @@ -1276,12 +1239,6 @@ HRESULT WINAPI IDirectInputDevice2WImpl_QueryInterface(LPDIRECTINPUTDEVICE8W ifa return E_NOINTERFACE; }
-HRESULT WINAPI IDirectInputDevice2AImpl_QueryInterface(LPDIRECTINPUTDEVICE8A iface, REFIID riid, LPVOID *ppobj) -{ - IDirectInputDeviceImpl *This = impl_from_IDirectInputDevice8A(iface); - return IDirectInputDevice2WImpl_QueryInterface(IDirectInputDevice8W_from_impl(This), riid, ppobj); -} - ULONG WINAPI IDirectInputDevice2WImpl_AddRef(LPDIRECTINPUTDEVICE8W iface) { IDirectInputDeviceImpl *This = impl_from_IDirectInputDevice8W(iface); @@ -1290,12 +1247,6 @@ ULONG WINAPI IDirectInputDevice2WImpl_AddRef(LPDIRECTINPUTDEVICE8W iface) return ref; }
-ULONG WINAPI IDirectInputDevice2AImpl_AddRef(LPDIRECTINPUTDEVICE8A iface) -{ - IDirectInputDeviceImpl *This = impl_from_IDirectInputDevice8A(iface); - return IDirectInputDevice2WImpl_AddRef(IDirectInputDevice8W_from_impl(This)); -} - HRESULT WINAPI IDirectInputDevice2AImpl_EnumObjects(LPDIRECTINPUTDEVICE8A iface, LPDIENUMDEVICEOBJECTSCALLBACKA lpCallback, LPVOID lpvRef, DWORD dwFlags) { @@ -1414,12 +1365,6 @@ HRESULT WINAPI IDirectInputDevice2WImpl_GetProperty(LPDIRECTINPUTDEVICE8W iface, return DI_OK; }
-HRESULT WINAPI IDirectInputDevice2AImpl_GetProperty(LPDIRECTINPUTDEVICE8A iface, REFGUID rguid, LPDIPROPHEADER pdiph) -{ - IDirectInputDeviceImpl *This = impl_from_IDirectInputDevice8A(iface); - return IDirectInputDevice_GetProperty(IDirectInputDevice8W_from_impl(This), rguid, pdiph); -} - /****************************************************************************** * SetProperty */ @@ -1530,13 +1475,6 @@ HRESULT WINAPI IDirectInputDevice2WImpl_SetProperty( return DI_OK; }
-HRESULT WINAPI IDirectInputDevice2AImpl_SetProperty( - LPDIRECTINPUTDEVICE8A iface, REFGUID rguid, LPCDIPROPHEADER pdiph) -{ - IDirectInputDeviceImpl *This = impl_from_IDirectInputDevice8A(iface); - return IDirectInputDevice_SetProperty(IDirectInputDevice8W_from_impl(This), rguid, pdiph); -} - HRESULT WINAPI IDirectInputDevice2AImpl_GetObjectInfo( LPDIRECTINPUTDEVICE8A iface, LPDIDEVICEOBJECTINSTANCEA pdidoi, @@ -1678,13 +1616,6 @@ HRESULT WINAPI IDirectInputDevice2WImpl_GetDeviceData(LPDIRECTINPUTDEVICE8W ifac return ret; }
-HRESULT WINAPI IDirectInputDevice2AImpl_GetDeviceData(LPDIRECTINPUTDEVICE8A iface, DWORD dodsize, - LPDIDEVICEOBJECTDATA dod, LPDWORD entries, DWORD flags) -{ - IDirectInputDeviceImpl *This = impl_from_IDirectInputDevice8A(iface); - return IDirectInputDevice_GetDeviceData(IDirectInputDevice8W_from_impl(This), dodsize, dod, entries, flags); -} - HRESULT WINAPI IDirectInputDevice2WImpl_RunControlPanel(LPDIRECTINPUTDEVICE8W iface, HWND hwndOwner, DWORD dwFlags) { IDirectInputDeviceImpl *This = impl_from_IDirectInputDevice8W(iface); @@ -1693,12 +1624,6 @@ HRESULT WINAPI IDirectInputDevice2WImpl_RunControlPanel(LPDIRECTINPUTDEVICE8W if return DI_OK; }
-HRESULT WINAPI IDirectInputDevice2AImpl_RunControlPanel(LPDIRECTINPUTDEVICE8A iface, HWND hwndOwner, DWORD dwFlags) -{ - IDirectInputDeviceImpl *This = impl_from_IDirectInputDevice8A(iface); - return IDirectInputDevice2WImpl_RunControlPanel(IDirectInputDevice8W_from_impl(This), hwndOwner, dwFlags); -} - HRESULT WINAPI IDirectInputDevice2WImpl_Initialize(LPDIRECTINPUTDEVICE8W iface, HINSTANCE hinst, DWORD dwVersion, REFGUID rguid) { @@ -1707,13 +1632,6 @@ HRESULT WINAPI IDirectInputDevice2WImpl_Initialize(LPDIRECTINPUTDEVICE8W iface, return DI_OK; }
-HRESULT WINAPI IDirectInputDevice2AImpl_Initialize(LPDIRECTINPUTDEVICE8A iface, HINSTANCE hinst, DWORD dwVersion, - REFGUID rguid) -{ - IDirectInputDeviceImpl *This = impl_from_IDirectInputDevice8A(iface); - return IDirectInputDevice2WImpl_Initialize(IDirectInputDevice8W_from_impl(This), hinst, dwVersion, rguid); -} - /****************************************************************************** * IDirectInputDevice2A */ @@ -1729,13 +1647,6 @@ HRESULT WINAPI IDirectInputDevice2WImpl_CreateEffect(LPDIRECTINPUTDEVICE8W iface return DIERR_UNSUPPORTED; }
-HRESULT WINAPI IDirectInputDevice2AImpl_CreateEffect(LPDIRECTINPUTDEVICE8A iface, REFGUID rguid, LPCDIEFFECT lpeff, - LPDIRECTINPUTEFFECT *ppdef, LPUNKNOWN pUnkOuter) -{ - IDirectInputDeviceImpl *This = impl_from_IDirectInputDevice8A(iface); - return IDirectInputDevice2_CreateEffect(IDirectInputDevice8W_from_impl(This), rguid, lpeff, ppdef, pUnkOuter); -} - HRESULT WINAPI IDirectInputDevice2AImpl_EnumEffects( LPDIRECTINPUTDEVICE8A iface, LPDIENUMEFFECTSCALLBACKA lpCallback, @@ -1787,12 +1698,6 @@ HRESULT WINAPI IDirectInputDevice2WImpl_GetForceFeedbackState(LPDIRECTINPUTDEVIC return DI_OK; }
-HRESULT WINAPI IDirectInputDevice2AImpl_GetForceFeedbackState(LPDIRECTINPUTDEVICE8A iface, LPDWORD pdwOut) -{ - IDirectInputDeviceImpl *This = impl_from_IDirectInputDevice8A(iface); - return IDirectInputDevice2_GetForceFeedbackState(IDirectInputDevice8W_from_impl(This), pdwOut); -} - HRESULT WINAPI IDirectInputDevice2WImpl_SendForceFeedbackCommand(LPDIRECTINPUTDEVICE8W iface, DWORD dwFlags) { IDirectInputDeviceImpl *This = impl_from_IDirectInputDevice8W(iface); @@ -1800,12 +1705,6 @@ HRESULT WINAPI IDirectInputDevice2WImpl_SendForceFeedbackCommand(LPDIRECTINPUTDE return DI_NOEFFECT; }
-HRESULT WINAPI IDirectInputDevice2AImpl_SendForceFeedbackCommand(LPDIRECTINPUTDEVICE8A iface, DWORD dwFlags) -{ - IDirectInputDeviceImpl *This = impl_from_IDirectInputDevice8A(iface); - return IDirectInputDevice2_SendForceFeedbackCommand(IDirectInputDevice8W_from_impl(This), dwFlags); -} - HRESULT WINAPI IDirectInputDevice2WImpl_EnumCreatedEffectObjects(LPDIRECTINPUTDEVICE8W iface, LPDIENUMCREATEDEFFECTOBJECTSCALLBACK lpCallback, LPVOID lpvRef, DWORD dwFlags) { @@ -1814,13 +1713,6 @@ HRESULT WINAPI IDirectInputDevice2WImpl_EnumCreatedEffectObjects(LPDIRECTINPUTDE return DI_OK; }
-HRESULT WINAPI IDirectInputDevice2AImpl_EnumCreatedEffectObjects(LPDIRECTINPUTDEVICE8A iface, - LPDIENUMCREATEDEFFECTOBJECTSCALLBACK lpCallback, LPVOID lpvRef, DWORD dwFlags) -{ - IDirectInputDeviceImpl *This = impl_from_IDirectInputDevice8A(iface); - return IDirectInputDevice2_EnumCreatedEffectObjects(IDirectInputDevice8W_from_impl(This), lpCallback, lpvRef, dwFlags); -} - HRESULT WINAPI IDirectInputDevice2WImpl_Escape(LPDIRECTINPUTDEVICE8W iface, LPDIEFFESCAPE lpDIEEsc) { IDirectInputDeviceImpl *This = impl_from_IDirectInputDevice8W(iface); @@ -1828,12 +1720,6 @@ HRESULT WINAPI IDirectInputDevice2WImpl_Escape(LPDIRECTINPUTDEVICE8W iface, LPDI return DI_OK; }
-HRESULT WINAPI IDirectInputDevice2AImpl_Escape(LPDIRECTINPUTDEVICE8A iface, LPDIEFFESCAPE lpDIEEsc) -{ - IDirectInputDeviceImpl *This = impl_from_IDirectInputDevice8A(iface); - return IDirectInputDevice2WImpl_Escape(IDirectInputDevice8W_from_impl(This), lpDIEEsc); -} - HRESULT WINAPI IDirectInputDevice2WImpl_Poll(LPDIRECTINPUTDEVICE8W iface) { IDirectInputDeviceImpl *This = impl_from_IDirectInputDevice8W(iface); @@ -1844,12 +1730,6 @@ HRESULT WINAPI IDirectInputDevice2WImpl_Poll(LPDIRECTINPUTDEVICE8W iface) return DI_OK; }
-HRESULT WINAPI IDirectInputDevice2AImpl_Poll(LPDIRECTINPUTDEVICE8A iface) -{ - IDirectInputDeviceImpl *This = impl_from_IDirectInputDevice8A(iface); - return IDirectInputDevice2_Poll(IDirectInputDevice8W_from_impl(This)); -} - HRESULT WINAPI IDirectInputDevice2WImpl_SendDeviceData(LPDIRECTINPUTDEVICE8W iface, DWORD cbObjectData, LPCDIDEVICEOBJECTDATA rgdod, LPDWORD pdwInOut, DWORD dwFlags) @@ -1860,15 +1740,6 @@ HRESULT WINAPI IDirectInputDevice2WImpl_SendDeviceData(LPDIRECTINPUTDEVICE8W ifa return DI_OK; }
-HRESULT WINAPI IDirectInputDevice2AImpl_SendDeviceData(LPDIRECTINPUTDEVICE8A iface, DWORD cbObjectData, - LPCDIDEVICEOBJECTDATA rgdod, LPDWORD pdwInOut, - DWORD dwFlags) -{ - IDirectInputDeviceImpl *This = impl_from_IDirectInputDevice8A(iface); - return IDirectInputDevice2WImpl_SendDeviceData(IDirectInputDevice8W_from_impl(This), cbObjectData, rgdod, - pdwInOut, dwFlags); -} - HRESULT WINAPI IDirectInputDevice7AImpl_EnumEffectsInFile(LPDIRECTINPUTDEVICE8A iface, LPCSTR lpszFileName, LPDIENUMEFFECTSINFILECALLBACK pec, diff --git a/dlls/dinput8/Makefile.in b/dlls/dinput8/Makefile.in index 5f0dce97caa..35b3bfb75f5 100644 --- a/dlls/dinput8/Makefile.in +++ b/dlls/dinput8/Makefile.in @@ -6,6 +6,7 @@ EXTRALIBS = $(IOKIT_LIBS) $(FORCEFEEDBACK_LIBS) PARENTSRC = ../dinput
C_SRCS = \ + ansi.c \ config.c \ data_formats.c \ device.c \
Signed-off-by: Rémi Bernon rbernon@codeweavers.com --- dlls/dinput/device.c | 4 ++++ dlls/dinput/tests/device.c | 3 +++ 2 files changed, 7 insertions(+)
diff --git a/dlls/dinput/device.c b/dlls/dinput/device.c index 972cfd604c7..c6385e6c025 100644 --- a/dlls/dinput/device.c +++ b/dlls/dinput/device.c @@ -1259,6 +1259,8 @@ HRESULT WINAPI IDirectInputDevice2AImpl_EnumObjects(LPDIRECTINPUTDEVICE8A iface, _dump_EnumObjects_flags(dwFlags); TRACE("\n");
+ if (!lpCallback) return DIERR_INVALIDPARAM; + /* Only the fields till dwFFMaxForce are relevant */ memset(&ddoi, 0, sizeof(ddoi)); ddoi.dwSize = FIELD_OFFSET(DIDEVICEOBJECTINSTANCEA, dwFFMaxForce); @@ -1289,6 +1291,8 @@ HRESULT WINAPI IDirectInputDevice2WImpl_EnumObjects(LPDIRECTINPUTDEVICE8W iface, _dump_EnumObjects_flags(dwFlags); TRACE("\n");
+ if (!lpCallback) return DIERR_INVALIDPARAM; + /* Only the fields till dwFFMaxForce are relevant */ memset(&ddoi, 0, sizeof(ddoi)); ddoi.dwSize = FIELD_OFFSET(DIDEVICEOBJECTINSTANCEW, dwFFMaxForce); diff --git a/dlls/dinput/tests/device.c b/dlls/dinput/tests/device.c index 071fc6de6bb..9be00a671fb 100644 --- a/dlls/dinput/tests/device.c +++ b/dlls/dinput/tests/device.c @@ -84,6 +84,9 @@ static void test_object_info(IDirectInputDeviceA *device, HWND hwnd) DWORD cnt = 0; DIDEVICEOBJECTDATA buffer[5];
+ hr = IDirectInputDevice_EnumObjects(device, NULL, &cnt, DIDFT_ALL); + ok(hr == DIERR_INVALIDPARAM, "IDirectInputDevice_EnumObjects returned %08x, expected %08x\n", hr, DIERR_INVALIDPARAM); + hr = IDirectInputDevice_EnumObjects(device, enum_callback, &cnt, DIDFT_ALL); ok(SUCCEEDED(hr), "EnumObjects() failed: %08x\n", hr);
Instead of a separate duplicate implementation.
Signed-off-by: Rémi Bernon rbernon@codeweavers.com --- dlls/dinput/ansi.c | 48 ++++++++++++++++++++++++++++++++++++++++++++ dlls/dinput/device.c | 32 ----------------------------- 2 files changed, 48 insertions(+), 32 deletions(-)
diff --git a/dlls/dinput/ansi.c b/dlls/dinput/ansi.c index 99156195423..5158d326073 100644 --- a/dlls/dinput/ansi.c +++ b/dlls/dinput/ansi.c @@ -43,6 +43,27 @@ static IDirectInputDevice8W *IDirectInputDevice8W_from_impl( IDirectInputDeviceI return &impl->IDirectInputDevice8W_iface; }
+static void dideviceobjectinstance_wtoa( const DIDEVICEOBJECTINSTANCEW *in, DIDEVICEOBJECTINSTANCEA *out ) +{ + out->guidType = in->guidType; + out->dwOfs = in->dwOfs; + out->dwType = in->dwType; + out->dwFlags = in->dwFlags; + WideCharToMultiByte( CP_ACP, 0, in->tszName, -1, out->tszName, sizeof(out->tszName), NULL, NULL ); + + if (out->dwSize <= FIELD_OFFSET( DIDEVICEOBJECTINSTANCEA, dwFFMaxForce )) return; + + out->dwFFMaxForce = in->dwFFMaxForce; + out->dwFFForceResolution = in->dwFFForceResolution; + out->wCollectionNumber = in->wCollectionNumber; + out->wDesignatorIndex = in->wDesignatorIndex; + out->wUsagePage = in->wUsagePage; + out->wUsage = in->wUsage; + out->dwDimension = in->dwDimension; + out->wExponent = in->wExponent; + out->wReserved = in->wReserved; +} + HRESULT WINAPI IDirectInputDevice2AImpl_QueryInterface( IDirectInputDevice8A *iface_a, REFIID iid, void **out ) { IDirectInputDeviceImpl *impl = impl_from_IDirectInputDevice8A( iface_a ); @@ -64,6 +85,33 @@ ULONG WINAPI IDirectInputDevice2AImpl_Release( IDirectInputDevice8A *iface_a ) return IDirectInputDevice8_Release( iface_w ); }
+struct enum_objects_wtoa_params +{ + LPDIENUMDEVICEOBJECTSCALLBACKA callback; + void *ref; +}; + +static BOOL CALLBACK enum_objects_wtoa_callback( const DIDEVICEOBJECTINSTANCEW *instance_w, void *ref ) +{ + struct enum_objects_wtoa_params *params = ref; + DIDEVICEOBJECTINSTANCEA instance_a = {sizeof(instance_a)}; + + dideviceobjectinstance_wtoa( instance_w, &instance_a ); + return params->callback( &instance_a, params->ref ); +} + +HRESULT WINAPI IDirectInputDevice2AImpl_EnumObjects( IDirectInputDevice8A *iface_a, LPDIENUMDEVICEOBJECTSCALLBACKA callback, + void *ref, DWORD flags ) +{ + struct enum_objects_wtoa_params params = {callback, ref}; + IDirectInputDeviceImpl *impl = impl_from_IDirectInputDevice8A( iface_a ); + IDirectInputDevice8W *iface_w = IDirectInputDevice8W_from_impl( impl ); + + if (!callback) return DIERR_INVALIDPARAM; + + return IDirectInputDevice8_EnumObjects( iface_w, enum_objects_wtoa_callback, ¶ms, flags ); +} + HRESULT WINAPI IDirectInputDevice2AImpl_GetProperty( IDirectInputDevice8A *iface_a, REFGUID guid, DIPROPHEADER *header ) { IDirectInputDeviceImpl *impl = impl_from_IDirectInputDevice8A( iface_a ); diff --git a/dlls/dinput/device.c b/dlls/dinput/device.c index c6385e6c025..31b859801c7 100644 --- a/dlls/dinput/device.c +++ b/dlls/dinput/device.c @@ -1247,38 +1247,6 @@ ULONG WINAPI IDirectInputDevice2WImpl_AddRef(LPDIRECTINPUTDEVICE8W iface) return ref; }
-HRESULT WINAPI IDirectInputDevice2AImpl_EnumObjects(LPDIRECTINPUTDEVICE8A iface, - LPDIENUMDEVICEOBJECTSCALLBACKA lpCallback, LPVOID lpvRef, DWORD dwFlags) -{ - IDirectInputDeviceImpl *This = impl_from_IDirectInputDevice8A(iface); - DIDEVICEOBJECTINSTANCEA ddoi; - int i; - - TRACE("(%p)->(%p,%p flags:%08x)\n", This, lpCallback, lpvRef, dwFlags); - TRACE(" - flags = "); - _dump_EnumObjects_flags(dwFlags); - TRACE("\n"); - - if (!lpCallback) return DIERR_INVALIDPARAM; - - /* Only the fields till dwFFMaxForce are relevant */ - memset(&ddoi, 0, sizeof(ddoi)); - ddoi.dwSize = FIELD_OFFSET(DIDEVICEOBJECTINSTANCEA, dwFFMaxForce); - - for (i = 0; i < This->data_format.wine_df->dwNumObjs; i++) - { - LPDIOBJECTDATAFORMAT odf = dataformat_to_odf(This->data_format.wine_df, i); - - if (dwFlags != DIDFT_ALL && !(dwFlags & DIDFT_GETTYPE(odf->dwType))) continue; - if (IDirectInputDevice_GetObjectInfo(iface, &ddoi, odf->dwType, DIPH_BYID) != DI_OK) - continue; - - if (lpCallback(&ddoi, lpvRef) != DIENUM_CONTINUE) break; - } - - return DI_OK; -} - HRESULT WINAPI IDirectInputDevice2WImpl_EnumObjects(LPDIRECTINPUTDEVICE8W iface, LPDIENUMDEVICEOBJECTSCALLBACKW lpCallback, LPVOID lpvRef, DWORD dwFlags) {