OpenVRViveMapper.cpp (1664B)
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 "OpenVRViveMapper.h" 8 9 #include "moz_external_vr.h" 10 #include "VRSession.h" 11 12 namespace mozilla::gfx { 13 14 void OpenVRViveMapper::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: Trackpad 25 GetButtonValueFromAction(aControllerState, 26 aControllerInfo.mActionTrackpad_Pressed, 27 aControllerInfo.mActionTrackpad_Touched); 28 // Button 3: a placeholder button for thumbstick. 29 ++mNumButtons; 30 // Button 4: Menu 31 GetButtonValueFromAction(aControllerState, 32 aControllerInfo.mActionMenu_Pressed, 33 aControllerInfo.mActionMenu_Touched); 34 35 // Axis 0, 1: Trackpad 36 GetAxisValueFromAction(aControllerState, 37 aControllerInfo.mActionTrackpad_Analog); 38 39 aControllerState.numButtons = mNumButtons; 40 aControllerState.numAxes = mNumAxes; 41 } 42 43 } // namespace mozilla::gfx