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 #include "OpenVRKnucklesMapper.h"
9 #include "moz_external_vr.h"
10 #include "VRSession.h"
12 namespace mozilla::gfx
{
14 void OpenVRKnucklesMapper::UpdateButtons(VRControllerState
& aControllerState
,
15 ControllerInfo
& aControllerInfo
) {
16 mNumButtons
= mNumAxes
= 0;
18 GetTriggerValueFromAction(aControllerState
,
19 aControllerInfo
.mActionTrigger_Value
);
21 GetButtonValueFromAction(aControllerState
,
22 aControllerInfo
.mActionGrip_Pressed
,
23 aControllerInfo
.mActionGrip_Touched
);
24 // Button 2: Touchpad.
25 GetButtonValueFromAction(aControllerState
,
26 aControllerInfo
.mActionTrackpad_Pressed
,
27 aControllerInfo
.mActionTrackpad_Touched
);
28 // Button 3: Thumbstick
29 GetButtonValueFromAction(aControllerState
,
30 aControllerInfo
.mActionThumbstick_Pressed
,
31 aControllerInfo
.mActionThumbstick_Touched
);
33 GetButtonValueFromAction(aControllerState
, aControllerInfo
.mActionA_Pressed
,
34 aControllerInfo
.mActionA_Touched
);
36 GetButtonValueFromAction(aControllerState
, aControllerInfo
.mActionB_Pressed
,
37 aControllerInfo
.mActionB_Touched
);
38 // Button 6: Finger index
39 GetTriggerValueFromAction(aControllerState
,
40 aControllerInfo
.mActionFingerIndex_Value
);
41 // Button 7: Finger middle
42 GetTriggerValueFromAction(aControllerState
,
43 aControllerInfo
.mActionFingerMiddle_Value
);
44 // Button 8: Finger ring
45 GetTriggerValueFromAction(aControllerState
,
46 aControllerInfo
.mActionFingerRing_Value
);
47 // Button 9: Finger pinky
48 GetTriggerValueFromAction(aControllerState
,
49 aControllerInfo
.mActionFingerPinky_Value
);
51 // Axis 0, 1: Touchpad
52 GetAxisValueFromAction(aControllerState
,
53 aControllerInfo
.mActionTrackpad_Analog
);
54 // Axis 2, 3: Thumbstick
55 GetAxisValueFromAction(aControllerState
,
56 aControllerInfo
.mActionThumbstick_Analog
);
58 aControllerState
.numButtons
= mNumButtons
;
59 aControllerState
.numAxes
= mNumAxes
;
62 } // namespace mozilla::gfx