Bug 1852740: add tests for the `fetchpriority` attribute in Link headers. r=necko...
[gecko.git] / dom / vr / XRInputSpace.cpp
blob34ccd37607b116309004fbcd6d1482656ae138a9
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/. */
7 #include "XRInputSpace.h"
8 #include "VRDisplayClient.h"
9 #include "mozilla/dom/GamepadPoseState.h"
11 namespace mozilla::dom {
13 XRInputSpace::XRInputSpace(nsIGlobalObject* aParent, XRSession* aSession,
14 XRNativeOrigin* aNativeOrigin,
15 int32_t aControllerIndex)
16 : XRSpace(aParent, aSession, aNativeOrigin), mIndex(aControllerIndex) {}
18 bool XRInputSpace::IsPositionEmulated() const {
19 gfx::VRDisplayClient* display = mSession->GetDisplayClient();
20 if (!display) {
21 // When there are no sensors, the position is considered emulated.
22 return true;
24 const gfx::VRDisplayInfo& displayInfo = display->GetDisplayInfo();
25 const gfx::VRControllerState& controllerState =
26 displayInfo.mControllerState[mIndex];
27 MOZ_ASSERT(controllerState.controllerName[0] != '\0');
29 return (
30 (controllerState.flags & GamepadCapabilityFlags::Cap_PositionEmulated) !=
31 GamepadCapabilityFlags::Cap_None);
34 } // namespace mozilla::dom