dinput: Factor all Poll implementations together.

With a new internal poll callback for mouse and keyboard Wine-specific
message peeking behavior.

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-10-20 11:29:30 +02:00 committed by Alexandre Julliard
parent ec3e51bb10
commit aebd03f070
5 changed files with 25 additions and 17 deletions

View File

@ -1661,13 +1661,17 @@ HRESULT WINAPI IDirectInputDevice2WImpl_Escape(LPDIRECTINPUTDEVICE8W iface, LPDI
return DI_OK;
}
HRESULT WINAPI IDirectInputDevice2WImpl_Poll(LPDIRECTINPUTDEVICE8W iface)
HRESULT WINAPI IDirectInputDevice2WImpl_Poll( IDirectInputDevice8W *iface )
{
IDirectInputDeviceImpl *This = impl_from_IDirectInputDevice8W(iface);
IDirectInputDeviceImpl *impl = impl_from_IDirectInputDevice8W( iface );
HRESULT hr = DI_NOEFFECT;
if (!This->acquired) return DIERR_NOTACQUIRED;
EnterCriticalSection( &impl->crit );
if (!impl->acquired) hr = DIERR_NOTACQUIRED;
LeaveCriticalSection( &impl->crit );
if (hr != DI_OK) return hr;
check_dinput_events();
if (impl->vtbl->poll) return impl->vtbl->poll( iface );
return DI_OK;
}

View File

@ -57,6 +57,7 @@ typedef HRESULT dinput_device_read_state( IDirectInputDevice8W *iface );
struct dinput_device_vtbl
{
HRESULT (*poll)( IDirectInputDevice8W *iface );
HRESULT (*read)( IDirectInputDevice8W *iface );
HRESULT (*acquire)( IDirectInputDevice8W *iface );
HRESULT (*unacquire)( IDirectInputDevice8W *iface );

View File

@ -1162,18 +1162,6 @@ static HRESULT WINAPI hid_joystick_EnumCreatedEffectObjects( IDirectInputDevice8
return DI_OK;
}
static HRESULT WINAPI hid_joystick_Poll( IDirectInputDevice8W *iface )
{
struct hid_joystick *impl = impl_from_IDirectInputDevice8W( iface );
HRESULT hr = DI_NOEFFECT;
EnterCriticalSection( &impl->base.crit );
if (!impl->base.acquired) hr = DIERR_NOTACQUIRED;
LeaveCriticalSection( &impl->base.crit );
return hr;
}
static const IDirectInputDevice8WVtbl hid_joystick_vtbl =
{
/*** IUnknown methods ***/
@ -1204,7 +1192,7 @@ static const IDirectInputDevice8WVtbl hid_joystick_vtbl =
hid_joystick_SendForceFeedbackCommand,
hid_joystick_EnumCreatedEffectObjects,
IDirectInputDevice2WImpl_Escape,
hid_joystick_Poll,
IDirectInputDevice2WImpl_Poll,
IDirectInputDevice2WImpl_SendDeviceData,
/*** IDirectInputDevice7 methods ***/
IDirectInputDevice7WImpl_EnumEffectsInFile,
@ -1432,6 +1420,7 @@ static HRESULT hid_joystick_internal_enum_objects( IDirectInputDevice8W *iface,
static const struct dinput_device_vtbl hid_joystick_internal_vtbl =
{
NULL,
hid_joystick_internal_read,
hid_joystick_internal_acquire,
hid_joystick_internal_unacquire,

View File

@ -270,6 +270,12 @@ static HRESULT WINAPI SysKeyboardWImpl_GetDeviceState(LPDIRECTINPUTDEVICE8W ifac
return DI_OK;
}
static HRESULT keyboard_internal_poll( IDirectInputDevice8W *iface )
{
check_dinput_events();
return DI_OK;
}
static HRESULT keyboard_internal_acquire( IDirectInputDevice8W *iface )
{
return DI_OK;
@ -353,6 +359,7 @@ static HRESULT keyboard_internal_set_property( IDirectInputDevice8W *iface, DWOR
static const struct dinput_device_vtbl keyboard_internal_vtbl =
{
keyboard_internal_poll,
NULL,
keyboard_internal_acquire,
keyboard_internal_unacquire,

View File

@ -490,6 +490,12 @@ static HRESULT WINAPI SysMouseWImpl_GetDeviceData(LPDIRECTINPUTDEVICE8W iface,
return res;
}
static HRESULT mouse_internal_poll( IDirectInputDevice8W *iface )
{
check_dinput_events();
return DI_OK;
}
static HRESULT mouse_internal_acquire( IDirectInputDevice8W *iface )
{
SysMouseImpl *impl = impl_from_IDirectInputDevice8W( iface );
@ -683,6 +689,7 @@ static HRESULT mouse_internal_set_property( IDirectInputDevice8W *iface, DWORD p
static const struct dinput_device_vtbl mouse_internal_vtbl =
{
mouse_internal_poll,
NULL,
mouse_internal_acquire,
mouse_internal_unacquire,