History

Scratch that; going to shoehorn joystick data into palms.

Andrzej Kapolka committed 12 years ago

Commit c4236851 parent 20eadab3 files · +3 −33Browse files

Showing the changes to interface/src/scripting/ControllerScriptingInterface.cpp (1 of 3 files). Show all

Unified · Split

interface/src/scripting/ControllerScriptingInterface.cpp+2−24
@@ -74,7 +74,6 @@ bool ControllerScriptingInterface::isPrimaryButtonPressed() const { · 73 unmodified lines
7474 return true;
7575 }
7676 }
77−
7877 return false;
7978 }
8079
@@ -88,24 +87,10 @@ glm::vec2 ControllerScriptingInterface::getPrimaryJoystickPosition() const { · 7 unmodified lines
8887 }
8988
9089 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;
9691 }
9792
9893 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− }
10994 int palmIndex = buttonIndex / NUMBER_OF_BUTTONS_PER_PALM;
11095 int buttonOnPalm = buttonIndex % NUMBER_OF_BUTTONS_PER_PALM;
11196 const PalmData* palmData = getActivePalm(palmIndex);
@@ -143,18 +128,11 @@ float ControllerScriptingInterface::getTriggerValue(int triggerIndex) const { · 31 unmodified lines
143128 }
144129
145130 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;
148132 }
149133
150134 glm::vec2 ControllerScriptingInterface::getJoystickPosition(int joystickIndex) const {
151135 // 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− }
158136 int palmIndex = joystickIndex;
159137 const PalmData* palmData = getActivePalm(palmIndex);
160138 if (palmData) {