From f4b7d5752ded8e2f481a66cdb876f4038f3eb3f6 Mon Sep 17 00:00:00 2001 From: Antoine Date: Tue, 1 Jun 2021 19:54:05 +0200 Subject: [PATCH] =?UTF-8?q?GLFW=5FJOYSTICK=5FN=20envoy=C3=A9=20depuis=20le?= =?UTF-8?q?=20constructeur?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/engine/Engine.java | 2 +- src/engine/input/GamepadInput.java | 12 ++++++------ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/engine/Engine.java b/src/engine/Engine.java index 4f6d8f3..7792cde 100644 --- a/src/engine/Engine.java +++ b/src/engine/Engine.java @@ -216,7 +216,7 @@ public class Engine { // Game logic should fit here if (present) { //sprite //bindings - GamepadInput gamepad1 = new GamepadInput(false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false); + GamepadInput gamepad1 = new GamepadInput(GLFW_JOYSTICK_1, false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false); gamepad1.inputRefresh(); System.out.println( " \n left :" + gamepad1.leftJoyLeft + diff --git a/src/engine/input/GamepadInput.java b/src/engine/input/GamepadInput.java index 33302da..8d807a2 100644 --- a/src/engine/input/GamepadInput.java +++ b/src/engine/input/GamepadInput.java @@ -3,8 +3,6 @@ package engine.input; import java.nio.ByteBuffer; import java.nio.FloatBuffer; -import engine.Engine; - import static engine.input.inputVariables.*; import static org.lwjgl.glfw.GLFW.*; /* Buttons @@ -34,6 +32,8 @@ import static org.lwjgl.glfw.GLFW.*; */ public class GamepadInput { + + private final int gamepadNum; public boolean buttonA_pressed ; public boolean buttonB_pressed ; @@ -67,11 +67,11 @@ public class GamepadInput { public boolean LT_pressed ; public boolean RT_pressed; - public GamepadInput (boolean buttonA_pressed,boolean buttonB_pressed,boolean buttonY_pressed, boolean buttonX_pressed, boolean LB_pressed, + public GamepadInput (int gamepadNum, boolean buttonA_pressed,boolean buttonB_pressed,boolean buttonY_pressed, boolean buttonX_pressed, boolean LB_pressed, boolean RB_pressed, boolean select_pressed, boolean start_pressed,boolean R_JoyClick_pressed, boolean L_JoyClick_pressed , boolean up_pressed, boolean down_pressed,boolean left_pressed,boolean right_pressed,boolean leftJoyRight,boolean leftJoyLeft,boolean leftJoyDown, boolean leftJoyUp, boolean rightJoyLeft, boolean rightJoyRight, boolean rightJoyDown,boolean rightJoyUp,boolean LT_pressed, boolean RT_pressed){ - + this.gamepadNum = gamepadNum; this.buttonA_pressed = buttonA_pressed; this.buttonB_pressed = buttonB_pressed; this.buttonY_pressed = buttonY_pressed; @@ -99,8 +99,8 @@ public class GamepadInput { } public void inputRefresh() { - ByteBuffer gamepadButton = glfwGetJoystickButtons(GLFW_JOYSTICK_1); - FloatBuffer gamepadAxes = glfwGetJoystickAxes(GLFW_JOYSTICK_1); + ByteBuffer gamepadButton = glfwGetJoystickButtons(this.gamepadNum); + FloatBuffer gamepadAxes = glfwGetJoystickAxes(this.gamepadNum); assert gamepadAxes != null; assert gamepadButton != null;