From 611894537a7513effc89e9ba0678910d20fd0f44 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?L=C3=A9o?= Date: Tue, 1 Jun 2021 19:23:33 +0200 Subject: [PATCH] constructor for gamepadInput --- src/engine/Engine.java | 11 ++-- src/engine/input/GamepadInput.java | 81 ++++++++++++++++++++---------- 2 files changed, 61 insertions(+), 31 deletions(-) diff --git a/src/engine/Engine.java b/src/engine/Engine.java index 78679a3..cd3d754 100644 --- a/src/engine/Engine.java +++ b/src/engine/Engine.java @@ -220,14 +220,15 @@ public class Engine { // Game logic should fit here if (present) { //sprite //bindings - GamepadInput.inputRefresh(buttonA, buttonB, buttonX, buttonY, LB, RB , select , start , + 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); + gamepad1.inputRefresh(buttonA, buttonB, buttonX, buttonY, LB, RB , select , start , L_JoystickClick , R_JoystickClick , Up , right , down , left, leftJoyX_Axe, leftJoyY_Axe, rightJoyX_Axe, rightJoyY_Axe, LT, RT); - System.out.println( " \n left :" + GamepadInput.leftJoyLeft + - " \n right :" + GamepadInput.leftJoyRight + - " \n down :" + GamepadInput.leftJoyDown + - " \n up :" + GamepadInput.leftJoyUp); + System.out.println( " \n left :" + gamepad1.leftJoyLeft + + " \n right :" + gamepad1.leftJoyRight + + " \n down :" + gamepad1.leftJoyDown + + " \n up :" + gamepad1.leftJoyUp); } // Input.keyboardInput(zangief, speed); diff --git a/src/engine/input/GamepadInput.java b/src/engine/input/GamepadInput.java index a8b4c94..d3ee603 100644 --- a/src/engine/input/GamepadInput.java +++ b/src/engine/input/GamepadInput.java @@ -32,41 +32,70 @@ import static org.lwjgl.glfw.GLFW.*; public class GamepadInput { - public static boolean buttonA_pressed = false; - public static boolean buttonB_pressed = false; - public static boolean buttonY_pressed = false; - public static boolean buttonX_pressed = false; + public boolean buttonA_pressed ; + public boolean buttonB_pressed ; + public boolean buttonY_pressed ; + public boolean buttonX_pressed; - public static boolean LB_pressed = false; - public static boolean RB_pressed = false; + public boolean LB_pressed ; + public boolean RB_pressed ; - public static boolean select_pressed = false; - public static boolean start_pressed = false; + public boolean select_pressed; + public boolean start_pressed; - public static boolean R_JoyClick_pressed = false; - public static boolean L_JoyClick_pressed = false; + public boolean R_JoyClick_pressed; + public boolean L_JoyClick_pressed; - public static boolean up_pressed = false; - public static boolean down_pressed = false; - public static boolean left_pressed = false; - public static boolean right_pressed = false; + public boolean up_pressed ; + public boolean down_pressed; + public boolean left_pressed ; + public boolean right_pressed; - public static boolean leftJoyRight = false; - public static boolean leftJoyLeft = false; - public static boolean leftJoyDown = false; - public static boolean leftJoyUp = false; + public boolean leftJoyRight; + public boolean leftJoyLeft; + public boolean leftJoyDown; + public boolean leftJoyUp; - public static boolean rightJoyLeft = false; - public static boolean rightJoyRight = false; - public static boolean rightJoyDown = false; - public static boolean rightJoyUp = false; - - public static boolean LT_pressed = false; - public static boolean RT_pressed = false; + public boolean rightJoyLeft; + public boolean rightJoyRight; + public boolean rightJoyDown ; + public boolean rightJoyUp; + 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, + 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.buttonA_pressed = buttonA_pressed; + this.buttonB_pressed = buttonB_pressed; + this.buttonY_pressed = buttonY_pressed; + this.buttonX_pressed =buttonX_pressed; + this.LB_pressed =LB_pressed; + this.RB_pressed =RB_pressed; + this.select_pressed =select_pressed; + this.start_pressed =start_pressed; + this.R_JoyClick_pressed =R_JoyClick_pressed; + this.L_JoyClick_pressed =L_JoyClick_pressed; + this.up_pressed =up_pressed; + this.down_pressed =down_pressed; + this.left_pressed =left_pressed; + this.right_pressed =right_pressed; + this.leftJoyRight =leftJoyRight; + this.leftJoyLeft =leftJoyLeft; + this.leftJoyDown =leftJoyDown; + this.leftJoyUp =leftJoyUp; + this.rightJoyLeft =rightJoyLeft; + this.rightJoyRight =rightJoyRight; + this.rightJoyDown =rightJoyDown; + this.rightJoyUp =rightJoyUp; + this.LT_pressed =LT_pressed; + this.RT_pressed =RT_pressed; + } - public static void inputRefresh(int ButtonA, int ButtonB, int ButtonX, int ButtonY, int LB, int RB , + public void inputRefresh(int ButtonA, int ButtonB, int ButtonX, int ButtonY, int LB, int RB , int select , int start , int L_JoyClick , int R_JoyClick , int up , int right , int down , int left, int leftJoyX_Axe, int leftJoyY_Axe, int rightJoyX_Axe, int rightJoyY_Axe, int LT, int RT) { //to update for more controlBinding ByteBuffer gamepadButton = glfwGetJoystickButtons(GLFW_JOYSTICK_1);