From f50de1504e002ba3afac3491c8b4817870c850d8 Mon Sep 17 00:00:00 2001 From: Julian Smart Date: Fri, 9 Sep 2005 14:50:27 +0000 Subject: [PATCH] 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 --- src/unix/joystick.cpp | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) 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; } -- 2.45.2