77 lines
1.8 KiB
Java
77 lines
1.8 KiB
Java
package engine.input;
|
|
|
|
import engine.math.Vector3f;
|
|
import engine.object.ObjectGl;
|
|
import org.lwjgl.glfw.GLFW;
|
|
import org.lwjgl.glfw.GLFWKeyCallback;
|
|
|
|
import java.nio.ByteBuffer;
|
|
import java.nio.FloatBuffer;
|
|
|
|
import static org.lwjgl.glfw.GLFW.*;
|
|
import static org.lwjgl.opengl.GL11.*;
|
|
/* Buttons
|
|
0 : Croix / A
|
|
1: rond /B
|
|
2: carré / X
|
|
3: triangle / Y
|
|
4: L1 / LB
|
|
5: R1 / RB
|
|
6:select
|
|
7:start
|
|
8:L3
|
|
9:R3
|
|
10: haut
|
|
11: droite
|
|
12: bas
|
|
13: gauche
|
|
*/
|
|
|
|
/* Axes
|
|
0 : left X axe ( right : 1 left -1)
|
|
1: left Y axe ( down : 1 , Up -1)
|
|
2: right X axe ( right : 1 left -1)
|
|
3: right Y axe ( down : 1 , Up -1)
|
|
4:L2 / LT : 1 active, -1 unactive
|
|
5: R2 /RT : 1 active, -1 unactive
|
|
*/
|
|
|
|
public class gamepadInput{
|
|
//à définir //à définir
|
|
public static void gamepadInput(ObjectGl token, int speed,int jump, int attack, int act3, int act4) { //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(jump)==1 ) { // appuie sur croix(PlayStation) A (Xbox)
|
|
jump( token,speed);
|
|
}
|
|
|
|
if (gamepadButton.get(attack)==1 ) { // appuie sur rond(PlayStation) B (Xbox)
|
|
attack( token,speed);
|
|
}
|
|
|
|
if (gamepadAxes.get(3) > 0.1) {
|
|
crouch(token,speed);
|
|
}
|
|
|
|
|
|
}
|
|
|
|
public static void jump(ObjectGl token,int speed) {
|
|
token.translate(new Vector3f( 0.0f, speed * 20.0f, 0.0f));
|
|
|
|
}
|
|
|
|
public static void attack(ObjectGl token,int speed) {
|
|
|
|
}
|
|
|
|
public static void crouch(ObjectGl token,int speed) {
|
|
token.setTextureWrap(161,260,56,59, ObjectGl.STICK_BOTTOM);
|
|
}
|
|
|
|
}
|