detection of all gamepad buttons (except RT LT)
This commit is contained in:
parent
bd587a5587
commit
db05036c01
@ -218,7 +218,7 @@ public class Engine {
|
||||
// Game logic should fit here
|
||||
|
||||
if (present) { //sprite //bindings
|
||||
gamepadInput.gamepadInput(zangief, speed, buttonA, buttonB, buttonX, buttonY);
|
||||
gamepadInput.gamepad(zangief, speed, buttonA, buttonB, buttonX, buttonY, LB, RB , select , start ,L_JoystickClick , R_JoystickClick , Up , right , down , left);
|
||||
|
||||
System.out.println( " \n A :" + gamepadInput.buttonA_pressed +
|
||||
" \n B :" + gamepadInput.buttonB_pressed +
|
||||
|
@ -42,34 +42,96 @@ public class gamepadInput{
|
||||
public static boolean buttonB_pressed = false;
|
||||
public static boolean buttonY_pressed = false;
|
||||
public static boolean buttonX_pressed = false;
|
||||
//à définir //à définir
|
||||
public static void gamepadInput(ObjectGl token, int speed,int ButtonA, int ButtonB, int ButtonX, int ButtonY) { //to update for more controlBinding
|
||||
|
||||
public static boolean LB_pressed = false;
|
||||
public static boolean RB_pressed = false;
|
||||
|
||||
public static boolean select_pressed = false;
|
||||
public static boolean start_pressed = false;
|
||||
|
||||
public static boolean R_JoyClick_pressed = false;
|
||||
public static boolean L_JoyClick_pressed = false;
|
||||
|
||||
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 static void gamepad(ObjectGl token, int speed,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) { //to update for more controlBinding
|
||||
ByteBuffer gamepadButton = glfwGetJoystickButtons(GLFW_JOYSTICK_1);
|
||||
FloatBuffer gamepadAxes = glfwGetJoystickAxes(GLFW_JOYSTICK_1);
|
||||
|
||||
assert gamepadAxes != null;
|
||||
assert gamepadButton != null;
|
||||
|
||||
|
||||
|
||||
|
||||
if (gamepadButton.get(ButtonA)==1 ) { // appuie sur croix(PlayStation) A (Xbox)
|
||||
// A B X Y
|
||||
if (gamepadButton.get(ButtonA)==1 ) {
|
||||
buttonA_pressed = true;
|
||||
}else buttonA_pressed = false;
|
||||
|
||||
if (gamepadButton.get(ButtonB)==1 ) { // appuie sur rond(PlayStation) B (Xbox)
|
||||
if (gamepadButton.get(ButtonB)==1 ) {
|
||||
buttonB_pressed = true;
|
||||
}else buttonB_pressed = false;
|
||||
|
||||
if (gamepadButton.get(ButtonY)==1 ) { // appuie sur rond(PlayStation) B (Xbox)
|
||||
if (gamepadButton.get(ButtonY)==1 ) {
|
||||
buttonY_pressed = true;
|
||||
}else buttonY_pressed = false;
|
||||
|
||||
if (gamepadButton.get(ButtonX)==1 ) { // appuie sur rond(PlayStation) B (Xbox)
|
||||
if (gamepadButton.get(ButtonX)==1 ) {
|
||||
buttonX_pressed = true;
|
||||
}else buttonX_pressed = false;
|
||||
|
||||
|
||||
// LB RB
|
||||
if (gamepadButton.get(LB)==1 ) {
|
||||
LB_pressed = true;
|
||||
}else LB_pressed = false;
|
||||
if (gamepadButton.get(RB)==1 ) {
|
||||
RB_pressed = true;
|
||||
}else RB_pressed = false;
|
||||
|
||||
|
||||
//start select
|
||||
if (gamepadButton.get(start)==1 ) {
|
||||
start_pressed = true;
|
||||
}else start_pressed = false;
|
||||
|
||||
if (gamepadButton.get(select)==1 ) {
|
||||
select_pressed = true;
|
||||
}else select_pressed = false;
|
||||
|
||||
|
||||
//R & L JoystickClick
|
||||
if (gamepadButton.get(R_JoyClick)==1 ) {
|
||||
R_JoyClick_pressed = true;
|
||||
}else R_JoyClick_pressed = false;
|
||||
if (gamepadButton.get(L_JoyClick)==1 ) {
|
||||
L_JoyClick_pressed = true;
|
||||
}else L_JoyClick_pressed = false;
|
||||
|
||||
|
||||
//up, down, left, right
|
||||
if (gamepadButton.get(select)==1 ) {
|
||||
up_pressed = true;
|
||||
}else up_pressed = false;
|
||||
|
||||
if (gamepadButton.get(select)==1 ) {
|
||||
down_pressed = true;
|
||||
}else down_pressed = false;
|
||||
|
||||
if (gamepadButton.get( left)==1 ) {
|
||||
left_pressed = true;
|
||||
}else left_pressed = false;
|
||||
|
||||
if (gamepadButton.get(right)==1 ) {
|
||||
right_pressed = true;
|
||||
}else right_pressed = false;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user