///////////////////////////////////////////////////////
| 472 | |
| 473 | //////////////////////////////////////////////////////////// |
| 474 | bool JoystickImpl::isConnected(unsigned int index) |
| 475 | { |
| 476 | // See if we can skip scanning if udev monitor is available |
| 477 | if (!udevMonitor) |
| 478 | { |
| 479 | // udev monitor is not available, perform a scan every query |
| 480 | updatePluggedList(); |
| 481 | } |
| 482 | else if (hasMonitorEvent()) |
| 483 | { |
| 484 | // Check if new joysticks were added/removed since last update |
| 485 | const auto udevDevice = UdevPtr<udev_device>(udev_monitor_receive_device(udevMonitor.get())); |
| 486 | |
| 487 | // If we can get the specific device, we check that, |
| 488 | // otherwise just do a full scan if udevDevice == nullptr |
| 489 | updatePluggedList(udevDevice.get()); |
| 490 | } |
| 491 | |
| 492 | if (index >= joystickList.size()) |
| 493 | return false; |
| 494 | |
| 495 | // Then check if the joystick is connected |
| 496 | return joystickList[index].plugged; |
| 497 | } |
| 498 | |
| 499 | //////////////////////////////////////////////////////////// |
| 500 | bool JoystickImpl::open(unsigned int index) |
nothing calls this directly
no test coverage detected