lwjgl Joystick

Started by AGP, April 16, 2009, 08:20:45 PM

Previous topic - Next topic

AGP

I have two programs. One uses an AWT window and initializes the FrameBuffer like this:
buffer = new FrameBuffer(width, height, SAMPLINGMODE_NORMAL);
buffer.enableRenderer(IRenderer.MODE_OPENGL);

Then (after World.renderScene(buffer) and World.draw(buffer)) calls buffer.display(Graphics). The other, like this: buffer = new FrameBuffer(width, height, SAMPLINGMODE_HARDWARE_ONLY);
buffer.enableRenderer(IRenderer.RENDERER_OPENGL);
then makes only buffer.displayGLOnly() calls. Oddly, the first program initializes and uses the lwjgl joystick succesfully whereas the second one can't get past controllers.create()! Why oh why?

EgonOlsen

What happens? Does it crash or is there a deadlock or what?

BTW:

buffer.enableRenderer(IRenderer.MODE_OPENGL);

is actually wrong. It will give you a software renderer in OpenGL-mode but that's more by accident than intentionally. Correct is:

buffer.enableRenderer(IRenderer.RENDERER_SOFTWARE);

AGP

I know, I realized it as I typed it here. But that's the code that runs the joystick. The other one just throws an LWJGLException (which I catch), so nothing happens but I can't access the joystick.

EgonOlsen

Can you post the actual exception?

AGP

I figured it out. Part of it is the fact that although it compiles with just a reference to lwjgl.jar, to run you have to reference jinput.jar. Plus, Vista x64 is giving me a headache. I can't wait for EVERYTHING to be 64-bit already.

Here's another joystick-related question: I wrote years ago a Java 2D game which only used the keyboard. Yesterday I decided to add the lwjgl joystick to it, so instead of drawing into the awt frame I added the AWTGLCanvas to the frame and drew on the canvas. This time I initialize the controllers just fine and even get a Controller instance. But when I poll the joystick for input, its value are always -1. I realize this question belongs in the lwjgl boards but there are a lot more people here.

EgonOlsen

You may try to query the stick in the startPainting()-method of an IPaintListener, albeit i don't think that OpenGL and joysticks are related, but you never know.
Or maybe there is a kind of update() or poll() method for the controller, that will be called automatically when using a normal Display but that will be omitted when using the AWTGLCanvas? I'm just guessing here, but LWJGL tends to bind all kind of input polling to the Display.

EgonOlsen

You are using an AWTGLCanvas (i.e. obtained from FrameBuffer.enableGLCanvasRenderer()) and are calling Display.setParent(canvas) too? Interesting...i would think that the setParent() hasn't any purpose here or does it?

Anyway, that's quite off topic. Sadly, i've never used any joystick related stuff. So it does work with the normal, native GL display but doesn't work with the AWTGL-based one?

AGP

Actually, in this case I'm referencing lwjgl directly (no jPCT). But I must be thinking more clearly today than I was yesterday because I solved it. Thanks for your help, pal.