Rémi Bernon : dinput: Factor all Poll implementations together.

Alexandre Julliard julliard at winehq.org
Wed Oct 20 15:58:41 CDT 2021


Module: wine
Branch: master
Commit: aebd03f07087fdff5cd83b1c4d9ecc930658b61c
URL:    https://source.winehq.org/git/wine.git/?a=commit;h=aebd03f07087fdff5cd83b1c4d9ecc930658b61c

Author: Rémi Bernon <rbernon at codeweavers.com>
Date:   Wed Oct 20 11:29:30 2021 +0200

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 at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 dlls/dinput/device.c         | 12 ++++++++----
 dlls/dinput/device_private.h |  1 +
 dlls/dinput/joystick_hid.c   | 15 ++-------------
 dlls/dinput/keyboard.c       |  7 +++++++
 dlls/dinput/mouse.c          |  7 +++++++
 5 files changed, 25 insertions(+), 17 deletions(-)

diff --git a/dlls/dinput/device.c b/dlls/dinput/device.c
index 2b2c4646e31..c31166b8248 100644
--- a/dlls/dinput/device.c
+++ b/dlls/dinput/device.c
@@ -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;
 }
 
diff --git a/dlls/dinput/device_private.h b/dlls/dinput/device_private.h
index da1a90fda42..92b0320520b 100644
--- a/dlls/dinput/device_private.h
+++ b/dlls/dinput/device_private.h
@@ -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 );
diff --git a/dlls/dinput/joystick_hid.c b/dlls/dinput/joystick_hid.c
index 5718f02bf47..59e5e4a719f 100644
--- a/dlls/dinput/joystick_hid.c
+++ b/dlls/dinput/joystick_hid.c
@@ -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,
diff --git a/dlls/dinput/keyboard.c b/dlls/dinput/keyboard.c
index ad91c948fbc..a8f831e7597 100644
--- a/dlls/dinput/keyboard.c
+++ b/dlls/dinput/keyboard.c
@@ -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,
diff --git a/dlls/dinput/mouse.c b/dlls/dinput/mouse.c
index 5b3ec2d1f20..5933d7e5f0f 100644
--- a/dlls/dinput/mouse.c
+++ b/dlls/dinput/mouse.c
@@ -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,




More information about the wine-cvs mailing list