Any gameButton can be toogled if needed now

This commit is contained in:
SerpentSpirale 2021-05-21 10:19:54 +02:00
parent 28725743fa
commit b86de4db95

View File

@ -8,7 +8,9 @@ public class GamepadButton {
Just a simple button, that auto deal with the great habit from android to just SPAAAM input events
*/
public int[] keycodes;
public boolean isToggleable = false;
private boolean isDown = false;
private boolean toggled = false;
public void update(KeyEvent event){
boolean isKeyDown = (event.getAction() == KeyEvent.ACTION_DOWN);
@ -18,6 +20,14 @@ public class GamepadButton {
public void update(boolean isKeyDown){
if(isKeyDown != isDown){
isDown = isKeyDown;
if(isToggleable){
if(isKeyDown){
toggled = !toggled;
Gamepad.sendInput(keycodes, toggled);
}
return;
}
Gamepad.sendInput(keycodes, isDown);
}
}