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

Function eventProcess

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

Source from the content-addressed store, hash-verified

343}
344
345std::optional<sf::Event> eventProcess()
346{
347 const std::lock_guard lock(inputMutex);
348
349 // Ensure that we are initialized
350 initFileDescriptors();
351
352 // This is for handling the Backspace and DEL text events, which we
353 // generate based on keystrokes (and not stdin)
354 static unsigned int doDeferredText = 0;
355 if (doDeferredText)
356 {
357 const auto event = sf::Event::TextEntered{doDeferredText};
358
359 doDeferredText = 0;
360 return event;
361 }
362
363 ssize_t bytesRead = 0;
364
365 // Check all the open file descriptors for the next event
366 for (auto& fileDescriptor : fileDescriptors)
367 {
368 input_event inputEvent{};
369 bytesRead = read(fileDescriptor, &inputEvent, sizeof(inputEvent));
370
371 while (bytesRead > 0)
372 {
373 if (inputEvent.type == EV_KEY)
374 {
375 if (const std::optional<sf::Mouse::Button> mb = toMouseButton(inputEvent.code))
376 {
377 mouseMap[*mb] = inputEvent.value;
378
379 if (inputEvent.value)
380 return sf::Event::MouseButtonPressed{*mb, mousePos};
381
382 return sf::Event::MouseButtonReleased{*mb, mousePos};
383 }
384
385 const sf::Keyboard::Key kb = toKey(inputEvent.code);
386
387 unsigned int special = 0;
388 if ((kb == sf::Keyboard::Key::Delete) || (kb == sf::Keyboard::Key::Backspace))
389 special = (kb == sf::Keyboard::Key::Delete) ? 127 : 8;
390
391 if (inputEvent.value == 2)
392 {
393 // key repeat events
394 //
395 if (special)
396 {
397 return sf::Event::TextEntered{special};
398 }
399 }
400 else if (kb != sf::Keyboard::Key::Unknown)
401 {
402 // key down and key up events

Callers 2

updateFunction · 0.85
checkEventFunction · 0.85

Calls 10

initFileDescriptorsFunction · 0.85
toMouseButtonFunction · 0.85
toKeyFunction · 0.85
altDownFunction · 0.85
controlDownFunction · 0.85
shiftDownFunction · 0.85
systemDownFunction · 0.85
processSlotsFunction · 0.85
readFunction · 0.50
selectFunction · 0.50

Tested by

no test coverage detected