| 105 | } |
| 106 | |
| 107 | void 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 | |
| 138 | std::optional<sf::Joystick::Axis> usageToAxis(int usage) |
| 139 | { |
no test coverage detected