]> git.saurik.com Git - wxWidgets.git/commitdiff
Applied patch [ 1281902 ] fix for wxJoystick under Linux
authorJulian Smart <julian@anthemion.co.uk>
Fri, 9 Sep 2005 14:50:27 +0000 (14:50 +0000)
committerJulian Smart <julian@anthemion.co.uk>
Fri, 9 Sep 2005 14:50:27 +0000 (14:50 +0000)
From John Ratliff

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@35447 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

src/unix/joystick.cpp

index a9c434cbc15e3616a1a31cc76131ee03954dabd9..eda239978da1d36bfdf5a4656cfa4ee92ea926ba 100644 (file)
@@ -184,13 +184,13 @@ wxJoystick::wxJoystick(int joystick)
     wxString dev_name;
 
      // old /dev structure
-    dev_name.Printf( wxT("/dev/js%d"), (joystick == wxJOYSTICK1) ? 0 : 1);
+    dev_name.Printf( wxT("/dev/js%d"), joystick);
     m_device = open(dev_name.fn_str(), O_RDONLY);
 
     // new /dev structure with "input" subdirectory
     if (m_device == -1)
     {
-        dev_name.Printf( wxT("/dev/input/js%d"), (joystick == wxJOYSTICK1) ? 0 : 1);
+        dev_name.Printf( wxT("/dev/input/js%d"), joystick);
         m_device = open(dev_name.fn_str(), O_RDONLY);             
     }
 
@@ -295,9 +295,20 @@ int wxJoystick::GetNumberJoysticks() const
         dev_name.Printf(wxT("/dev/js%d"), j);
         fd = open(dev_name.fn_str(), O_RDONLY);
         if (fd == -1)
-            return j;
+            break;
         close(fd);
     }
+    
+    if (j == 0) {
+        for (j=0; j<4; j++) {
+            dev_name.Printf(wxT("/dev/input/js%d"), j);
+            fd = open(dev_name.fn_str(), O_RDONLY);
+            if (fd == -1)
+                return j;
+            close(fd);
+        }
+    }
+    
     return j;
 }