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