left joystick control ( textures update)
This commit is contained in:
parent
7bcbad5792
commit
3e12e98010
@ -216,28 +216,32 @@ public class Engine {
|
||||
// if (Input.isKeyDown(GLFW.GLFW_KEY_S))token.translate(new Vector3f ( 0.0f,speed * -5.0f, 0.0f));
|
||||
// if (Input.isKeyDown(GLFW.GLFW_KEY_D))token.translate(new Vector3f (speed * 5.0f, 0.0f, 0.0f));
|
||||
// }
|
||||
private static void gamepadInput(ObjectGl token, int speed) {
|
||||
private static void gamepadInput(ObjectGlTex token, int speed) {
|
||||
ByteBuffer gamepadButton = glfwGetJoystickButtons(GLFW_JOYSTICK_1);
|
||||
FloatBuffer gamepadAxes = glfwGetJoystickAxes(GLFW_JOYSTICK_1);
|
||||
String name = GLFW.glfwGetJoystickName(GLFW_JOYSTICK_1);
|
||||
|
||||
//System.out.println("GamePad Name :" + name);
|
||||
for (int i =0 ; i < gamepadAxes.capacity(); i++) {
|
||||
System.out.println(i + " :" + gamepadAxes.get(i));
|
||||
}
|
||||
System.out.flush();
|
||||
// for (int i =0 ; i < gamepadAxes.capacity(); i++) {
|
||||
// System.out.println(i + " :" + gamepadAxes.get(i));
|
||||
// }
|
||||
|
||||
|
||||
if (gamepadButton.get(0) ==1 ) { // appuie sur croix(PlayStation) A (Xbox)
|
||||
token.translate(new Vector3f (speed *-5.0f, 0.0f, 0.0f));
|
||||
token.translate(new Vector3f ( 0.0f, speed * 5.0f, 0.0f));
|
||||
}
|
||||
|
||||
if ( (gamepadAxes.get(2) < -0.1 || gamepadAxes.get(2) > 0.1) ) { // de droite à gauche
|
||||
if ( (gamepadAxes.get(2) < -0.1 || gamepadAxes.get(2) > 0.1) ) { // de droite à gauche //joystick gauche
|
||||
token.translate(new Vector3f (5*speed * gamepadAxes.get(2), 0.0f, 0.0f));
|
||||
if ( gamepadAxes.get(2) < -0.1 ){
|
||||
token.setTextureWrap(121,0,57,80);
|
||||
}else if (gamepadAxes.get(2) > 0.1) {
|
||||
token.setTextureWrap(178,0,62,82);
|
||||
}
|
||||
}
|
||||
|
||||
if ( (gamepadAxes.get(3) < -0.1 || gamepadAxes.get(3) > 0.1) ) { // de haut en bas
|
||||
if ( (gamepadAxes.get(3) < -0.1 || gamepadAxes.get(3) > 0.1) ) { // de haut en bas //joystick gauche
|
||||
token.translate(new Vector3f (0.0f, -5* speed * gamepadAxes.get(3), 0.0f));
|
||||
|
||||
}
|
||||
|
||||
/* Buttons
|
||||
|
Loading…
x
Reference in New Issue
Block a user