author | Daosheng Mu <daoshengmu@gmail.com> |
Thu, 06 Apr 2017 09:45:55 +0800 | |
changeset 351911 | 3bae8c02fe0c1ba19fb34de274c94a6db81caaa6 |
parent 351910 | 5ff9620560fc250a68afa34595e52e8e16f15e28 |
child 351912 | 52ebd9950a44ef2a4c2c5d67f1f2a1fd8792fd72 |
push id | 31623 |
push user | archaeopteryx@coole-files.de |
push date | Sat, 08 Apr 2017 20:46:02 +0000 |
treeherder | mozilla-central@21c4aca1ae60 [default view] [failures only] |
perfherder | [talos] [build metrics] [platform microbench] (compared to previous push) |
reviewers | kip |
bugs | 1349895 |
milestone | 55.0a1 |
first release with | nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
|
last release without | nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
|
--- a/gfx/vr/gfxVROpenVR.cpp +++ b/gfx/vr/gfxVROpenVR.cpp @@ -18,17 +18,16 @@ #include "CompositorD3D11.h" #include "TextureD3D11.h" #endif // XP_WIN #include "gfxVROpenVR.h" #include "nsServiceManagerUtils.h" #include "nsIScreenManager.h" -#include "openvr/openvr.h" #include "mozilla/dom/GamepadEventTypes.h" #include "mozilla/dom/GamepadBinding.h" #ifndef M_PI # define M_PI 3.14159265358979323846 #endif @@ -386,24 +385,36 @@ VRDisplayOpenVR::NotifyVSync() // We update mIsConneced once per frame. mDisplayInfo.mIsConnected = vr_IsHmdPresent(); // Make sure we respond to OpenVR events even when not presenting PollEvents(); } VRControllerOpenVR::VRControllerOpenVR(dom::GamepadHand aHand, uint32_t aNumButtons, - uint32_t aNumAxes) + uint32_t aNumAxes, vr::ETrackedDeviceClass aDeviceType) : VRControllerHost(VRDeviceType::OpenVR) , mTrigger(0) , mVibrateThread(nullptr) , mIsVibrateStopped(false) { MOZ_COUNT_CTOR_INHERITED(VRControllerOpenVR, VRControllerHost); - mControllerInfo.mControllerName.AssignLiteral("OpenVR Gamepad"); + + switch (aDeviceType) { + case vr::TrackedDeviceClass_Controller: + mControllerInfo.mControllerName.AssignLiteral("OpenVR Gamepad"); + break; + case vr::TrackedDeviceClass_GenericTracker: + mControllerInfo.mControllerName.AssignLiteral("OpenVR Tracker"); + break; + default: + MOZ_ASSERT(false); + break; + } + mControllerInfo.mMappingType = GamepadMappingType::_empty; mControllerInfo.mHand = aHand; mControllerInfo.mNumButtons = aNumButtons; mControllerInfo.mNumAxes = aNumAxes; mControllerInfo.mNumHaptics = kNumOpenVRHaptcs; } VRControllerOpenVR::~VRControllerOpenVR() @@ -903,26 +914,29 @@ 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; } - if (mVRSystem->GetTrackedDeviceClass(trackedDevice) - != vr::TrackedDeviceClass_Controller) { + + deviceType = mVRSystem->GetTrackedDeviceClass(trackedDevice); + if (deviceType != vr::TrackedDeviceClass_Controller + && deviceType != vr::TrackedDeviceClass_GenericTracker) { continue; } trackedIndexArray[newControllerCount] = trackedDevice; ++newControllerCount; } if (newControllerCount != mControllerCount) { @@ -1000,17 +1014,17 @@ VRSystemManagerOpenVR::ScanForController ++numButtons; } if (supportButtons & BTN_MASK_FROM_ID(k_EButton_DPad_Down)) { ++numButtons; } RefPtr<VRControllerOpenVR> openVRController = - new VRControllerOpenVR(hand, numButtons, numAxes); + new VRControllerOpenVR(hand, numButtons, numAxes, deviceType); openVRController->SetTrackedIndex(trackedDevice); mOpenVRController.AppendElement(openVRController); // Not already present, add it. AddGamepad(openVRController->GetControllerInfo()); ++mControllerCount; } }
--- a/gfx/vr/gfxVROpenVR.h +++ b/gfx/vr/gfxVROpenVR.h @@ -9,16 +9,17 @@ #include "nsTArray.h" #include "nsIScreen.h" #include "nsCOMPtr.h" #include "mozilla/RefPtr.h" #include "mozilla/gfx/2D.h" #include "mozilla/EnumeratedArray.h" +#include "openvr/openvr.h" #include "gfxVR.h" // OpenVR Interfaces namespace vr { class IVRChaperone; class IVRCompositor; class IVRSystem; struct TrackedDevicePose_t; @@ -67,17 +68,17 @@ protected: void UpdateStageParameters(); void PollEvents(); }; class VRControllerOpenVR : public VRControllerHost { public: explicit VRControllerOpenVR(dom::GamepadHand aHand, uint32_t aNumButtons, - uint32_t aNumAxes); + uint32_t aNumAxes, vr::ETrackedDeviceClass aDeviceType); void SetTrackedIndex(uint32_t aTrackedIndex); uint32_t GetTrackedIndex(); void SetTrigger(float aValue); float GetTrigger(); void VibrateHaptic(vr::IVRSystem* aVRSystem, uint32_t aHapticIndex, double aIntensity, double aDuration,
--- a/gfx/vr/openvr/openvr.h +++ b/gfx/vr/openvr/openvr.h @@ -147,16 +147,17 @@ static const uint32_t k_unTrackedDeviceI static const uint32_t k_unTrackedDeviceIndexInvalid = 0xFFFFFFFF; /** Describes what kind of object is being tracked at a given ID */ enum ETrackedDeviceClass { TrackedDeviceClass_Invalid = 0, // the ID was not valid. TrackedDeviceClass_HMD = 1, // Head-Mounted Displays TrackedDeviceClass_Controller = 2, // Tracked controllers + TrackedDeviceClass_GenericTracker = 3, // Generic trackers, similar to controllers TrackedDeviceClass_TrackingReference = 4, // Camera and base stations that serve as tracking reference points TrackedDeviceClass_Other = 1000, }; /** Describes what specific role associated with a tracked device */ enum ETrackedControllerRole