[Android] Fix joysticks only capable of right/down movements. Also make it capable of using onscreen joystick even if controller 1 is bound.
This commit is contained in:
parent
d7be993889
commit
2e1aa64958
|
@ -103,14 +103,10 @@ public final class InputOverlayDrawableJoystick extends BitmapDrawable
|
||||||
public float[] getAxisValues()
|
public float[] getAxisValues()
|
||||||
{
|
{
|
||||||
float[] joyaxises = {0f, 0f, 0f, 0f};
|
float[] joyaxises = {0f, 0f, 0f, 0f};
|
||||||
if (axises[0] >= 0.0f)
|
|
||||||
joyaxises[1] = Math.min(axises[0], 1.0f);
|
joyaxises[1] = Math.min(axises[0], 1.0f);
|
||||||
else
|
joyaxises[0] = Math.min(axises[0], 0.0f);
|
||||||
joyaxises[0] = Math.min(Math.abs(axises[0]), 1.0f);
|
|
||||||
if (axises[1] >= 0.0)
|
|
||||||
joyaxises[3] = Math.min(axises[1], 1.0f);
|
joyaxises[3] = Math.min(axises[1], 1.0f);
|
||||||
else
|
joyaxises[2] = Math.min(axises[1], 0.0f);
|
||||||
joyaxises[2] = Math.min(Math.abs(axises[1]), 1.0f);
|
|
||||||
return joyaxises;
|
return joyaxises;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -140,7 +140,7 @@ namespace ButtonManager
|
||||||
auto it = m_controllers.begin();
|
auto it = m_controllers.begin();
|
||||||
if (it == m_controllers.end())
|
if (it == m_controllers.end())
|
||||||
return value;
|
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)
|
void TouchEvent(int padID, ButtonType button, int action)
|
||||||
{
|
{
|
||||||
|
|
|
@ -59,10 +59,10 @@ Touchscreen::Touchscreen(int padID)
|
||||||
AddInput(new Button(_padID, ButtonManager::BUTTON_DOWN));
|
AddInput(new Button(_padID, ButtonManager::BUTTON_DOWN));
|
||||||
AddInput(new Button(_padID, ButtonManager::BUTTON_LEFT));
|
AddInput(new Button(_padID, ButtonManager::BUTTON_LEFT));
|
||||||
AddInput(new Button(_padID, ButtonManager::BUTTON_RIGHT));
|
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_LEFT, -1.0f), 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_MAIN_UP, -1.0f), 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_UP, -1.0f), 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_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_L), new Axis(_padID, ButtonManager::TRIGGER_L));
|
||||||
AddAnalogInputs(new Axis(_padID, ButtonManager::TRIGGER_R), new Axis(_padID, ButtonManager::TRIGGER_R));
|
AddAnalogInputs(new Axis(_padID, ButtonManager::TRIGGER_R), new Axis(_padID, ButtonManager::TRIGGER_R));
|
||||||
}
|
}
|
||||||
|
@ -88,7 +88,7 @@ std::string Touchscreen::Axis::GetName() const
|
||||||
|
|
||||||
ControlState Touchscreen::Axis::GetState() const
|
ControlState Touchscreen::Axis::GetState() const
|
||||||
{
|
{
|
||||||
return ButtonManager::GetAxisValue(_padID, _index);
|
return ButtonManager::GetAxisValue(_padID, _index) * _neg;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -43,11 +43,12 @@ private:
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
std::string GetName() const;
|
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;
|
ControlState GetState() const;
|
||||||
private:
|
private:
|
||||||
const int _padID;
|
const int _padID;
|
||||||
const ButtonManager::ButtonType _index;
|
const ButtonManager::ButtonType _index;
|
||||||
|
const float _neg;
|
||||||
};
|
};
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
Loading…
Reference in New Issue