Affiche le controleur utilisé par chaque joueur

This commit is contained in:
Antoine 2021-06-11 16:03:51 +02:00
parent e2586cbcd2
commit 6ac2db30ea
2 changed files with 7 additions and 2 deletions

View File

@ -107,4 +107,8 @@ public class GamepadInput {
return new Vector3f(x,y); return new Vector3f(x,y);
} }
public String getGamepadName(){
return glfwGetJoystickName(this.gamepadNum);
}
} }

View File

@ -100,7 +100,6 @@ public class match {
boolean Joystick1Present = glfwJoystickPresent(GLFW_JOYSTICK_1); boolean Joystick1Present = glfwJoystickPresent(GLFW_JOYSTICK_1);
boolean Joystick2Present = glfwJoystickPresent(GLFW_JOYSTICK_2); boolean Joystick2Present = glfwJoystickPresent(GLFW_JOYSTICK_2);
System.out.println(Joystick1Present);
String path = "textures/Sprite.png"; String path = "textures/Sprite.png";
String pathToBG = "textures/background_beach.png"; String pathToBG = "textures/background_beach.png";
@ -128,10 +127,12 @@ public class match {
if(Joystick1Present) { if(Joystick1Present) {
gamepad1 = new GamepadInput(GLFW_JOYSTICK_1); gamepad1 = new GamepadInput(GLFW_JOYSTICK_1);
gamepad1.inputRefresh(); gamepad1.inputRefresh();
System.out.println("P1 Controller: " + gamepad1.getGamepadName());
} }
if(Joystick2Present) { if(Joystick2Present) {
gamepad2 = new GamepadInput(GLFW_JOYSTICK_2); gamepad2 = new GamepadInput(GLFW_JOYSTICK_2);
gamepad2.inputRefresh(); gamepad2.inputRefresh();
System.out.println("P2 Controller: " + gamepad2.getGamepadName());
} }
while(frameCount < 5940 && engine.getRunning()) { while(frameCount < 5940 && engine.getRunning()) {