Showing the changes to interface/src/ControllerScriptingInterface.cpp (1 of 6 files). Show all
Unified · Split
| @@ -0,0 +1,45 @@ | |||
| 1 | // | ||
| 2 | // ControllerScriptingInterface.h | ||
| 3 | // hifi | ||
| 4 | // | ||
| 5 | // Created by Brad Hefta-Gaub on 12/17/13 | ||
| 6 | // Copyright (c) 2013 HighFidelity, Inc. All rights reserved. | ||
| 7 | // | ||
| 8 | |||
| 9 | #include <HandData.h> | ||
| 10 | #include "Application.h" | ||
| 11 | #include "ControllerScriptingInterface.h" | ||
| 12 | |||
| 13 | const PalmData* ControllerScriptingInterface::getPrimaryPalm() const { | ||
| 14 | int leftPalmIndex, rightPalmIndex; | ||
| 15 | |||
| 16 | const HandData* handData = Application::getInstance()->getAvatar()->getHandData(); | ||
| 17 | handData->getLeftRightPalmIndices(leftPalmIndex, rightPalmIndex); | ||
| 18 | |||
| 19 | if (rightPalmIndex != -1) { | ||
| 20 | return &handData->getPalms()[rightPalmIndex]; | ||
| 21 | } | ||
| 22 | |||
| 23 | return NULL; | ||
| 24 | } | ||
| 25 | |||
| 26 | bool ControllerScriptingInterface::isPrimaryButtonPressed() const { | ||
| 27 | const PalmData* primaryPalm = getPrimaryPalm(); | ||
| 28 | if (primaryPalm) { | ||
| 29 | if (primaryPalm->getControllerButtons() & BUTTON_FWD) { | ||
| 30 | return true; | ||
| 31 | } | ||
| 32 | } | ||
| 33 | |||
| 34 | return false; | ||
| 35 | } | ||
| 36 | |||
| 37 | glm::vec2 ControllerScriptingInterface::getPrimaryJoystickPosition() const { | ||
| 38 | const PalmData* primaryPalm = getPrimaryPalm(); | ||
| 39 | if (primaryPalm) { | ||
| 40 | return glm::vec2(primaryPalm->getJoystickX(), primaryPalm->getJoystickY()); | ||
| 41 | } | ||
| 42 | |||
| 43 | return glm::vec2(0); | ||
| 44 | } | ||
| 45 | |||