]> git.saurik.com Git - wxWidgets.git/blobdiff - src/unix/joystick.cpp
Trace module initialization and cleanup.
[wxWidgets.git] / src / unix / joystick.cpp
index a9c434cbc15e3616a1a31cc76131ee03954dabd9..27720ea24eca64b4dd7d377efcbf10c7fb21626e 100644 (file)
@@ -9,10 +9,6 @@
 // Licence:     wxWindows licence
 /////////////////////////////////////////////////////////////////////////////
 
-#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
-#pragma implementation "joystick.h"
-#endif
-
 // for compilers that support precompilation, includes "wx.h".
 #include "wx/wxprec.h"
 
@@ -184,13 +180,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 +291,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;
 }