Vitaliy Margolen : dinput: Fix remaining formatting of the find_joydevs().

Alexandre Julliard julliard at winehq.org
Mon Dec 29 08:47:37 CST 2008


Module: wine
Branch: master
Commit: 8b09a8eb9db3afe1481744570d4bf813e2487592
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=8b09a8eb9db3afe1481744570d4bf813e2487592

Author: Vitaliy Margolen <wine-patches at kievinfo.com>
Date:   Sun Dec 28 13:41:08 2008 -0700

dinput: Fix remaining formatting of the find_joydevs().

---

 dlls/dinput/joystick_linuxinput.c |   41 +++++++++++++++++++-----------------
 1 files changed, 22 insertions(+), 19 deletions(-)

diff --git a/dlls/dinput/joystick_linuxinput.c b/dlls/dinput/joystick_linuxinput.c
index b07166c..2511750 100644
--- a/dlls/dinput/joystick_linuxinput.c
+++ b/dlls/dinput/joystick_linuxinput.c
@@ -263,27 +263,30 @@ static void find_joydevs(void)
             continue;
         }
 
-      /* A true joystick has at least axis X and Y, and at least 1
-       * button. copied from linux/drivers/input/joydev.c */
-      if (test_bit(joydev.absbits,ABS_X) && test_bit(joydev.absbits,ABS_Y) &&
-          (   test_bit(joydev.keybits,BTN_TRIGGER)	||
-              test_bit(joydev.keybits,BTN_A) 	||
-              test_bit(joydev.keybits,BTN_1)
-          )
-         ) {
-
-        if (!(joydev.device = HeapAlloc(GetProcessHeap(), 0, strlen(buf) + 1))) {
-          close(fd);
-          continue;
+        /* A true joystick has at least axis X and Y, and at least 1
+         * button. copied from linux/drivers/input/joydev.c */
+        if (!test_bit(joydev.absbits, ABS_X) || !test_bit(joydev.absbits, ABS_Y) ||
+            !(test_bit(joydev.keybits, BTN_TRIGGER) ||
+              test_bit(joydev.keybits, BTN_A) ||
+              test_bit(joydev.keybits, BTN_1)))
+        {
+            close(fd);
+            continue;
+        }
+
+        if (!(joydev.device = HeapAlloc(GetProcessHeap(), 0, strlen(buf) + 1)))
+        {
+            close(fd);
+            continue;
         }
         strcpy(joydev.device, buf);
 
         buf[MAX_PATH - 1] = 0;
         if (ioctl(fd, EVIOCGNAME(MAX_PATH - 1), buf) != -1 &&
             (joydev.name = HeapAlloc(GetProcessHeap(), 0, strlen(buf) + 1)))
-          strcpy(joydev.name, buf);
+            strcpy(joydev.name, buf);
         else
-          joydev.name = joydev.device;
+            joydev.name = joydev.device;
 
 	joydev.guid = DInput_Wine_Joystick_Base_GUID;
 	joydev.guid.Data3 += have_joydevs;
@@ -305,9 +308,11 @@ static void find_joydevs(void)
         }
 #endif
 
-	for (j=0;j<ABS_MAX;j++) {
-	  if (test_bit(joydev.absbits,j)) {
-	    if (-1!=ioctl(fd,EVIOCGABS(j),&(joydev.axes[j]))) {
+        for (j = 0; j < ABS_MAX;j ++)
+        {
+            if (!test_bit(joydev.absbits, j)) continue;
+            if (ioctl(fd, EVIOCGABS(j), &(joydev.axes[j])) != -1)
+            {
 	      TRACE(" ... with axis %d: cur=%d, min=%d, max=%d, fuzz=%d, flat=%d\n",
 		  j,
 		  joydev.axes[j].value,
@@ -317,7 +322,6 @@ static void find_joydevs(void)
 		  joydev.axes[j].flat
 		  );
 	    }
-	  }
 	}
 
         if (!have_joydevs)
@@ -333,7 +337,6 @@ static void find_joydevs(void)
         joydevs = new_joydevs;
         memcpy(joydevs + have_joydevs, &joydev, sizeof(joydev));
         have_joydevs++;
-      }
 
         close(fd);
     }




More information about the wine-cvs mailing list