X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/dcd5c3d0487b80a026c87bf67e887be0289bc4eb..3b96fc2f1b64f78bba7c755a5c14f618962f696b:/src/unix/joystick.cpp diff --git a/src/unix/joystick.cpp b/src/unix/joystick.cpp index a9c434cbc1..27720ea24e 100644 --- a/src/unix/joystick.cpp +++ b/src/unix/joystick.cpp @@ -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; }