XRInputSpace.cpp (1322B)
1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ 2 /* vim: set ts=8 sts=2 et sw=2 tw=80: */ 3 /* This Source Code Form is subject to the terms of the Mozilla Public 4 * License, v. 2.0. If a copy of the MPL was not distributed with this file, 5 * You can obtain one at http://mozilla.org/MPL/2.0/. */ 6 7 #include "XRInputSpace.h" 8 9 #include "VRDisplayClient.h" 10 #include "mozilla/dom/GamepadPoseState.h" 11 12 namespace mozilla::dom { 13 14 XRInputSpace::XRInputSpace(nsIGlobalObject* aParent, XRSession* aSession, 15 XRNativeOrigin* aNativeOrigin, 16 int32_t aControllerIndex) 17 : XRSpace(aParent, aSession, aNativeOrigin), mIndex(aControllerIndex) {} 18 19 bool XRInputSpace::IsPositionEmulated() const { 20 gfx::VRDisplayClient* display = mSession->GetDisplayClient(); 21 if (!display) { 22 // When there are no sensors, the position is considered emulated. 23 return true; 24 } 25 const gfx::VRDisplayInfo& displayInfo = display->GetDisplayInfo(); 26 const gfx::VRControllerState& controllerState = 27 displayInfo.mControllerState[mIndex]; 28 MOZ_ASSERT(controllerState.controllerName[0] != '\0'); 29 30 return ( 31 (controllerState.flags & GamepadCapabilityFlags::Cap_PositionEmulated) != 32 GamepadCapabilityFlags::Cap_None); 33 } 34 35 } // namespace mozilla::dom