| 135 | } |
| 136 | |
| 137 | void initFileDescriptors() |
| 138 | { |
| 139 | static bool initialized = false; |
| 140 | if (initialized) |
| 141 | return; |
| 142 | |
| 143 | initialized = true; |
| 144 | |
| 145 | for (int i = 0; i < 32; i++) |
| 146 | { |
| 147 | std::string name("/dev/input/event"); |
| 148 | std::ostringstream stream; |
| 149 | stream << i; |
| 150 | name += stream.str(); |
| 151 | |
| 152 | const int tempFD = open(name.c_str(), O_RDONLY | O_NONBLOCK); |
| 153 | |
| 154 | if (tempFD < 0) |
| 155 | { |
| 156 | if (errno != ENOENT) |
| 157 | sf::err() << "Error opening " << name << ": " << std::strerror(errno) << std::endl; |
| 158 | |
| 159 | continue; |
| 160 | } |
| 161 | |
| 162 | if (keepFileDescriptor(tempFD)) |
| 163 | fileDescriptors.push_back(tempFD); |
| 164 | else |
| 165 | close(tempFD); |
| 166 | } |
| 167 | |
| 168 | std::atexit(uninitFileDescriptors); |
| 169 | } |
| 170 | |
| 171 | std::optional<sf::Mouse::Button> toMouseButton(int code) |
| 172 | { |
no test coverage detected