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
This commit is contained in:
Julian Smart
2005-09-09 14:50:27 +00:00
parent 60b0bd1dd1
commit f50de1504e

View File

@@ -184,13 +184,13 @@ wxJoystick::wxJoystick(int joystick)
wxString dev_name; wxString dev_name;
// old /dev structure // 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); m_device = open(dev_name.fn_str(), O_RDONLY);
// new /dev structure with "input" subdirectory // new /dev structure with "input" subdirectory
if (m_device == -1) 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); 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); dev_name.Printf(wxT("/dev/js%d"), j);
fd = open(dev_name.fn_str(), O_RDONLY); fd = open(dev_name.fn_str(), O_RDONLY);
if (fd == -1) if (fd == -1)
return j; break;
close(fd); 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; return j;
} }