Bug 1356421 - Part 1: Fix for making OpenVR get correct device types for Gamepad id; r?kip
MozReview-Commit-ID: KI25bjqKTTL
--- a/gfx/vr/gfxVROpenVR.cpp
+++ b/gfx/vr/gfxVROpenVR.cpp
@@ -896,27 +896,27 @@ VRSystemManagerOpenVR::ScanForController
// mVRSystem is available after VRDisplay is created
// at GetHMDs().
if (!mVRSystem) {
return;
}
::vr::TrackedDeviceIndex_t trackedIndexArray[::vr::k_unMaxTrackedDeviceCount];
uint32_t newControllerCount = 0;
- ::vr::ETrackedDeviceClass deviceType;
// Basically, we would have HMDs in the tracked devices,
// but we are just interested in the controllers.
for (::vr::TrackedDeviceIndex_t trackedDevice = ::vr::k_unTrackedDeviceIndex_Hmd + 1;
trackedDevice < ::vr::k_unMaxTrackedDeviceCount; ++trackedDevice) {
if (!mVRSystem->IsTrackedDeviceConnected(trackedDevice)) {
continue;
}
- deviceType = mVRSystem->GetTrackedDeviceClass(trackedDevice);
+ const ::vr::ETrackedDeviceClass deviceType = mVRSystem->
+ GetTrackedDeviceClass(trackedDevice);
if (deviceType != ::vr::TrackedDeviceClass_Controller
&& deviceType != ::vr::TrackedDeviceClass_GenericTracker) {
continue;
}
trackedIndexArray[newControllerCount] = trackedDevice;
++newControllerCount;
}
@@ -927,23 +927,24 @@ VRSystemManagerOpenVR::ScanForController
RemoveGamepad(i);
}
mControllerCount = 0;
mOpenVRController.Clear();
// Re-adding controllers to VRControllerManager.
for (::vr::TrackedDeviceIndex_t i = 0; i < newControllerCount; ++i) {
const ::vr::TrackedDeviceIndex_t trackedDevice = trackedIndexArray[i];
+ const ::vr::ETrackedDeviceClass deviceType = mVRSystem->
+ GetTrackedDeviceClass(trackedDevice);
const ::vr::ETrackedControllerRole role = mVRSystem->
- GetControllerRoleForTrackedDeviceIndex(
- trackedDevice);
-
+ GetControllerRoleForTrackedDeviceIndex(
+ trackedDevice);
+ const GamepadHand hand = GetGamepadHandFromControllerRole(role);
uint32_t numButtons = 0;
uint32_t numAxes = 0;
- const GamepadHand hand = GetGamepadHandFromControllerRole(role);
// Scan the axes that the controllers support
for (uint32_t j = 0; j < ::vr::k_unControllerStateAxisCount; ++j) {
const uint32_t supportAxis = mVRSystem->GetInt32TrackedDeviceProperty(trackedDevice,
static_cast<vr::TrackedDeviceProperty>(
::vr::Prop_Axis0Type_Int32 + j));
switch (supportAxis) {
case ::vr::EVRControllerAxisType::k_eControllerAxis_Joystick: