Improved joystick detection performances on Linux (avoids endless calls to open when a joystick node cannot be open)
This commit is contained in:
parent
5ffe258320
commit
77238767ee
@ -46,8 +46,17 @@ namespace
|
||||
{
|
||||
char name[32];
|
||||
std::snprintf(name, sizeof(name), "/dev/input/js%u", i);
|
||||
struct stat info;
|
||||
plugged[i] = (stat(name, &info) == 0);
|
||||
|
||||
int file = ::open(name, O_RDONLY);
|
||||
if (file >= 0)
|
||||
{
|
||||
plugged[i] = true;
|
||||
::close(file);
|
||||
}
|
||||
else
|
||||
{
|
||||
plugged[i] = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user