| 366 | } |
| 367 | |
| 368 | void InputManager::OculusTouch::HapticsThread(OculusTouch* device) |
| 369 | { |
| 370 | std::chrono::microseconds freq(std::chrono::seconds(1)); |
| 371 | freq /= REV_HAPTICS_SAMPLE_RATE; |
| 372 | |
| 373 | while (device->m_bHapticsRunning) |
| 374 | { |
| 375 | vr::TrackedDeviceIndex_t touch = vr::VRSystem()->GetTrackedDeviceIndexForControllerRole(device->Role); |
| 376 | |
| 377 | float sample = (device->m_Haptics.GetSample() + device->m_Haptics.GetSample()) / 2.0f; |
| 378 | if (sample > 0.0f) |
| 379 | vr::VRSystem()->TriggerHapticPulse(touch, 0, (uint16_t)(freq.count() * sample)); |
| 380 | |
| 381 | std::this_thread::sleep_for(freq); |
| 382 | } |
| 383 | } |
| 384 | |
| 385 | InputManager::OculusTouch::OculusTouch(vr::VRActionSetHandle_t actionSet, vr::ETrackedControllerRole role) |
| 386 | : InputDevice(actionSet) |