Showing the changes to interface/src/scripting/ControllerScriptingInterface.cpp (1 of 3 files). Show all
Unified · Split
| @@ -74,7 +74,6 @@ bool ControllerScriptingInterface::isPrimaryButtonPressed() const { · 73 unmodified lines | ||
| 74 | 74 | return true; |
| 75 | 75 | } |
| 76 | 76 | } |
| 77 | − | |
| 78 | 77 | return false; |
| 79 | 78 | } |
| 80 | 79 | |
| @@ -88,24 +87,10 @@ glm::vec2 ControllerScriptingInterface::getPrimaryJoystickPosition() const { · 7 unmodified lines | ||
| 88 | 87 | } |
| 89 | 88 | |
| 90 | 89 | int ControllerScriptingInterface::getNumberOfButtons() const { |
| 91 | − int buttonCount = 0; | |
| 92 | − foreach (const JoystickState& state, Application::getInstance()->getJoystickManager()->getJoystickStates()) { | |
| 93 | − buttonCount += state.buttons.size(); | |
| 94 | − } | |
| 95 | − return buttonCount + getNumberOfActivePalms() * NUMBER_OF_BUTTONS_PER_PALM; | |
| 90 | + return getNumberOfActivePalms() * NUMBER_OF_BUTTONS_PER_PALM; | |
| 96 | 91 | } |
| 97 | 92 | |
| 98 | 93 | bool ControllerScriptingInterface::isButtonPressed(int buttonIndex) const { |
| 99 | − int managedButtonIndex = buttonIndex - getNumberOfActivePalms() * NUMBER_OF_BUTTONS_PER_PALM; | |
| 100 | − if (managedButtonIndex >= 0) { | |
| 101 | − foreach (const JoystickState& state, Application::getInstance()->getJoystickManager()->getJoystickStates()) { | |
| 102 | − if (managedButtonIndex < state.buttons.size()) { | |
| 103 | − return state.buttons.at(managedButtonIndex); | |
| 104 | − } | |
| 105 | − managedButtonIndex -= state.buttons.size(); | |
| 106 | − } | |
| 107 | − return false; | |
| 108 | − } | |
| 109 | 94 | int palmIndex = buttonIndex / NUMBER_OF_BUTTONS_PER_PALM; |
| 110 | 95 | int buttonOnPalm = buttonIndex % NUMBER_OF_BUTTONS_PER_PALM; |
| 111 | 96 | const PalmData* palmData = getActivePalm(palmIndex); |
| @@ -143,18 +128,11 @@ float ControllerScriptingInterface::getTriggerValue(int triggerIndex) const { · 31 unmodified lines | ||
| 143 | 128 | } |
| 144 | 129 | |
| 145 | 130 | int ControllerScriptingInterface::getNumberOfJoysticks() const { |
| 146 | − return getNumberOfActivePalms() * NUMBER_OF_JOYSTICKS_PER_PALM + | |
| 147 | − Application::getInstance()->getJoystickManager()->getJoystickStates().size(); | |
| 131 | + return getNumberOfActivePalms() * NUMBER_OF_JOYSTICKS_PER_PALM; | |
| 148 | 132 | } |
| 149 | 133 | |
| 150 | 134 | glm::vec2 ControllerScriptingInterface::getJoystickPosition(int joystickIndex) const { |
| 151 | 135 | // we know there's one joystick per palm, so the joystickIndex is the palm Index |
| 152 | − int managedJoystickIndex = joystickIndex - getNumberOfActivePalms(); | |
| 153 | − if (managedJoystickIndex >= 0) { | |
| 154 | − const JoystickState& state = Application::getInstance()->getJoystickManager()->getJoystickStates().at( | |
| 155 | − managedJoystickIndex); | |
| 156 | − return glm::vec2(state.axes.size() > 0 ? state.axes.at(0) : 0.0f, state.axes.size() > 1 ? state.axes.at(1) : 0.0f); | |
| 157 | − } | |
| 158 | 136 | int palmIndex = joystickIndex; |
| 159 | 137 | const PalmData* palmData = getActivePalm(palmIndex); |
| 160 | 138 | if (palmData) { |