Bug 1860712 [wpt PR 42705] - Port popover test to WPT and adjust for close requests...
[gecko.git] / dom / vr / XRInputSource.h
blob2f9405c18e164c8f7315d7e5f79e93dac74467e1
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 #ifndef mozilla_dom_XRInputSource_h_
8 #define mozilla_dom_XRInputSource_h_
10 #include "mozilla/DOMEventTargetHelper.h"
11 #include "mozilla/dom/WebXRBinding.h"
13 #include "gfxVR.h"
15 namespace mozilla {
16 namespace gfx {
17 class VRDisplayClient;
18 } // namespace gfx
19 namespace dom {
20 class Gamepad;
21 class XRSpace;
22 class XRSession;
23 class XRNativeOrigin;
24 enum class XRHandedness : uint8_t;
25 enum class XRTargetRayMode : uint8_t;
27 class XRInputSource final : public nsWrapperCache {
28 public:
29 NS_INLINE_DECL_CYCLE_COLLECTING_NATIVE_REFCOUNTING(XRInputSource)
30 NS_DECL_CYCLE_COLLECTION_NATIVE_WRAPPERCACHE_CLASS(XRInputSource)
32 explicit XRInputSource(nsISupports* aParent);
34 // WebIDL Boilerplate
35 nsISupports* GetParentObject() const { return mParent; }
36 JSObject* WrapObject(JSContext* aCx,
37 JS::Handle<JSObject*> aGivenProto) override;
39 // WebIDL Members
40 XRHandedness Handedness();
41 XRTargetRayMode TargetRayMode();
42 XRSpace* TargetRaySpace();
43 XRSpace* GetGripSpace();
44 void GetProfiles(nsTArray<nsString>& aResult);
45 Gamepad* GetGamepad();
46 void Setup(XRSession* aSession, uint32_t aIndex);
47 void SetGamepadIsConnected(bool aConnected, XRSession* aSession);
48 void Update(XRSession* aSession);
49 int32_t GetIndex();
51 protected:
52 virtual ~XRInputSource();
54 nsCOMPtr<nsISupports> mParent;
56 private:
57 enum class ActionState : uint8_t {
58 ActionState_Pressing = 0,
59 ActionState_Pressed = 1,
60 ActionState_Releasing = 2,
61 ActionState_Released = 3
64 void CreateGripSpace(XRSession* aSession,
65 const gfx::VRControllerState& controllerState);
66 void DispatchEvent(const nsAString& aEvent, XRSession* aSession);
68 nsTArray<nsString> mProfiles;
69 XRHandedness mHandedness;
70 XRTargetRayMode mTargetRayMode;
72 RefPtr<XRSpace> mTargetRaySpace;
73 RefPtr<XRSpace> mGripSpace;
74 RefPtr<Gamepad> mGamepad;
75 int32_t mIndex;
76 ActionState mSelectAction;
77 ActionState mSqueezeAction;
80 } // namespace dom
81 } // namespace mozilla
83 #endif // mozilla_dom_XRInputSource_h_