Reputation:
I have been recently watching a tutorial on how to get controller input in lwjgl then a problem occurred so I made a new project and put in the exact code that he had letter by letter and then the same problem occurred.
The error that i am getting is that first off lwjgl is saying it cant be initialized and java is saying that there is a class not found exception?
Here is my code:
package simple;
import org.lwjgl.LWJGLException;
import org.lwjgl.input.Controller;
import org.lwjgl.input.Controllers;
public class ControllerInput {
static Controller controller;
public static void main(String[] args){
try {
Controllers.create();
} catch (LWJGLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
Controllers.poll();
for(int i = 0;i<Controllers.getControllerCount(); i++){
controller = Controllers.getController(i);
System.out.println(controller.getName());
}
}
}
(i have tried putting Controllers.destroy()
at the end but that doesnt work)
here is my error:
org.lwjgl.LWJGLException: Failed to initialise controllers
at org.lwjgl.input.Controllers.create(Controllers.java:86)
at simple.ControllerInput.main(ControllerInput.java:14)
Caused by: java.lang.NoClassDefFoundError: net/java/games/input/ControllerEnvironment
at org.lwjgl.input.Controllers.create(Controllers.java:69)
... 1 more
Caused by: java.lang.ClassNotFoundException: net.java.games.input.ControllerEnvironment
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
... 2 more
Upvotes: 0
Views: 575
Reputation: 159
It seems you're trying to use LWJGL2 legacy API with LWJGL3. Download and add to your classpath LWJGL2's jar.
LWJGL3's input handling works differently via GLFW
Upvotes: 1