dinput: Return an HRESULT from hid_joystick_device_try_open.
Signed-off-by: Rémi Bernon <rbernon@codeweavers.com> Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
ac7fa1677a
commit
10b00e66bc
|
@ -1413,9 +1413,9 @@ static DWORD device_type_for_version( DWORD type, DWORD version )
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static BOOL hid_joystick_device_try_open( UINT32 handle, const WCHAR *path, HANDLE *device,
|
static HRESULT hid_joystick_device_try_open( UINT32 handle, const WCHAR *path, HANDLE *device,
|
||||||
PHIDP_PREPARSED_DATA *preparsed, HIDD_ATTRIBUTES *attrs,
|
PHIDP_PREPARSED_DATA *preparsed, HIDD_ATTRIBUTES *attrs,
|
||||||
HIDP_CAPS *caps, DIDEVICEINSTANCEW *instance, DWORD version )
|
HIDP_CAPS *caps, DIDEVICEINSTANCEW *instance, DWORD version )
|
||||||
{
|
{
|
||||||
BOOL has_accelerator, has_brake, has_clutch, has_z, has_pov;
|
BOOL has_accelerator, has_brake, has_clutch, has_z, has_pov;
|
||||||
PHIDP_PREPARSED_DATA preparsed_data = NULL;
|
PHIDP_PREPARSED_DATA preparsed_data = NULL;
|
||||||
|
@ -1430,7 +1430,7 @@ static BOOL hid_joystick_device_try_open( UINT32 handle, const WCHAR *path, HAND
|
||||||
|
|
||||||
device_file = CreateFileW( path, GENERIC_READ | GENERIC_WRITE, FILE_SHARE_READ | FILE_SHARE_WRITE,
|
device_file = CreateFileW( path, GENERIC_READ | GENERIC_WRITE, FILE_SHARE_READ | FILE_SHARE_WRITE,
|
||||||
NULL, OPEN_EXISTING, FILE_FLAG_OVERLAPPED | FILE_FLAG_NO_BUFFERING, 0 );
|
NULL, OPEN_EXISTING, FILE_FLAG_OVERLAPPED | FILE_FLAG_NO_BUFFERING, 0 );
|
||||||
if (device_file == INVALID_HANDLE_VALUE) return FALSE;
|
if (device_file == INVALID_HANDLE_VALUE) return DIERR_DEVICENOTREG;
|
||||||
|
|
||||||
if (!HidD_GetPreparsedData( device_file, &preparsed_data )) goto failed;
|
if (!HidD_GetPreparsedData( device_file, &preparsed_data )) goto failed;
|
||||||
if (!HidD_GetAttributes( device_file, attrs )) goto failed;
|
if (!HidD_GetAttributes( device_file, attrs )) goto failed;
|
||||||
|
@ -1556,12 +1556,12 @@ static BOOL hid_joystick_device_try_open( UINT32 handle, const WCHAR *path, HAND
|
||||||
|
|
||||||
*device = device_file;
|
*device = device_file;
|
||||||
*preparsed = preparsed_data;
|
*preparsed = preparsed_data;
|
||||||
return TRUE;
|
return DI_OK;
|
||||||
|
|
||||||
failed:
|
failed:
|
||||||
CloseHandle( device_file );
|
CloseHandle( device_file );
|
||||||
HidD_FreePreparsedData( preparsed_data );
|
HidD_FreePreparsedData( preparsed_data );
|
||||||
return FALSE;
|
return DIERR_DEVICENOTREG;
|
||||||
}
|
}
|
||||||
|
|
||||||
static HRESULT hid_joystick_device_open( int index, DIDEVICEINSTANCEW *filter, WCHAR *device_path,
|
static HRESULT hid_joystick_device_open( int index, DIDEVICEINSTANCEW *filter, WCHAR *device_path,
|
||||||
|
@ -1600,8 +1600,8 @@ static HRESULT hid_joystick_device_open( int index, DIDEVICEINSTANCEW *filter, W
|
||||||
(BYTE *)&handle, sizeof(handle), NULL, 0 ) ||
|
(BYTE *)&handle, sizeof(handle), NULL, 0 ) ||
|
||||||
type != DEVPROP_TYPE_UINT32)
|
type != DEVPROP_TYPE_UINT32)
|
||||||
continue;
|
continue;
|
||||||
if (!hid_joystick_device_try_open( handle, detail->DevicePath, device, preparsed,
|
if (FAILED(hid_joystick_device_try_open( handle, detail->DevicePath, device, preparsed,
|
||||||
attrs, caps, &instance, version ))
|
attrs, caps, &instance, version )))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (device_instance_is_disabled( &instance, &override ))
|
if (device_instance_is_disabled( &instance, &override ))
|
||||||
|
@ -1620,8 +1620,8 @@ static HRESULT hid_joystick_device_open( int index, DIDEVICEINSTANCEW *filter, W
|
||||||
|
|
||||||
CloseHandle( *device );
|
CloseHandle( *device );
|
||||||
HidD_FreePreparsedData( *preparsed );
|
HidD_FreePreparsedData( *preparsed );
|
||||||
if (!hid_joystick_device_try_open( handle, detail->DevicePath, device, preparsed,
|
if (FAILED(hid_joystick_device_try_open( handle, detail->DevicePath, device, preparsed,
|
||||||
attrs, caps, &instance, version ))
|
attrs, caps, &instance, version )))
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2062,9 +2062,8 @@ HRESULT hid_joystick_create_device( struct dinput *dinput, const GUID *guid, IDi
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
wcscpy( impl->device_path, *(const WCHAR **)guid );
|
wcscpy( impl->device_path, *(const WCHAR **)guid );
|
||||||
if (!hid_joystick_device_try_open( 0, impl->device_path, &impl->device, &impl->preparsed, &attrs,
|
hr = hid_joystick_device_try_open( 0, impl->device_path, &impl->device, &impl->preparsed, &attrs,
|
||||||
&impl->caps, &instance, dinput->dwVersion ))
|
&impl->caps, &instance, dinput->dwVersion );
|
||||||
hr = DIERR_DEVICENOTREG;
|
|
||||||
}
|
}
|
||||||
if (hr != DI_OK) goto failed;
|
if (hr != DI_OK) goto failed;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue