]> git.saurik.com Git - wxWidgets.git/blobdiff - src/unix/joystick.cpp
adding missing file
[wxWidgets.git] / src / unix / joystick.cpp
index 0a32033ee32aad2cf472b190f297db1e44a2ef78..eda239978da1d36bfdf5a4656cfa4ee92ea926ba 100644 (file)
@@ -183,10 +183,17 @@ wxJoystick::wxJoystick(int joystick)
 {
     wxString dev_name;
 
-     // Assume it's the same device name on all Linux systems ...
-    dev_name.Printf( wxT("/dev/js%d"), (joystick == wxJOYSTICK1) ? 0 : 1);
+     // old /dev structure
+    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);
+        m_device = open(dev_name.fn_str(), O_RDONLY);             
+    }
+
     if (m_device != -1)
     {
         m_thread = new wxJoystickThread(m_device, m_joystick);
@@ -288,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;
 }