Hello i'm new at lwjgl and i have a xbox contoller and want to use it.
I've searched for the org.lwjgl.input package in the build 3.0.0b build 9 but it doesn't seems to be there...
So how can I use Controllers?
LWJGL uses GLFW, so look here:
http://www.glfw.org/docs/latest/group__joysticks.html
I tried:
System.out.println(GLFW.glfwGetJoystickName(GLFW.GLFW_JOYSTICK_1));
But I only get:
Exception in thread "main" java.lang.NullPointerException
at org.lwjgl.system.MemoryUtil.memDecodeUTF8(MemoryUtil.java:1153)
at org.lwjgl.system.MemoryUtil.memDecodeUTF8(MemoryUtil.java:1140)
at org.lwjgl.glfw.GLFW.glfwGetJoystickName(GLFW.java:2426)
at game.Game.main(Game.java:13)
Did you initialise GLFW first? You don't need a window created but you need to initialise GLFW for that command to work
Take from getting started page
// Initialize GLFW. Most GLFW functions will not work before doing this.
if ( glfwInit() != GL11.GL_TRUE )
throw new IllegalStateException("Unable to initialize GLFW");
Edit :
But it would be nice that if null came back a "no" would be returned instead (to say not present).
Quote from: abcdef on August 09, 2015, 21:31:57But it would be nice that if null came back a "no" would be returned instead (to say not present).
Indeed, I will fix this in the next build. Thanks!
Fixed in build 3.0.0b #14.