mirror of
https://github.com/AngelAuraMC/Amethyst-Android.git
synced 2025-09-16 16:16:04 -04:00
- Reset state will now only send an input when necesarry.
This commit is contained in:
parent
95fd415f94
commit
0ddc5db967
@ -5,12 +5,12 @@ import android.view.KeyEvent;
|
|||||||
public class GamepadButton {
|
public class GamepadButton {
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Just a simple button, that auto deal with the great habit from android to just SPAAAM input events
|
Just a simple button, that auto deal with the great habit from android to just SPAAAMS input events
|
||||||
*/
|
*/
|
||||||
public int[] keycodes;
|
public int[] keycodes;
|
||||||
public boolean isToggleable = false;
|
public boolean isToggleable = false;
|
||||||
private boolean isDown = false;
|
private boolean isDown = false;
|
||||||
private boolean toggled = false;
|
private boolean isToggled = false;
|
||||||
|
|
||||||
public void update(KeyEvent event){
|
public void update(KeyEvent event){
|
||||||
boolean isKeyDown = (event.getAction() == KeyEvent.ACTION_DOWN);
|
boolean isKeyDown = (event.getAction() == KeyEvent.ACTION_DOWN);
|
||||||
@ -22,23 +22,25 @@ public class GamepadButton {
|
|||||||
isDown = isKeyDown;
|
isDown = isKeyDown;
|
||||||
if(isToggleable){
|
if(isToggleable){
|
||||||
if(isKeyDown){
|
if(isKeyDown){
|
||||||
toggled = !toggled;
|
isToggled = !isToggled;
|
||||||
Gamepad.sendInput(keycodes, toggled);
|
Gamepad.sendInput(keycodes, isToggled);
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Gamepad.sendInput(keycodes, isDown);
|
Gamepad.sendInput(keycodes, isDown);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void resetButtonState(){
|
public void resetButtonState(){
|
||||||
isDown = false;
|
if(isDown || isToggled){
|
||||||
toggled = false;
|
|
||||||
Gamepad.sendInput(keycodes, false);
|
Gamepad.sendInput(keycodes, false);
|
||||||
}
|
}
|
||||||
|
isDown = false;
|
||||||
|
isToggled = false;
|
||||||
|
}
|
||||||
|
|
||||||
public boolean isDown(){
|
public boolean isDown(){
|
||||||
return isToggleable ? toggled : isDown;
|
return isToggleable ? isToggled : isDown;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user