Aric Stewart : dinput: Create generic joystick Acquire/Unacquire.
Alexandre Julliard
julliard at winehq.org
Tue Mar 10 10:53:33 CDT 2009
Module: wine
Branch: master
Commit: 5dbe136027463a3c14d8379408167e2b3e274caa
URL: http://source.winehq.org/git/wine.git/?a=commit;h=5dbe136027463a3c14d8379408167e2b3e274caa
Author: Aric Stewart <aric at codeweavers.com>
Date: Mon Mar 9 10:07:35 2009 -0500
dinput: Create generic joystick Acquire/Unacquire.
---
dlls/dinput/joystick.c | 34 ++++++++++++++++++++++++++++++++++
dlls/dinput/joystick_linux.c | 16 +++++++++-------
dlls/dinput/joystick_private.h | 4 ++++
3 files changed, 47 insertions(+), 7 deletions(-)
diff --git a/dlls/dinput/joystick.c b/dlls/dinput/joystick.c
index a19cf27..6e7e7ef 100644
--- a/dlls/dinput/joystick.c
+++ b/dlls/dinput/joystick.c
@@ -32,6 +32,40 @@
WINE_DEFAULT_DEBUG_CHANNEL(dinput);
/******************************************************************************
+ * Acquire : gets exclusive control of the joystick
+ */
+HRESULT WINAPI JoystickAGenericImpl_Acquire(LPDIRECTINPUTDEVICE8A iface)
+{
+ JoystickGenericImpl *This = (JoystickGenericImpl *)iface;
+
+ TRACE("(%p)\n",This);
+
+ if (This->base.acquired) {
+ WARN("already acquired\n");
+ return S_FALSE;
+ }
+
+ This->base.acquired = 1;
+
+ return DI_OK;
+}
+
+/******************************************************************************
+ * Unacquire : frees the joystick
+ */
+HRESULT WINAPI JoystickAGenericImpl_Unacquire(LPDIRECTINPUTDEVICE8A iface)
+{
+ JoystickGenericImpl *This = (JoystickGenericImpl *)iface;
+ HRESULT res;
+
+ TRACE("(%p)\n",This);
+
+ if ((res = IDirectInputDevice2AImpl_Unacquire(iface)) != DI_OK) return res;
+
+ return DI_OK;
+}
+
+/******************************************************************************
* SetProperty : change input device properties
*/
HRESULT WINAPI JoystickAGenericImpl_SetProperty(
diff --git a/dlls/dinput/joystick_linux.c b/dlls/dinput/joystick_linux.c
index 67ec02b..afabebe 100644
--- a/dlls/dinput/joystick_linux.c
+++ b/dlls/dinput/joystick_linux.c
@@ -605,13 +605,13 @@ const struct dinput_device joystick_linux_device = {
static HRESULT WINAPI JoystickLinuxAImpl_Acquire(LPDIRECTINPUTDEVICE8A iface)
{
JoystickImpl *This = (JoystickImpl *)iface;
+ HRESULT res;
TRACE("(%p)\n",This);
- if (This->generic.base.acquired) {
- WARN("already acquired\n");
- return S_FALSE;
- }
+ res = JoystickAGenericImpl_Acquire(iface);
+ if (res != DI_OK)
+ return res;
/* open the joystick device */
if (This->joyfd==-1) {
@@ -620,12 +620,11 @@ static HRESULT WINAPI JoystickLinuxAImpl_Acquire(LPDIRECTINPUTDEVICE8A iface)
This->joyfd=open(This->dev,O_RDONLY);
if (This->joyfd==-1) {
ERR("open(%s) failed: %s\n", This->dev, strerror(errno));
+ JoystickAGenericImpl_Unacquire(iface);
return DIERR_NOTFOUND;
}
}
- This->generic.base.acquired = 1;
-
return DI_OK;
}
@@ -639,7 +638,10 @@ static HRESULT WINAPI JoystickLinuxAImpl_Unacquire(LPDIRECTINPUTDEVICE8A iface)
TRACE("(%p)\n",This);
- if ((res = IDirectInputDevice2AImpl_Unacquire(iface)) != DI_OK) return res;
+ res = JoystickAGenericImpl_Unacquire(iface);
+
+ if (res != DI_OK)
+ return res;
if (This->joyfd!=-1) {
TRACE("closing joystick device\n");
diff --git a/dlls/dinput/joystick_private.h b/dlls/dinput/joystick_private.h
index e1709e9..b61406f 100644
--- a/dlls/dinput/joystick_private.h
+++ b/dlls/dinput/joystick_private.h
@@ -78,4 +78,8 @@ HRESULT WINAPI JoystickAGenericImpl_Poll(LPDIRECTINPUTDEVICE8A iface);
HRESULT WINAPI JoystickAGenericImpl_GetDeviceState( LPDIRECTINPUTDEVICE8A iface,
DWORD len, LPVOID ptr);
+HRESULT WINAPI JoystickAGenericImpl_Acquire(LPDIRECTINPUTDEVICE8A iface);
+
+HRESULT WINAPI JoystickAGenericImpl_Unacquire(LPDIRECTINPUTDEVICE8A iface);
+
#endif /* __WINE_DLLS_DINPUT_JOYSTICK_PRIVATE_H */
More information about the wine-cvs
mailing list