LWJGL Controller Advice [Getting false axis events]

So, I’ve got Keyboard and Mouse redone to use LWJGL instead of AWT or whatever built-in thing I’d been doing. Remapping works pretty well, and everything. And now, I’m going to try and take this 360 controller we bought and try to make that happen.

Any advice, as I dive in to controller support? Any major differences I should be aware of between how LWJGL treats controllers versus keyboards or mice?

I suppose if I run into any nasty, stumping problems, I’ll edit or reply to this topic.

You should take the pressed key and print it out! You would get numbers and you could insted checking for “A” pressed you check “5” pressed.

Good idea. That’s what I did for keyboard and mouse – there are default bindings, but it’s basically agnostic to the actual names of the keys or mice, so it should be easy to reconfigure for non-English keyboards and such. I’ll be doing something similar for controllers.

Having trouble getting it to recognize the binaries. It complained they weren’t in java.library.path, so I set java.library.path to the same as org.lwjgl.librarypath , all before it ever tries to set up controllers, but it still complains. If I paste the same path into my NetBeans project properties -> run -> VM Options as -Djava.library.path=“C:\Users\Joel\Documents\NetBeansProjects\hippo\native\windows” , it works. This, even though printing out java.library.path shows the same path whether I set it in the VM Options or in the program.

I’m trying this, but they call it a hack, which makes me raise an eyebrow about its reliability: http://blog.cedarsoft.com/2010/11/setting-java-library-path-programmatically/

[EDIT: that hack appears to work, and my, it recognizes a lot of controllers. My Xbox 360 controller comes up first, then my keyboard (twice), my microphone (twice, but very interesting), then the driver for my wife’s not-connected drawing tablet (also twice), though it claims it failed to initialize said tablet driver (did it fail on both versions that it saw? on one? on a third one that didn’t end up in the controllers list?)]

Current problem, for those interested in helping, or for posterity:

The “X Rotation” axis (moving the right stick side-to-side on the Xbox 360 controller I’m using) is giving constant false positives. I keep getting events where the x- and y-axis values for the event are both 0.0, it’s an axis event, and the axis name is “X Rotation”. This regardless of what I set the RXDeadZone to (the default is 0.05, I think).

I guess I’ll just ignore them for now, as they seem to be doing no real harm?

If anyone knows what’s up here, I’d appreciate any advice.

I think that you cant read like that, try somehow getting the angle of your stick, if not just don’t use it! Hope i helped :smiley:

Thanks. It hands me events separately for horizontal and vertical movement, and I can compute the angle from those.

The events, as far as I can tell, only trigger when a stick position changes. The right stick gets labeled by LWGLJ as “X Rotation” and “Y Rotation”, depending on which direction you push it. If you push it straight to the right, for example, it triggers an X Rotation event with a value of 1.0. All the way to the left is -1.0. If you were to push it, say, to the right and a little bit down, it would give a pair of events, something like X Rotation 1.0 and Y Rotation 0.4253412. And, if you let go of the stick, it fires an event for each axis with values of 0.0. So, on this controller at least, 0.0 is centered. You can set a dead zone where it’s not supposed to notice little changes, if I understand correctly.

The weird thing is that, for any other stick movements, it only fires the event once each time you move. It doesn’t keep creating events if you hold it still. Yet, the “X Rotation” axis (left-right on the right stick) keeps firing a 0.0 event. It looks as if the computer thinks that the stick keeps getting moved to the center from somewhere else, over and over again, instead of just staying there.

Create a variable for x and y for your stick and set it. After the method is called again check if x,y is the same if not set it to to a difrent x,y