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

Function initFileDescriptors

src/SFML/Window/DRM/InputImpl.cpp:137–169  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

135}
136
137void 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
171std::optional<sf::Mouse::Button> toMouseButton(int code)
172{

Callers 3

eventProcessFunction · 0.85
setTerminalConfigFunction · 0.85
restoreTerminalConfigFunction · 0.85

Calls 2

keepFileDescriptorFunction · 0.85
closeFunction · 0.85

Tested by

no test coverage detected