dinput: Return DIERR_INVALIDPARAM instead of DIERR_INPUTLOST from Acquire.

MSDN states that the function can only return one of DIERR_INVALIDPARAM,
DIERR_NOTINITIALIZED, DIERR_OTHERAPPHASPRIO, on error, and DI_OK, or
DI_NOEFFECT, on success.

Some games will try to call Acquire again in a tight loop and block the
main thread if DIERR_INPUTLOST is returned. There's a small chance for
this to happen with Resident Evil 2, whenever a joystick is plugged,
then quickly unplugged.

Signed-off-by: Rémi Bernon <rbernon@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Rémi Bernon 2021-12-22 14:46:16 +01:00 committed by Alexandre Julliard
parent ac442a78a1
commit ea93f283b5
1 changed files with 2 additions and 2 deletions

View File

@ -866,7 +866,7 @@ static HRESULT hid_joystick_acquire( IDirectInputDevice8W *iface )
{
impl->device = CreateFileW( impl->device_path, GENERIC_READ | GENERIC_WRITE, FILE_SHARE_READ | FILE_SHARE_WRITE,
NULL, OPEN_EXISTING, FILE_FLAG_OVERLAPPED | FILE_FLAG_NO_BUFFERING, 0 );
if (impl->device == INVALID_HANDLE_VALUE) return DIERR_INPUTLOST;
if (impl->device == INVALID_HANDLE_VALUE) return DIERR_INVALIDPARAM;
}
memset( &impl->read_ovl, 0, sizeof(impl->read_ovl) );
@ -876,7 +876,7 @@ static HRESULT hid_joystick_acquire( IDirectInputDevice8W *iface )
{
CloseHandle( impl->device );
impl->device = INVALID_HANDLE_VALUE;
return DIERR_INPUTLOST;
return DIERR_INVALIDPARAM;
}
IDirectInputDevice8_SendForceFeedbackCommand( iface, DISFFC_RESET );