inputVariables
This commit is contained in:
parent
611894537a
commit
094fedc3a2
@ -25,10 +25,6 @@ public class Engine {
|
|||||||
|
|
||||||
private final List<ObjectGl> objectsGl;
|
private final List<ObjectGl> objectsGl;
|
||||||
|
|
||||||
private final static int buttonA=0, buttonB=1, buttonX=2, buttonY=3, LB = 4, RB = 5, select = 6, start = 7,
|
|
||||||
L_JoystickClick = 8, R_JoystickClick =9, Up = 10, right = 11, down = 12, left = 13,
|
|
||||||
leftJoyX_Axe = 0, leftJoyY_Axe = 1, rightJoyX_Axe = 2, rightJoyY_Axe = 3, LT = 4, RT = 5;
|
|
||||||
|
|
||||||
private boolean running;
|
private boolean running;
|
||||||
|
|
||||||
private final int width;
|
private final int width;
|
||||||
@ -221,9 +217,7 @@ public class Engine {
|
|||||||
|
|
||||||
if (present) { //sprite //bindings
|
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(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 ,
|
gamepad1.inputRefresh();
|
||||||
L_JoystickClick , R_JoystickClick , Up , right , down , left,
|
|
||||||
leftJoyX_Axe, leftJoyY_Axe, rightJoyX_Axe, rightJoyY_Axe, LT, RT);
|
|
||||||
|
|
||||||
System.out.println( " \n left :" + gamepad1.leftJoyLeft +
|
System.out.println( " \n left :" + gamepad1.leftJoyLeft +
|
||||||
" \n right :" + gamepad1.leftJoyRight +
|
" \n right :" + gamepad1.leftJoyRight +
|
||||||
|
@ -3,6 +3,8 @@ package engine.input;
|
|||||||
import java.nio.ByteBuffer;
|
import java.nio.ByteBuffer;
|
||||||
import java.nio.FloatBuffer;
|
import java.nio.FloatBuffer;
|
||||||
|
|
||||||
|
import engine.Engine;
|
||||||
|
|
||||||
import static org.lwjgl.glfw.GLFW.*;
|
import static org.lwjgl.glfw.GLFW.*;
|
||||||
/* Buttons
|
/* Buttons
|
||||||
0 : Croix / A
|
0 : Croix / A
|
||||||
@ -95,9 +97,7 @@ public class GamepadInput {
|
|||||||
this.RT_pressed =RT_pressed;
|
this.RT_pressed =RT_pressed;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void inputRefresh(int ButtonA, int ButtonB, int ButtonX, int ButtonY, int LB, int RB ,
|
public void inputRefresh() {
|
||||||
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);
|
ByteBuffer gamepadButton = glfwGetJoystickButtons(GLFW_JOYSTICK_1);
|
||||||
FloatBuffer gamepadAxes = glfwGetJoystickAxes(GLFW_JOYSTICK_1);
|
FloatBuffer gamepadAxes = glfwGetJoystickAxes(GLFW_JOYSTICK_1);
|
||||||
|
|
||||||
@ -106,50 +106,50 @@ public class GamepadInput {
|
|||||||
|
|
||||||
|
|
||||||
// A B X Y
|
// A B X Y
|
||||||
buttonA_pressed = gamepadButton.get(ButtonA) == 1;
|
buttonA_pressed = gamepadButton.get(inputVariables.buttonA) == 1;
|
||||||
buttonB_pressed = gamepadButton.get(ButtonB) == 1;
|
buttonB_pressed = gamepadButton.get(inputVariables.buttonB) == 1;
|
||||||
buttonY_pressed = gamepadButton.get(ButtonY) == 1;
|
buttonY_pressed = gamepadButton.get(inputVariables.buttonY) == 1;
|
||||||
buttonX_pressed = gamepadButton.get(ButtonX) == 1;
|
buttonX_pressed = gamepadButton.get(inputVariables.buttonX) == 1;
|
||||||
|
|
||||||
|
|
||||||
// LB RB
|
// LB RB
|
||||||
LB_pressed = gamepadButton.get(LB) == 1;
|
LB_pressed = gamepadButton.get(inputVariables.LB) == 1;
|
||||||
RB_pressed = gamepadButton.get(RB) == 1;
|
RB_pressed = gamepadButton.get(inputVariables.RB) == 1;
|
||||||
|
|
||||||
|
|
||||||
//start select
|
//start select
|
||||||
start_pressed = gamepadButton.get(start) == 1;
|
start_pressed = gamepadButton.get(inputVariables.start) == 1;
|
||||||
select_pressed = gamepadButton.get(select) == 1;
|
select_pressed = gamepadButton.get(inputVariables.select) == 1;
|
||||||
|
|
||||||
|
|
||||||
//R & L JoystickClick
|
//R & L JoystickClick
|
||||||
R_JoyClick_pressed = gamepadButton.get(R_JoyClick) == 1;
|
R_JoyClick_pressed = gamepadButton.get(inputVariables.R_JoystickClick) == 1;
|
||||||
L_JoyClick_pressed = gamepadButton.get(L_JoyClick) == 1;
|
L_JoyClick_pressed = gamepadButton.get(inputVariables.L_JoystickClick) == 1;
|
||||||
|
|
||||||
|
|
||||||
//up, down, left, right
|
//up, down, left, right
|
||||||
up_pressed = gamepadButton.get(up) == 1;
|
up_pressed = gamepadButton.get(inputVariables.up) == 1;
|
||||||
down_pressed = gamepadButton.get(down) == 1;
|
down_pressed = gamepadButton.get(inputVariables.down) == 1;
|
||||||
left_pressed = gamepadButton.get(left) == 1;
|
left_pressed = gamepadButton.get(inputVariables.left) == 1;
|
||||||
right_pressed = gamepadButton.get(right) == 1;
|
right_pressed = gamepadButton.get(inputVariables.right) == 1;
|
||||||
|
|
||||||
|
|
||||||
//Left Joystick
|
//Left Joystick
|
||||||
leftJoyRight = gamepadAxes.get(leftJoyX_Axe) > 0.1;
|
leftJoyRight = gamepadAxes.get(inputVariables.leftJoyX_Axe) > 0.1;
|
||||||
leftJoyLeft = gamepadAxes.get(leftJoyX_Axe) < -0.1;
|
leftJoyLeft = gamepadAxes.get(inputVariables.leftJoyX_Axe) < -0.1;
|
||||||
leftJoyDown = gamepadAxes.get(leftJoyY_Axe) > 0.1;
|
leftJoyDown = gamepadAxes.get(inputVariables.leftJoyY_Axe) > 0.1;
|
||||||
leftJoyUp = gamepadAxes.get(leftJoyY_Axe) < -0.1;
|
leftJoyUp = gamepadAxes.get(inputVariables.leftJoyY_Axe) < -0.1;
|
||||||
|
|
||||||
|
|
||||||
//Right Joystick
|
//Right Joystick
|
||||||
rightJoyRight = gamepadAxes.get(rightJoyX_Axe) > 0.1;
|
rightJoyRight = gamepadAxes.get(inputVariables.rightJoyX_Axe) > 0.1;
|
||||||
rightJoyLeft = gamepadAxes.get(rightJoyX_Axe) < -0.1;
|
rightJoyLeft = gamepadAxes.get(inputVariables.rightJoyX_Axe) < -0.1;
|
||||||
rightJoyDown = gamepadAxes.get(rightJoyY_Axe) > 0.1;
|
rightJoyDown = gamepadAxes.get(inputVariables.rightJoyY_Axe) > 0.1;
|
||||||
rightJoyUp = gamepadAxes.get(rightJoyY_Axe) < -0.1;
|
rightJoyUp = gamepadAxes.get(inputVariables.rightJoyY_Axe) < -0.1;
|
||||||
|
|
||||||
//LT RT
|
//LT RT
|
||||||
LT_pressed = gamepadButton.get(LT) == 1;
|
LT_pressed = gamepadButton.get(inputVariables.LT) == 1;
|
||||||
RT_pressed = gamepadButton.get(RT) == 1;
|
RT_pressed = gamepadButton.get(inputVariables.RT) == 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean checkPressed(int keyCode){
|
public boolean checkPressed(int keyCode){
|
||||||
|
7
src/engine/input/inputVariables.java
Normal file
7
src/engine/input/inputVariables.java
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
package engine.input;
|
||||||
|
|
||||||
|
public class inputVariables {
|
||||||
|
public final static int buttonA=0, buttonB=1, buttonX=2, buttonY=3, LB = 4, RB = 5, select = 6, start = 7,
|
||||||
|
L_JoystickClick = 8, R_JoystickClick =9, up = 10, right = 11, down = 12, left = 13,
|
||||||
|
leftJoyX_Axe = 0, leftJoyY_Axe = 1, rightJoyX_Axe = 2, rightJoyY_Axe = 3, LT = 4, RT = 5;
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user