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);
}
public String getGamepadName(){
return glfwGetJoystickName(this.gamepadNum);
}
}

View File

@ -100,7 +100,6 @@ public class match {
boolean Joystick1Present = glfwJoystickPresent(GLFW_JOYSTICK_1);
boolean Joystick2Present = glfwJoystickPresent(GLFW_JOYSTICK_2);
System.out.println(Joystick1Present);
String path = "textures/Sprite.png";
String pathToBG = "textures/background_beach.png";
@ -125,13 +124,15 @@ public class match {
objP2.setTextureWrap(f.getSprite()[0], f.getSprite()[1], f.getSprite()[2], f.getSprite()[3], ObjectGl.STICK_TOP);
objP2.flipTextureWrapH();
if (Joystick1Present) {
if(Joystick1Present) {
gamepad1 = new GamepadInput(GLFW_JOYSTICK_1);
gamepad1.inputRefresh();
System.out.println("P1 Controller: " + gamepad1.getGamepadName());
}
if(Joystick2Present) {
gamepad2 = new GamepadInput(GLFW_JOYSTICK_2);
gamepad2.inputRefresh();
System.out.println("P2 Controller: " + gamepad2.getGamepadName());
}
while(frameCount < 5940 && engine.getRunning()) {