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

Function updatePluggedList

src/SFML/Window/NetBSD/JoystickImpl.cpp:107–136  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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

Callers 1

initializeMethod · 0.70

Calls 1

isJoystickFunction · 0.70

Tested by

no test coverage detected