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
5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
7 #ifndef GFX_VR_SERVICE_OPENVRCONTROLLERMAPPER_H
8 #define GFX_VR_SERVICE_OPENVRCONTROLLERMAPPER_H
13 #include "moz_external_vr.h"
18 struct ControllerAction
{
21 vr::VRActionHandle_t handle
= vr::k_ulInvalidActionHandle
;
23 ControllerAction() = default;
25 ControllerAction(const char* aName
, const char* aType
)
26 : name(aName
), type(aType
) {}
29 struct ControllerInfo
{
30 vr::VRInputValueHandle_t mSource
= vr::k_ulInvalidInputValueHandle
;
32 ControllerAction mActionPose
;
33 ControllerAction mActionHaptic
;
35 ControllerAction mActionTrackpad_Analog
;
36 ControllerAction mActionTrackpad_Pressed
;
37 ControllerAction mActionTrackpad_Touched
;
39 ControllerAction mActionTrigger_Value
;
41 ControllerAction mActionGrip_Pressed
;
42 ControllerAction mActionGrip_Touched
;
43 ControllerAction mActionMenu_Pressed
;
44 ControllerAction mActionMenu_Touched
;
45 // It seems like there's no way to get response from a sys. btn.
46 ControllerAction mActionSystem_Pressed
;
47 ControllerAction mActionSystem_Touched
;
49 // --- Knuckles & Cosmos
50 ControllerAction mActionA_Pressed
;
51 ControllerAction mActionA_Touched
;
52 ControllerAction mActionB_Pressed
;
53 ControllerAction mActionB_Touched
;
55 // --- Knuckles, Cosmos, and WMR
56 ControllerAction mActionThumbstick_Analog
;
57 ControllerAction mActionThumbstick_Pressed
;
58 ControllerAction mActionThumbstick_Touched
;
61 ControllerAction mActionFingerIndex_Value
;
62 ControllerAction mActionFingerMiddle_Value
;
63 ControllerAction mActionFingerRing_Value
;
64 ControllerAction mActionFingerPinky_Value
;
67 ControllerAction mActionBumper_Pressed
;
70 class OpenVRControllerMapper
{
72 OpenVRControllerMapper();
73 virtual ~OpenVRControllerMapper() = default;
75 virtual void UpdateButtons(VRControllerState
& aControllerState
,
76 ControllerInfo
& aControllerInfo
) = 0;
77 uint32_t GetButtonCount() { return mNumButtons
; }
78 uint32_t GetAxisCount() { return mNumAxes
; }
81 void GetButtonValueFromAction(VRControllerState
& aControllerState
,
82 const ControllerAction
& aPressAction
,
83 const ControllerAction
& aTouchAction
);
84 void GetTriggerValueFromAction(VRControllerState
& aControllerState
,
85 const ControllerAction
& aAction
);
86 void GetAxisValueFromAction(VRControllerState
& aControllerState
,
87 const ControllerAction
& aAction
,
88 bool aInvertAxis
= false);
94 } // namespace mozilla
96 #endif // GFX_VR_SERVICE_OPENVRCONTROLLERMAPPER_H