updating linux stick button mappings

I’m having some trouble using jinput with my wireless xbox 360 gamepad on linux. I did some digging into the source and found a couple of problems.

  • The linux plugin NativeDefinitions file says that it’s generated from /usr/include/linux/input.h, but hasn’t changed in svn in 7 years. A quick comparison against my actual input.h from kernel 3.5.0 shows a lot of differences. Specifically, what’s really tripping me up is that it’s missing the button codes in the 0x200 range. My gamepad, for instance, is generating codes in this range for the d-pad.
  • Related to the previous point is that the LinuxNativeTypesMap is also out-of-date. For instance, there doesn’t appear to be an entry for BTN_START, causing the “start” button on my gamepad to show up as an “unknown” button.
  • Finally, in LinuxNativeTyepsMap.getButtonID, the code is creating a Key.UNKNOWN object instead of a Button.UNKNOWN object when the native button id isn’t recognized. I’m using jMonkeyEngine, which expects a joystick to only have buttons and axes, so even though jinput is reporting 5 “unknown” components, jME is throwing them away because they’re keys. This might be something to fix in jME but I also believe that returning a key from getButtonID is a defect.

I’d love to get these problems fixed to support the linux gaming community (and my project ;D ). I’m looking for some help here to either have the library updated or, alternatively, get some assistance with building the project so I can fix it myself and submit a patch. Can anyone offer advice?

I’ll take a look later, as long as it’s a quick fix I should be able to get a new build out tonight.

Endolf

Hi

I’ve regenerated the natives file, see if that helps, or makes it worse :slight_smile:

Endolf

That’s awesome, thank you!

I was able to figure out how to build jinput from source. Using your new native definitions I added the other fixes I mentioned in my original post and everything works way better now. Here is the patch of what I did: http://pastebin.java-gaming.org/ea3436d3d4d

Out of curiosity, I also did some research into where those “trigger happy” button codes came from. Found this commit that describes the reasoning: https://github.com/torvalds/linux/commit/cf2f765f1896064e34c6f0f2ef896ff058dd5c06. Incidentally, as of october 2012, these codes have been moved from include/linux/input.h to include/uapi/linux/input.h. I’m not sure how you’re generating that definitions file but you might trip on this sometime in the future.

Awesome.

Thank you for the patch, I’ll take a look at putting this in this today some time.

Endolf

Hi

Sorry for the delay.

Just been looking at applying your patch. All looks fine, you even fixed a bug for us :slight_smile:

Should be in tonights build.

Thanks

Endolf

It seems to affect the whole gamepad support under GNU Linux, doesn’t it?