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

Method processSensorEvents

src/SFML/Window/WindowImpl.cpp:352–373  ·  view source on GitHub ↗

///////////////////////////////////////////////////////

Source from the content-addressed store, hash-verified

350
351////////////////////////////////////////////////////////////
352void WindowImpl::processSensorEvents()
353{
354 // First update the sensor states
355 SensorManager::getInstance().update();
356
357 for (unsigned int i = 0; i < Sensor::Count; ++i)
358 {
359 const auto sensor = static_cast<Sensor::Type>(i);
360
361 // Only process enabled sensors
362 if (SensorManager::getInstance().isEnabled(sensor))
363 {
364 // Copy the previous value of the sensor and get the new one
365 const Vector3f previousValue = m_sensorValue[sensor];
366 m_sensorValue[sensor] = SensorManager::getInstance().getValue(sensor);
367
368 // If the value has changed, trigger an event
369 if (m_sensorValue[sensor] != previousValue) // TODO use a threshold?
370 pushEvent(Event::SensorChanged{sensor, m_sensorValue[sensor]});
371 }
372 }
373}
374
375
376////////////////////////////////////////////////////////////

Callers

nothing calls this directly

Calls 4

pushEventFunction · 0.85
isEnabledMethod · 0.80
updateMethod · 0.45
getValueMethod · 0.45

Tested by

no test coverage detected