From: Julian Smart Date: Fri, 9 Sep 2005 14:50:27 +0000 (+0000) Subject: Applied patch [ 1281902 ] fix for wxJoystick under Linux X-Git-Url: https://git.saurik.com/wxWidgets.git/commitdiff_plain/f50de1504e002ba3afac3491c8b4817870c850d8 Applied patch [ 1281902 ] fix for wxJoystick under Linux From John Ratliff git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@35447 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- diff --git a/src/unix/joystick.cpp b/src/unix/joystick.cpp index a9c434cbc1..eda239978d 100644 --- a/src/unix/joystick.cpp +++ b/src/unix/joystick.cpp @@ -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; }