Add GamepadButton.java

This commit is contained in:
SerpentSpirale 2021-05-20 14:37:29 +02:00
parent 91c04a15c3
commit 1d63e30e6c

View File

@ -0,0 +1,26 @@
package net.kdt.pojavlaunch.customcontrols.gamepad;
import android.view.KeyEvent;
public class GamepadButton {
/*
Just a simple button, that auto deal with the great habit from android to just SPAAAM input events
*/
public int[] keycodes;
private boolean isDown = false;
public void update(KeyEvent event){
boolean down = (event.getAction() == KeyEvent.ACTION_DOWN);
if(down != isDown){
isDown = down;
Gamepad.sendInput(keycodes, isDown);
}
}
public void resetButtonState(){
isDown = false;
}
}