diff --git a/dlls/dinput/dinput_main.c b/dlls/dinput/dinput_main.c index bee919cebff..ffa78be2fb5 100644 --- a/dlls/dinput/dinput_main.c +++ b/dlls/dinput/dinput_main.c @@ -610,7 +610,6 @@ static HRESULT WINAPI IDirectInput7WImpl_CreateDeviceEx( IDirectInput7W *iface, { IDirectInputImpl *impl = impl_from_IDirectInput7W( iface ); IDirectInputDevice8W *device; - unsigned int i; HRESULT hr; TRACE( "iface %p, guid %s, iid %s, out %p, outer %p\n", iface, debugstr_guid( guid ), @@ -622,20 +621,14 @@ static HRESULT WINAPI IDirectInput7WImpl_CreateDeviceEx( IDirectInput7W *iface, if (!guid) return E_POINTER; if (!impl->initialized) return DIERR_NOTINITIALIZED; - /* Loop on all the devices to see if anyone matches the given GUID */ - for (i = 0; i < ARRAY_SIZE(dinput_devices); i++) - { - if (!dinput_devices[i]->create_device) continue; - if (SUCCEEDED(hr = dinput_devices[i]->create_device( impl, guid, &device ))) - { - hr = IDirectInputDevice8_QueryInterface( device, iid, out ); - IDirectInputDevice8_Release( device ); - return hr; - } - } + if (IsEqualGUID( &GUID_SysKeyboard, guid )) hr = keyboard_create_device( impl, guid, &device ); + else if (IsEqualGUID( &GUID_SysMouse, guid )) hr = mouse_create_device( impl, guid, &device ); + else hr = hid_joystick_create_device( impl, guid, &device ); - WARN( "invalid device GUID %s\n", debugstr_guid( guid ) ); - return DIERR_DEVICENOTREG; + if (FAILED(hr)) return hr; + hr = IDirectInputDevice8_QueryInterface( device, iid, out ); + IDirectInputDevice8_Release( device ); + return hr; } static HRESULT WINAPI IDirectInputWImpl_CreateDevice(LPDIRECTINPUT7W iface, REFGUID rguid, diff --git a/dlls/dinput/dinput_private.h b/dlls/dinput/dinput_private.h index 553906e705d..e9b40bb95b6 100644 --- a/dlls/dinput/dinput_private.h +++ b/dlls/dinput/dinput_private.h @@ -60,8 +60,11 @@ struct dinput_device { }; extern HRESULT mouse_enum_device( DWORD type, DWORD flags, DIDEVICEINSTANCEW *instance, DWORD version, int index ); +extern HRESULT mouse_create_device( IDirectInputImpl *dinput, const GUID *guid, IDirectInputDevice8W **out ); extern HRESULT keyboard_enum_device( DWORD type, DWORD flags, DIDEVICEINSTANCEW *instance, DWORD version, int index ); +extern HRESULT keyboard_create_device( IDirectInputImpl *dinput, const GUID *guid, IDirectInputDevice8W **out ); extern HRESULT hid_joystick_enum_device( DWORD type, DWORD flags, DIDEVICEINSTANCEW *instance, DWORD version, int index ); +extern HRESULT hid_joystick_create_device( IDirectInputImpl *dinput, const GUID *guid, IDirectInputDevice8W **out ); struct DevicePlayer { GUID instance_guid; diff --git a/dlls/dinput/joystick_hid.c b/dlls/dinput/joystick_hid.c index 8ce55e67ef2..3419fed7d79 100644 --- a/dlls/dinput/joystick_hid.c +++ b/dlls/dinput/joystick_hid.c @@ -1737,7 +1737,7 @@ static BOOL init_pid_caps( struct hid_joystick *impl, struct hid_value_caps *cap return DIENUM_CONTINUE; } -static HRESULT hid_joystick_create_device( IDirectInputImpl *dinput, const GUID *guid, IDirectInputDevice8W **out ) +HRESULT hid_joystick_create_device( IDirectInputImpl *dinput, const GUID *guid, IDirectInputDevice8W **out ) { static const DIPROPHEADER filter = { diff --git a/dlls/dinput/keyboard.c b/dlls/dinput/keyboard.c index 4a3deb161f1..3b8f52b38f2 100644 --- a/dlls/dinput/keyboard.c +++ b/dlls/dinput/keyboard.c @@ -174,7 +174,7 @@ HRESULT keyboard_enum_device( DWORD type, DWORD flags, DIDEVICEINSTANCEW *instan return DI_OK; } -static HRESULT keyboard_create_device( IDirectInputImpl *dinput, const GUID *guid, IDirectInputDevice8W **out ) +HRESULT keyboard_create_device( IDirectInputImpl *dinput, const GUID *guid, IDirectInputDevice8W **out ) { SysKeyboardImpl *impl; HRESULT hr; diff --git a/dlls/dinput/mouse.c b/dlls/dinput/mouse.c index b120966717e..325d38c90d3 100644 --- a/dlls/dinput/mouse.c +++ b/dlls/dinput/mouse.c @@ -104,7 +104,7 @@ HRESULT mouse_enum_device( DWORD type, DWORD flags, DIDEVICEINSTANCEW *instance, return DI_OK; } -static HRESULT mouse_create_device( IDirectInputImpl *dinput, const GUID *guid, IDirectInputDevice8W **out ) +HRESULT mouse_create_device( IDirectInputImpl *dinput, const GUID *guid, IDirectInputDevice8W **out ) { SysMouseImpl *impl; HKEY hkey, appkey;