added input package

test for control binding
This commit is contained in:
Léo 2021-05-30 19:06:15 +02:00
parent 4f8a32d5a4
commit 09562c4216
3 changed files with 38 additions and 26 deletions

View File

@ -1,16 +1,20 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<classpath> <classpath>
<classpathentry kind="src" path="src"/> <classpathentry including="**/*.java" kind="src" output="target/classes" path="src">
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-11"> <attributes>
<attributes> <attribute name="optional" value="true"/>
<attribute name="module" value="true"/> <attribute name="maven.pomderived" value="true"/>
<attribute name="maven.pomderived" value="true"/> </attributes>
</attributes> </classpathentry>
</classpathentry> <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-11">
<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER"> <attributes>
<attributes> <attribute name="maven.pomderived" value="true"/>
<attribute name="maven.pomderived" value="true"/> </attributes>
</attributes> </classpathentry>
</classpathentry> <classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
<classpathentry kind="output" path="target/classes"/> <attributes>
</classpath> <attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="output" path="target/classes"/>
</classpath>

View File

@ -1,9 +1,12 @@
package engine; package engine;
import engine.input.Input;
import engine.input.gamepadInput;
import engine.math.*; import engine.math.*;
import engine.object.*; import engine.object.*;
import engine.sound.*; import engine.sound.*;
import org.lwjgl.glfw.GLFWFramebufferSizeCallback; import org.lwjgl.glfw.GLFWFramebufferSizeCallback;
import org.lwjgl.glfw.GLFWVidMode; import org.lwjgl.glfw.GLFWVidMode;
import org.lwjgl.opengl.GL; import org.lwjgl.opengl.GL;
@ -21,7 +24,7 @@ public class Engine {
private final List<ObjectGl> objectsGl; private final List<ObjectGl> objectsGl;
private static boolean present = glfwJoystickPresent(GLFW_JOYSTICK_1);
private boolean running; private boolean running;
@ -61,8 +64,8 @@ public class Engine {
this.setWindow(glfwCreateWindow(width, height, "Boulevard Combattant", NULL, NULL)); this.setWindow(glfwCreateWindow(width, height, "Boulevard Combattant", NULL, NULL));
assert getWindow() != NULL; assert getWindow() != NULL;
boolean present = glfwJoystickPresent(GLFW_JOYSTICK_1);
System.out.println(present); System.out.println("Manette détectée : " + present);
// On récupère les informations du moniteur principal // On récupère les informations du moniteur principal
GLFWVidMode vidmode = glfwGetVideoMode(glfwGetPrimaryMonitor()); GLFWVidMode vidmode = glfwGetVideoMode(glfwGetPrimaryMonitor());
@ -205,14 +208,20 @@ public class Engine {
long lastFrame; long lastFrame;
int frame = 0; int frame = 0;
boolean nextFrame = false; boolean nextFrame = false;
boolean present = glfwJoystickPresent(GLFW_JOYSTICK_1);
int buttonA=0;
int buttonB=1;
int buttonX=3;
int buttonY=4;
while (engine.isRunning()) { while (engine.isRunning()) {
lastFrame = System.currentTimeMillis(); lastFrame = System.currentTimeMillis();
// Game logic should fit here // Game logic should fit here
if (present) { if (present) {
Input.gamepadInput(zangief, speed); gamepadInput.gamepadInput(zangief, speed, buttonA, buttonB, buttonX, buttonY);
} }
Input.keyboardInput(zangief, speed); Input.keyboardInput(zangief, speed);
// input(smiley2, speed); // input(smiley2, speed);

View File

@ -1,5 +1,6 @@
package engine; package engine.input;
import engine.Engine;
import engine.math.Vector3f; import engine.math.Vector3f;
import engine.object.ObjectGl; import engine.object.ObjectGl;
import org.lwjgl.glfw.GLFW; import org.lwjgl.glfw.GLFW;
@ -38,9 +39,7 @@ public class Input extends GLFWKeyCallback {
String name = GLFW.glfwGetJoystickName(GLFW_JOYSTICK_1); String name = GLFW.glfwGetJoystickName(GLFW_JOYSTICK_1);
System.out.println("GamePad Name :" + name); System.out.println("GamePad Name :" + name);
// 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) if (gamepadButton.get(0) ==1 ) { // appuie sur croix(PlayStation) A (Xbox)