34 lines
873 B
Java
34 lines
873 B
Java
package engine.input;
|
|
|
|
import engine.Engine;
|
|
|
|
import java.util.List;
|
|
|
|
import static org.lwjgl.glfw.GLFW.glfwGetKey;
|
|
|
|
public class Button {
|
|
|
|
public String name;
|
|
private final List<Integer> buttonsGamepad;
|
|
private final List<Integer> buttonsKeyboard;
|
|
private final GamepadInput controller;
|
|
|
|
public Button(String name, List<Integer> buttonsGamepad, List<Integer> buttonsKeyboard, GamepadInput controller){
|
|
this.name = name;
|
|
this.buttonsGamepad = buttonsGamepad;
|
|
this.buttonsKeyboard = buttonsKeyboard;
|
|
this.controller = controller;
|
|
}
|
|
|
|
public boolean isButtonPressed(){
|
|
for (int i : buttonsGamepad){
|
|
if (controller.checkPressed(i)) return true;
|
|
} for (int i : buttonsKeyboard){
|
|
if (glfwGetKey(Engine.getWindow(), i) == 1) return true;
|
|
}
|
|
return false;
|
|
}
|
|
|
|
|
|
}
|