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 | return true; | 74 | return true; |
| 75 | } | 75 | } |
| 76 | } | 76 | } |
| 77 | |||
| 78 | return false; | 77 | return false; |
| 79 | } | 78 | } |
| 80 | 79 | ||
| @@ -88,24 +87,10 @@ glm::vec2 ControllerScriptingInterface::getPrimaryJoystickPosition() const { · 7 unmodified lines | |||
| 88 | } | 87 | } |
| 89 | 88 | ||
| 90 | int ControllerScriptingInterface::getNumberOfButtons() const { | 89 | int ControllerScriptingInterface::getNumberOfButtons() const { |
| 91 | int buttonCount = 0; | 90 | return getNumberOfActivePalms() * NUMBER_OF_BUTTONS_PER_PALM; |
| 92 | foreach (const JoystickState& state, Application::getInstance()->getJoystickManager()->getJoystickStates()) { | ||
| 93 | buttonCount += state.buttons.size(); | ||
| 94 | } | ||
| 95 | return buttonCount + getNumberOfActivePalms() * NUMBER_OF_BUTTONS_PER_PALM; | ||
| 96 | } | 91 | } |
| 97 | 92 | ||
| 98 | bool ControllerScriptingInterface::isButtonPressed(int buttonIndex) const { | 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 | int palmIndex = buttonIndex / NUMBER_OF_BUTTONS_PER_PALM; | 94 | int palmIndex = buttonIndex / NUMBER_OF_BUTTONS_PER_PALM; |
| 110 | int buttonOnPalm = buttonIndex % NUMBER_OF_BUTTONS_PER_PALM; | 95 | int buttonOnPalm = buttonIndex % NUMBER_OF_BUTTONS_PER_PALM; |
| 111 | const PalmData* palmData = getActivePalm(palmIndex); | 96 | const PalmData* palmData = getActivePalm(palmIndex); |
| @@ -143,18 +128,11 @@ float ControllerScriptingInterface::getTriggerValue(int triggerIndex) const { · 31 unmodified lines | |||
| 143 | } | 128 | } |
| 144 | 129 | ||
| 145 | int ControllerScriptingInterface::getNumberOfJoysticks() const { | 130 | int ControllerScriptingInterface::getNumberOfJoysticks() const { |
| 146 | return getNumberOfActivePalms() * NUMBER_OF_JOYSTICKS_PER_PALM + | 131 | return getNumberOfActivePalms() * NUMBER_OF_JOYSTICKS_PER_PALM; |
| 147 | Application::getInstance()->getJoystickManager()->getJoystickStates().size(); | ||
| 148 | } | 132 | } |
| 149 | 133 | ||
| 150 | glm::vec2 ControllerScriptingInterface::getJoystickPosition(int joystickIndex) const { | 134 | glm::vec2 ControllerScriptingInterface::getJoystickPosition(int joystickIndex) const { |
| 151 | // we know there's one joystick per palm, so the joystickIndex is the palm Index | 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 | int palmIndex = joystickIndex; | 136 | int palmIndex = joystickIndex; |
| 159 | const PalmData* palmData = getActivePalm(palmIndex); | 137 | const PalmData* palmData = getActivePalm(palmIndex); |
| 160 | if (palmData) { | 138 | if (palmData) { |