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 "OpenVRCosmosMapper.h"
9 #include "moz_external_vr.h"
10 #include "VRSession.h"
12 namespace mozilla::gfx
{
14 void OpenVRCosmosMapper::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: a placeholder button for trackpad.
26 // Button 3: Thumbstick
27 GetButtonValueFromAction(aControllerState
,
28 aControllerInfo
.mActionThumbstick_Pressed
,
29 aControllerInfo
.mActionThumbstick_Touched
);
31 GetButtonValueFromAction(aControllerState
, aControllerInfo
.mActionA_Pressed
,
32 aControllerInfo
.mActionA_Touched
);
34 GetButtonValueFromAction(aControllerState
, aControllerInfo
.mActionB_Pressed
,
35 aControllerInfo
.mActionB_Touched
);
37 GetButtonValueFromAction(aControllerState
,
38 aControllerInfo
.mActionBumper_Pressed
,
39 aControllerInfo
.mActionBumper_Pressed
);
41 // Axis 0, 1: placeholder axes for touchpad.
43 // Axis 2, 3: Thumbstick
44 GetAxisValueFromAction(aControllerState
,
45 aControllerInfo
.mActionThumbstick_Analog
);
47 aControllerState
.numButtons
= mNumButtons
;
48 aControllerState
.numAxes
= mNumAxes
;
51 } // namespace mozilla::gfx