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:
@@ -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);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -294,10 +294,21 @@ int wxJoystick::GetNumberJoysticks() const
|
|||||||
for (j=0; j<4; j++) {
|
for (j=0; j<4; j++) {
|
||||||
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)
|
||||||
|
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)
|
if (fd == -1)
|
||||||
return j;
|
return j;
|
||||||
close(fd);
|
close(fd);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return j;
|
return j;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user