Contoller integration

Started by Craumix, August 09, 2015, 18:43:05

Previous topic - Next topic

Craumix

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?


Craumix

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)

abcdef

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).

spasi

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!

spasi