| 355 | } |
| 356 | |
| 357 | ovrVector2f InputManager::InputDevice::ApplyDeadzone(ovrVector2f axis, float deadZone) |
| 358 | { |
| 359 | XR::Vector2f vector(axis); |
| 360 | float mag = vector.Length(); |
| 361 | if (mag > deadZone) |
| 362 | { |
| 363 | // scale such that output magnitude is in the range[0, 1] |
| 364 | float legalRange = 1.0f - deadZone; |
| 365 | float normalizedMag = std::min(1.0f, (mag - deadZone) / legalRange); |
| 366 | float scale = normalizedMag / mag; |
| 367 | return vector * scale; |
| 368 | } |
| 369 | else |
| 370 | { |
| 371 | // stick is in the inner dead zone |
| 372 | return OVR::Vector2f(); |
| 373 | } |
| 374 | } |
| 375 | |
| 376 | ovrButton InputManager::InputDevice::TrackpadToDPad(ovrVector2f trackpad) |
| 377 | { |