Updates to joystick support

I finally got my hands on an XBox style gamepad and was able to address some long-standing issues that folks have complained about. Being able to put hands on one was very educational.

First, I’ve added two new JoystickAxis constants:
LEFT_TRIGGER
RIGHT_TRIGGER

These map to logical IDs .rx and .ry… which in my pile of game controllers seems to map to all non-XBox style gamepads. For XBox they will be remapped in config. The issue is that generic and play station style controllers never seem to report anything but a generic name (even a PS4 controller only shows up as “Wireless Controller”) but I guess most Xbox controllers will have “xbox” in the name somewhere.

Second, along those lines, the joystick remapping support now allows for a regex normalization in joystick name. For example:

XBOX.regex=(?i).*xbox.*

…means we can create one button/axis remapping for “XBOX” and anything with the word ‘xbox’ anywhere in its actual name (case insensitive) will match.

I’ve left the old XBox controller configurations in temporarily but I’ve commented them out.

Third, the TestJoystick app has been updated to support the new LEFT_TRIGGER/RIGHT_TRIGGER axes.

On Playstation style controllers, the triggers are axes and also buttons so they get reported both ways. (Buttons 6 and 7 usually) For Xbox controllers, these seem only to be treated as axes… so the test joystick app accounts for this now.

If you build JME from source and have a controller to test, you might consider giving the TestJoystick app a whirl to see if it still works with your game controller after these changes.

Commits:
https://github.com/jMonkeyEngine/jmonkeyengine/commit/5901a95363b5e0675023fd5b61878cf829753c50
https://github.com/jMonkeyEngine/jmonkeyengine/commit/54b812ca7182afd2a1369baf42eabc44afe9d51b
https://github.com/jMonkeyEngine/jmonkeyengine/commit/59af265398839ec82115597ded8f296e4e320735

10 Likes

Thanks :slightly_smiling_face:

question: i heard console machines (ps,xbox) dont have jvm installed. how can we make games for this platforms then? it can run some standalone jvm?

Note the point here is to use Xbox/PS joystick controllers in JME.

ah right, was just confused, but yes, just joystick :smiley: got it

anyway im curious if xbox/ps would allow provide game with some standalone jvm(if there is any for consoles i dont check)

I think running JME games on a console is probably a separate thread from getting random gamepads to work on desktop PC JME.

1 Like

Thanks for your hard work Pspeed!

Being that I was the one complaining most about this, I really appreciate it. My next game is going to require this support. I will test it once I get fully prototyping.

Wobblytrout