Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
[Android] Fix joysticks only capable of right/down movements. Also ma…
…ke it capable of using onscreen joystick even if controller 1 is bound.
  • Loading branch information
Sonicadvance1 committed Dec 13, 2013
1 parent d7be993 commit 2e1aa64
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 15 deletions.
Expand Up @@ -103,14 +103,10 @@ public void TrackEvent(MotionEvent event)
public float[] getAxisValues()
{
float[] joyaxises = {0f, 0f, 0f, 0f};
if (axises[0] >= 0.0f)
joyaxises[1] = Math.min(axises[0], 1.0f);
else
joyaxises[0] = Math.min(Math.abs(axises[0]), 1.0f);
if (axises[1] >= 0.0)
joyaxises[3] = Math.min(axises[1], 1.0f);
else
joyaxises[2] = Math.min(Math.abs(axises[1]), 1.0f);
joyaxises[1] = Math.min(axises[0], 1.0f);
joyaxises[0] = Math.min(axises[0], 0.0f);
joyaxises[3] = Math.min(axises[1], 1.0f);
joyaxises[2] = Math.min(axises[1], 0.0f);
return joyaxises;
}

Expand Down
2 changes: 1 addition & 1 deletion Source/Core/DolphinWX/Src/Android/ButtonManager.cpp
Expand Up @@ -140,7 +140,7 @@ namespace ButtonManager
auto it = m_controllers.begin();
if (it == m_controllers.end())
return value;
return it->second->AxisValue(padID, axis);
return value != 0.0f ? value : it->second->AxisValue(padID, axis);
}
void TouchEvent(int padID, ButtonType button, int action)
{
Expand Down
Expand Up @@ -59,10 +59,10 @@ Touchscreen::Touchscreen(int padID)
AddInput(new Button(_padID, ButtonManager::BUTTON_DOWN));
AddInput(new Button(_padID, ButtonManager::BUTTON_LEFT));
AddInput(new Button(_padID, ButtonManager::BUTTON_RIGHT));
AddAnalogInputs(new Axis(_padID, ButtonManager::STICK_MAIN_LEFT), new Axis(_padID, ButtonManager::STICK_MAIN_RIGHT));
AddAnalogInputs(new Axis(_padID, ButtonManager::STICK_MAIN_UP), new Axis(_padID, ButtonManager::STICK_MAIN_DOWN));
AddAnalogInputs(new Axis(_padID, ButtonManager::STICK_C_UP), new Axis(_padID, ButtonManager::STICK_C_DOWN));
AddAnalogInputs(new Axis(_padID, ButtonManager::STICK_C_LEFT), new Axis(_padID, ButtonManager::STICK_C_RIGHT));
AddAnalogInputs(new Axis(_padID, ButtonManager::STICK_MAIN_LEFT, -1.0f), new Axis(_padID, ButtonManager::STICK_MAIN_RIGHT));
AddAnalogInputs(new Axis(_padID, ButtonManager::STICK_MAIN_UP, -1.0f), new Axis(_padID, ButtonManager::STICK_MAIN_DOWN));
AddAnalogInputs(new Axis(_padID, ButtonManager::STICK_C_UP, -1.0f), new Axis(_padID, ButtonManager::STICK_C_DOWN));
AddAnalogInputs(new Axis(_padID, ButtonManager::STICK_C_LEFT, -1.0f), new Axis(_padID, ButtonManager::STICK_C_RIGHT));
AddAnalogInputs(new Axis(_padID, ButtonManager::TRIGGER_L), new Axis(_padID, ButtonManager::TRIGGER_L));
AddAnalogInputs(new Axis(_padID, ButtonManager::TRIGGER_R), new Axis(_padID, ButtonManager::TRIGGER_R));
}
Expand All @@ -88,7 +88,7 @@ std::string Touchscreen::Axis::GetName() const

ControlState Touchscreen::Axis::GetState() const
{
return ButtonManager::GetAxisValue(_padID, _index);
return ButtonManager::GetAxisValue(_padID, _index) * _neg;
}

}
Expand Down
Expand Up @@ -43,11 +43,12 @@ class Touchscreen : public Core::Device
{
public:
std::string GetName() const;
Axis(int padID, ButtonManager::ButtonType index) : _padID(padID), _index(index) {}
Axis(int padID, ButtonManager::ButtonType index, float neg = 1.0f) : _padID(padID), _index(index), _neg(neg) {}
ControlState GetState() const;
private:
const int _padID;
const ButtonManager::ButtonType _index;
const float _neg;
};

public:
Expand Down

0 comments on commit 2e1aa64

Please sign in to comment.