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

Function updatePluggedList

src/SFML/Window/FreeBSD/JoystickImpl.cpp:106–135  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

104}
105
106void updatePluggedList()
107{
108 /*
109 * Devices /dev/uhid<x> are shared between joystick and any other
110 * human interface device. We need to iterate over all found devices
111 * and check if they are joysticks. The index of JoystickImpl::open
112 * does not match the /dev/uhid<index> device!
113 */
114 if (DIR* directory = opendir("/dev"))
115 {
116 unsigned int joystickCount = 0;
117 struct dirent* directoryEntry = readdir(directory);
118
119 while (directoryEntry && joystickCount < sf::Joystick::Count)
120 {
121 if (!std::strncmp(directoryEntry->d_name, "uhid", 4))
122 {
123 std::string name("/dev/");
124 name += directoryEntry->d_name;
125
126 if (isJoystick(name.c_str()))
127 plugged[static_cast<unsigned int>(joystickCount++)] = name;
128 }
129
130 directoryEntry = readdir(directory);
131 }
132
133 closedir(directory);
134 }
135}
136
137std::optional<sf::Joystick::Axis> usageToAxis(int usage)
138{

Callers 1

initializeMethod · 0.70

Calls 1

isJoystickFunction · 0.70

Tested by

no test coverage detected