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"
17 class VRDisplayClient
;
24 enum class XRHandedness
: uint8_t;
25 enum class XRTargetRayMode
: uint8_t;
27 class XRInputSource final
: public nsWrapperCache
{
29 NS_INLINE_DECL_CYCLE_COLLECTING_NATIVE_REFCOUNTING(XRInputSource
)
30 NS_DECL_CYCLE_COLLECTION_NATIVE_WRAPPERCACHE_CLASS(XRInputSource
)
32 explicit XRInputSource(nsISupports
* aParent
);
35 nsISupports
* GetParentObject() const { return mParent
; }
36 JSObject
* WrapObject(JSContext
* aCx
,
37 JS::Handle
<JSObject
*> aGivenProto
) override
;
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
);
52 virtual ~XRInputSource();
54 nsCOMPtr
<nsISupports
> mParent
;
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
;
76 ActionState mSelectAction
;
77 ActionState mSqueezeAction
;
81 } // namespace mozilla
83 #endif // mozilla_dom_XRInputSource_h_