dinput: Utilize IDirectInputDevice2AImpl_Acquire/Unacquire

Christoph Frick frick at sc-networks.de
Mon Dec 11 03:04:49 CST 2006


This calls the common acquire methods which keep track about it properly and
set the acquired flag properly.

This fixes the one part of the problems with IL2; GetDeviceData can not be
callced on unacquired devices and the acquire implementation of the joystick
input code had not set it properly.
---
 dlls/dinput/joystick_linuxinput.c |   39 +++++++++++++++++++-----------------
 1 files changed, 21 insertions(+), 18 deletions(-)

diff --git a/dlls/dinput/joystick_linuxinput.c b/dlls/dinput/joystick_linuxinput.c
index 0ba4877..661a4db 100644
--- a/dlls/dinput/joystick_linuxinput.c
+++ b/dlls/dinput/joystick_linuxinput.c
@@ -605,26 +605,29 @@ static HRESULT WINAPI JoystickAImpl_SetD
 static HRESULT WINAPI JoystickAImpl_Acquire(LPDIRECTINPUTDEVICE8A iface)
 {
     JoystickImpl *This = (JoystickImpl *)iface;
+    HRESULT res;
 
     TRACE("(this=%p)\n",This);
-    if (This->joyfd!=-1)
-    	return S_FALSE;
+
     if (This->df==NULL) {
       return DIERR_INVALIDPARAM;
     }
-
-    if (-1==(This->joyfd=open(This->joydev->device,O_RDWR))) { 
-      if (-1==(This->joyfd=open(This->joydev->device,O_RDONLY))) {
-        /* Couldn't open the device at all */ 
-        perror(This->joydev->device);
-        return DIERR_NOTFOUND;
-      } else {
-        /* Couldn't open in r/w but opened in read-only. */
-        WARN("Could not open %s in read-write mode.  Force feedback will be disabled.\n", This->joydev->device);
+    res = IDirectInputDevice2AImpl_Acquire(iface);
+    if (res==DI_OK) {
+      if (-1==(This->joyfd=open(This->joydev->device,O_RDWR))) { 
+        if (-1==(This->joyfd=open(This->joydev->device,O_RDONLY))) {
+          /* Couldn't open the device at all */ 
+          perror(This->joydev->device);
+          IDirectInputDevice2AImpl_Unacquire(iface);
+          return DIERR_NOTFOUND;
+        } else {
+          /* Couldn't open in r/w but opened in read-only. */
+          WARN("Could not open %s in read-write mode.  Force feedback will be disabled.\n", This->joydev->device);
+        }
       }
     }
 
-    return 0;
+    return res;
 }
 
 /******************************************************************************
@@ -633,15 +636,15 @@ static HRESULT WINAPI JoystickAImpl_Acqu
 static HRESULT WINAPI JoystickAImpl_Unacquire(LPDIRECTINPUTDEVICE8A iface)
 {
     JoystickImpl *This = (JoystickImpl *)iface;
+    HRESULT res;
 
     TRACE("(this=%p)\n",This);
-    if (This->joyfd!=-1) {
-  	close(This->joyfd);
-	This->joyfd = -1;
-	return DI_OK;
+    res = IDirectInputDevice2AImpl_Unacquire(iface);
+    if (res==DI_OK && This->joyfd!=-1) {
+      close(This->joyfd);
+      This->joyfd = -1;
     }
-    else 
-    	return DI_NOEFFECT;
+    return res;
 }
 
 /*
-- 
1.4.4.1

-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 163 bytes
Desc: not available
Url : http://www.winehq.org/pipermail/wine-patches/attachments/20061211/739eda88/attachment.pgp


More information about the wine-patches mailing list