Signed-off-by: Rémi Bernon rbernon@codeweavers.com --- dlls/dinput/dinput_main.c | 32 +++++++++++++--------------- dlls/dinput/dinput_private.h | 2 +- dlls/dinput/joystick_linux.c | 34 ++++-------------------------- dlls/dinput/joystick_linuxinput.c | 34 ++++-------------------------- dlls/dinput/joystick_osx.c | 33 ++++------------------------- dlls/dinput/keyboard.c | 35 ++++--------------------------- dlls/dinput/mouse.c | 34 ++++-------------------------- 7 files changed, 36 insertions(+), 168 deletions(-)
diff --git a/dlls/dinput/dinput_main.c b/dlls/dinput/dinput_main.c index 85de9f79b81..3d6d5732cfb 100644 --- a/dlls/dinput/dinput_main.c +++ b/dlls/dinput/dinput_main.c @@ -644,9 +644,15 @@ static HRESULT WINAPI IDirectInput2WImpl_FindDevice(LPDIRECTINPUT7W iface, REFGU return DI_OK; }
-static HRESULT create_device(IDirectInputImpl *This, REFGUID rguid, REFIID riid, LPVOID *pvOut, BOOL unicode) +static HRESULT WINAPI IDirectInput7WImpl_CreateDeviceEx( IDirectInput7W *iface, REFGUID rguid, REFIID riid, + LPVOID *pvOut, LPUNKNOWN lpUnknownOuter ) { + IDirectInputDevice8W *device; + IDirectInputImpl *This = impl_from_IDirectInput7W( iface ); unsigned int i; + HRESULT hr; + + TRACE( "(%p)->(%s, %s, %p, %p)\n", This, debugstr_guid( rguid ), debugstr_guid( riid ), pvOut, lpUnknownOuter );
if (pvOut) *pvOut = NULL; @@ -660,31 +666,23 @@ static HRESULT create_device(IDirectInputImpl *This, REFGUID rguid, REFIID riid, /* Loop on all the devices to see if anyone matches the given GUID */ for (i = 0; i < ARRAY_SIZE(dinput_devices); i++) { - HRESULT ret; - if (!dinput_devices[i]->create_device) continue; - if ((ret = dinput_devices[i]->create_device(This, rguid, riid, pvOut, unicode)) == DI_OK) - return DI_OK; + if (SUCCEEDED(hr = dinput_devices[i]->create_device( This, rguid, &device ))) + { + hr = IDirectInputDevice8_QueryInterface( device, riid, pvOut ); + IDirectInputDevice8_Release( device ); + return hr; + } }
WARN("invalid device GUID %s\n", debugstr_guid(rguid)); return DIERR_DEVICENOTREG; }
-static HRESULT WINAPI IDirectInput7WImpl_CreateDeviceEx(LPDIRECTINPUT7W iface, REFGUID rguid, - REFIID riid, LPVOID* pvOut, LPUNKNOWN lpUnknownOuter) -{ - IDirectInputImpl *This = impl_from_IDirectInput7W( iface ); - - TRACE("(%p)->(%s, %s, %p, %p)\n", This, debugstr_guid(rguid), debugstr_guid(riid), pvOut, lpUnknownOuter); - - return create_device(This, rguid, riid, pvOut, TRUE); -} - static HRESULT WINAPI IDirectInputWImpl_CreateDevice(LPDIRECTINPUT7W iface, REFGUID rguid, LPDIRECTINPUTDEVICEW* pdev, LPUNKNOWN punk) { - return IDirectInput7_CreateDeviceEx( iface, rguid, NULL, (LPVOID *)pdev, punk ); + return IDirectInput7_CreateDeviceEx( iface, rguid, &IID_IDirectInputDeviceW, (LPVOID *)pdev, punk ); }
/******************************************************************************* @@ -713,7 +711,7 @@ static HRESULT WINAPI IDirectInput8WImpl_CreateDevice(LPDIRECTINPUT8W iface, REF LPDIRECTINPUTDEVICE8W* pdev, LPUNKNOWN punk) { IDirectInputImpl *This = impl_from_IDirectInput8W( iface ); - return IDirectInput7_CreateDeviceEx( &This->IDirectInput7W_iface, rguid, NULL, (LPVOID *)pdev, punk ); + return IDirectInput7_CreateDeviceEx( &This->IDirectInput7W_iface, rguid, &IID_IDirectInputDevice8W, (LPVOID *)pdev, punk ); }
static HRESULT WINAPI IDirectInput8WImpl_EnumDevices(LPDIRECTINPUT8W iface, DWORD dwDevType, LPDIENUMDEVICESCALLBACKW lpCallback, diff --git a/dlls/dinput/dinput_private.h b/dlls/dinput/dinput_private.h index 256c30d3dc0..404eaad1d52 100644 --- a/dlls/dinput/dinput_private.h +++ b/dlls/dinput/dinput_private.h @@ -57,7 +57,7 @@ struct dinput_device { const char *name; HRESULT (*enum_deviceA)(DWORD dwDevType, DWORD dwFlags, LPDIDEVICEINSTANCEA lpddi, DWORD version, int id); HRESULT (*enum_deviceW)(DWORD dwDevType, DWORD dwFlags, LPDIDEVICEINSTANCEW lpddi, DWORD version, int id); - HRESULT (*create_device)(IDirectInputImpl *dinput, REFGUID rguid, REFIID riid, LPVOID *pdev, int unicode); + HRESULT (*create_device)(IDirectInputImpl *dinput, REFGUID rguid, IDirectInputDevice8W **out); };
struct DevicePlayer { diff --git a/dlls/dinput/joystick_linux.c b/dlls/dinput/joystick_linux.c index 0c1560617dd..32e355c47e8 100644 --- a/dlls/dinput/joystick_linux.c +++ b/dlls/dinput/joystick_linux.c @@ -587,13 +587,13 @@ static unsigned short get_joystick_index(REFGUID guid) return MAX_JOYSTICKS; }
-static HRESULT joydev_create_device(IDirectInputImpl *dinput, REFGUID rguid, REFIID riid, LPVOID *pdev, int unicode) +static HRESULT joydev_create_device( IDirectInputImpl *dinput, REFGUID rguid, IDirectInputDevice8W **out ) { unsigned short index;
- TRACE("%p %s %s %p %i\n", dinput, debugstr_guid(rguid), debugstr_guid(riid), pdev, unicode); + TRACE( "%p %s %p\n", dinput, debugstr_guid( rguid ), out ); find_joystick_devices(); - *pdev = NULL; + *out = NULL;
if ((index = get_joystick_index(rguid)) < MAX_JOYSTICKS && joystick_devices_count && index < joystick_devices_count) @@ -601,37 +601,11 @@ static HRESULT joydev_create_device(IDirectInputImpl *dinput, REFGUID rguid, REF JoystickImpl *This; HRESULT hr;
- if (riid == NULL) - ;/* nothing */ - else if (IsEqualGUID(&IID_IDirectInputDeviceA, riid) || - IsEqualGUID(&IID_IDirectInputDevice2A, riid) || - IsEqualGUID(&IID_IDirectInputDevice7A, riid) || - IsEqualGUID(&IID_IDirectInputDevice8A, riid)) - { - unicode = 0; - } - else if (IsEqualGUID(&IID_IDirectInputDeviceW, riid) || - IsEqualGUID(&IID_IDirectInputDevice2W, riid) || - IsEqualGUID(&IID_IDirectInputDevice7W, riid) || - IsEqualGUID(&IID_IDirectInputDevice8W, riid)) - { - unicode = 1; - } - else - { - WARN("no interface\n"); - return DIERR_NOINTERFACE; - } - if (FAILED(hr = alloc_device( rguid, dinput, &This, index ))) return hr;
TRACE( "Created a Joystick device (%p)\n", This );
- if (unicode) - *pdev = &This->generic.base.IDirectInputDevice8W_iface; - else - *pdev = &This->generic.base.IDirectInputDevice8A_iface; - + *out = &This->generic.base.IDirectInputDevice8W_iface; return hr; }
diff --git a/dlls/dinput/joystick_linuxinput.c b/dlls/dinput/joystick_linuxinput.c index 3bc6114322f..0b7a4e63c8f 100644 --- a/dlls/dinput/joystick_linuxinput.c +++ b/dlls/dinput/joystick_linuxinput.c @@ -612,13 +612,13 @@ static unsigned short get_joystick_index(REFGUID guid) return MAX_JOYDEV; }
-static HRESULT joydev_create_device(IDirectInputImpl *dinput, REFGUID rguid, REFIID riid, LPVOID *pdev, int unicode) +static HRESULT joydev_create_device( IDirectInputImpl *dinput, REFGUID rguid, IDirectInputDevice8W **out ) { unsigned short index;
- TRACE("%p %s %s %p %i\n", dinput, debugstr_guid(rguid), debugstr_guid(riid), pdev, unicode); + TRACE( "%p %s %p\n", dinput, debugstr_guid( rguid ), out ); find_joydevs(); - *pdev = NULL; + *out = NULL;
if ((index = get_joystick_index(rguid)) < MAX_JOYDEV && have_joydevs && index < have_joydevs) @@ -626,37 +626,11 @@ static HRESULT joydev_create_device(IDirectInputImpl *dinput, REFGUID rguid, REF JoystickImpl *This; HRESULT hr;
- if (riid == NULL) - ;/* nothing */ - else if (IsEqualGUID(&IID_IDirectInputDeviceA, riid) || - IsEqualGUID(&IID_IDirectInputDevice2A, riid) || - IsEqualGUID(&IID_IDirectInputDevice7A, riid) || - IsEqualGUID(&IID_IDirectInputDevice8A, riid)) - { - unicode = 0; - } - else if (IsEqualGUID(&IID_IDirectInputDeviceW, riid) || - IsEqualGUID(&IID_IDirectInputDevice2W, riid) || - IsEqualGUID(&IID_IDirectInputDevice7W, riid) || - IsEqualGUID(&IID_IDirectInputDevice8W, riid)) - { - unicode = 1; - } - else - { - WARN("no interface\n"); - return DIERR_NOINTERFACE; - } - if (FAILED(hr = alloc_device( rguid, dinput, &This, index ))) return hr;
TRACE( "Created a Joystick device (%p)\n", This );
- if (unicode) - *pdev = &This->generic.base.IDirectInputDevice8W_iface; - else - *pdev = &This->generic.base.IDirectInputDevice8A_iface; - + *out = &This->generic.base.IDirectInputDevice8W_iface; return DI_OK; }
diff --git a/dlls/dinput/joystick_osx.c b/dlls/dinput/joystick_osx.c index e29a7bd9726..38a708d4cae 100644 --- a/dlls/dinput/joystick_osx.c +++ b/dlls/dinput/joystick_osx.c @@ -1323,13 +1323,13 @@ static unsigned short get_joystick_index(REFGUID guid) return 0xffff; }
-static HRESULT joydev_create_device(IDirectInputImpl *dinput, REFGUID rguid, REFIID riid, LPVOID *pdev, int unicode) +static HRESULT joydev_create_device( IDirectInputImpl *dinput, REFGUID rguid, IDirectInputDevice8W **out ) { unsigned short index; int joystick_devices_count;
- TRACE("%p %s %s %p %i\n", dinput, debugstr_guid(rguid), debugstr_guid(riid), pdev, unicode); - *pdev = NULL; + TRACE( "%p %s %p\n", dinput, debugstr_guid( rguid ), out ); + *out = NULL;
if ((joystick_devices_count = find_joystick_devices()) == 0) return DIERR_DEVICENOTREG; @@ -1340,36 +1340,11 @@ static HRESULT joydev_create_device(IDirectInputImpl *dinput, REFGUID rguid, REF JoystickImpl *This; HRESULT hr;
- if (riid == NULL) - ;/* nothing */ - else if (IsEqualGUID(&IID_IDirectInputDeviceA, riid) || - IsEqualGUID(&IID_IDirectInputDevice2A, riid) || - IsEqualGUID(&IID_IDirectInputDevice7A, riid) || - IsEqualGUID(&IID_IDirectInputDevice8A, riid)) - { - unicode = 0; - } - else if (IsEqualGUID(&IID_IDirectInputDeviceW, riid) || - IsEqualGUID(&IID_IDirectInputDevice2W, riid) || - IsEqualGUID(&IID_IDirectInputDevice7W, riid) || - IsEqualGUID(&IID_IDirectInputDevice8W, riid)) - { - unicode = 1; - } - else - { - WARN("no interface\n"); - return DIERR_NOINTERFACE; - } - if (FAILED(hr = alloc_device( rguid, dinput, &This, index ))) return hr;
TRACE( "Created a Joystick device (%p)\n", This );
- if (unicode) - *pdev = &This->generic.base.IDirectInputDevice8W_iface; - else - *pdev = &This->generic.base.IDirectInputDevice8A_iface; + *out = &This->generic.base.IDirectInputDevice8W_iface; return hr; }
diff --git a/dlls/dinput/keyboard.c b/dlls/dinput/keyboard.c index c64051e8663..0e371e31b99 100644 --- a/dlls/dinput/keyboard.c +++ b/dlls/dinput/keyboard.c @@ -283,48 +283,21 @@ failed: return DIERR_OUTOFMEMORY; }
- -static HRESULT keyboarddev_create_device(IDirectInputImpl *dinput, REFGUID rguid, REFIID riid, LPVOID *pdev, int unicode) +static HRESULT keyboarddev_create_device( IDirectInputImpl *dinput, REFGUID rguid, IDirectInputDevice8W **out ) { - TRACE("%p %s %s %p %i\n", dinput, debugstr_guid(rguid), debugstr_guid(riid), pdev, unicode); - *pdev = NULL; + TRACE( "%p %s %p\n", dinput, debugstr_guid( rguid ), out ); + *out = NULL;
if (IsEqualGUID(&GUID_SysKeyboard, rguid)) /* Wine Keyboard */ { SysKeyboardImpl *This; HRESULT hr;
- if (riid == NULL) - ;/* nothing */ - else if (IsEqualGUID(&IID_IDirectInputDeviceA, riid) || - IsEqualGUID(&IID_IDirectInputDevice2A, riid) || - IsEqualGUID(&IID_IDirectInputDevice7A, riid) || - IsEqualGUID(&IID_IDirectInputDevice8A, riid)) - { - unicode = 0; - } - else if (IsEqualGUID(&IID_IDirectInputDeviceW, riid) || - IsEqualGUID(&IID_IDirectInputDevice2W, riid) || - IsEqualGUID(&IID_IDirectInputDevice7W, riid) || - IsEqualGUID(&IID_IDirectInputDevice8W, riid)) - { - unicode = 1; - } - else - { - WARN("no interface\n"); - return DIERR_NOINTERFACE; - } - if (FAILED(hr = alloc_device( rguid, dinput, &This ))) return hr;
TRACE( "Created a Keyboard device (%p)\n", This );
- if (unicode) - *pdev = &This->base.IDirectInputDevice8W_iface; - else - *pdev = &This->base.IDirectInputDevice8A_iface; - + *out = &This->base.IDirectInputDevice8W_iface; return DI_OK; }
diff --git a/dlls/dinput/mouse.c b/dlls/dinput/mouse.c index ef503526c35..09cfe945a50 100644 --- a/dlls/dinput/mouse.c +++ b/dlls/dinput/mouse.c @@ -240,47 +240,21 @@ failed: return DIERR_OUTOFMEMORY; }
-static HRESULT mousedev_create_device(IDirectInputImpl *dinput, REFGUID rguid, REFIID riid, LPVOID *pdev, int unicode) +static HRESULT mousedev_create_device( IDirectInputImpl *dinput, REFGUID rguid, IDirectInputDevice8W **out ) { - TRACE("%p %s %s %p %i\n", dinput, debugstr_guid(rguid), debugstr_guid(riid), pdev, unicode); - *pdev = NULL; + TRACE( "%p %s %p\n", dinput, debugstr_guid( rguid ), out ); + *out = NULL;
if (IsEqualGUID(&GUID_SysMouse, rguid)) /* Wine Mouse */ { SysMouseImpl *This; HRESULT hr;
- if (riid == NULL) - ;/* nothing */ - else if (IsEqualGUID(&IID_IDirectInputDeviceA, riid) || - IsEqualGUID(&IID_IDirectInputDevice2A, riid) || - IsEqualGUID(&IID_IDirectInputDevice7A, riid) || - IsEqualGUID(&IID_IDirectInputDevice8A, riid)) - { - unicode = 0; - } - else if (IsEqualGUID(&IID_IDirectInputDeviceW, riid) || - IsEqualGUID(&IID_IDirectInputDevice2W, riid) || - IsEqualGUID(&IID_IDirectInputDevice7W, riid) || - IsEqualGUID(&IID_IDirectInputDevice8W, riid)) - { - unicode = 1; - } - else - { - WARN("no interface\n"); - return DIERR_NOINTERFACE; - } - if (FAILED(hr = alloc_device( rguid, dinput, &This ))) return hr;
TRACE( "Created a Mouse device (%p)\n", This );
- if (unicode) - *pdev = &This->base.IDirectInputDevice8W_iface; - else - *pdev = &This->base.IDirectInputDevice8A_iface; - + *out = &This->base.IDirectInputDevice8W_iface; return DI_OK; }