///////////////////////////////////////////////////////
| 350 | |
| 351 | //////////////////////////////////////////////////////////// |
| 352 | void 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 | //////////////////////////////////////////////////////////// |