MCPcopy Create free account
hub / github.com/SFML/SFML / isConnected

Method isConnected

src/SFML/Window/Unix/JoystickImpl.cpp:474–497  ·  view source on GitHub ↗

///////////////////////////////////////////////////////

Source from the content-addressed store, hash-verified

472
473////////////////////////////////////////////////////////////
474bool 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////////////////////////////////////////////////////////////
500bool JoystickImpl::open(unsigned int index)

Callers

nothing calls this directly

Calls 3

hasMonitorEventFunction · 0.85
getMethod · 0.80
updatePluggedListFunction · 0.70

Tested by

no test coverage detected