OpenVRKnucklesMapper.cpp (2660B)
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/. */ 6 7 #include "OpenVRKnucklesMapper.h" 8 9 #include "moz_external_vr.h" 10 #include "VRSession.h" 11 12 namespace mozilla::gfx { 13 14 void OpenVRKnucklesMapper::UpdateButtons(VRControllerState& aControllerState, 15 ControllerInfo& aControllerInfo) { 16 mNumButtons = mNumAxes = 0; 17 // Button 0: Trigger 18 GetTriggerValueFromAction(aControllerState, 19 aControllerInfo.mActionTrigger_Value); 20 // Button 1: Grip 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); 32 // Button 4: A 33 GetButtonValueFromAction(aControllerState, aControllerInfo.mActionA_Pressed, 34 aControllerInfo.mActionA_Touched); 35 // Button 5: B 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); 50 51 // Axis 0, 1: Touchpad 52 GetAxisValueFromAction(aControllerState, 53 aControllerInfo.mActionTrackpad_Analog); 54 // Axis 2, 3: Thumbstick 55 GetAxisValueFromAction(aControllerState, 56 aControllerInfo.mActionThumbstick_Analog); 57 58 aControllerState.numButtons = mNumButtons; 59 aControllerState.numAxes = mNumAxes; 60 } 61 62 } // namespace mozilla::gfx