How to use gamepads in JME

Hey guys and girls,

I’m completely new to JME. I have a little project in which I would like to implement gamepad controls. Unfortunately, I find documentation on the use of gamepads rather hard to find. How do I do it? I tried treating it exactly as I would treat a keyboard (define mappings (with JoyAxisTrigger e.g.) in a listener which is registered to the InputManager) but unfortunately, this doesn’t work for me. What do I have to do to be able to use a gamepad?

Did you set this?
http://javadoc.jmonkeyengine.org/com/jme3/system/AppSettings.html#setUseJoysticks-boolean-

A few places to look when you want to understand something in easiest to hardest order:
-wiki
-javadoc
-test applications (there is a TestJoystick application in this case that might have made a bunch of things clear)
-the source code.

Edit: the first two may not have been 100% helpful in this case other than to confirm your current path… but the third one certainly would have helped. just have to know about it… and now you do. :slight_smile:

1 Like

Hi @nesta.bentum & @pspeed,

Yes, there is even a tutorial that “simulates” a game pad’s input. I don’t have the link but will look for it because I distinctly remember copying the code and running it and it was insightful albeit I don’t use a gamepad which brings a question to ALL Monkeys which is;

I know game pads are used for that is why there was an example but in reality (here is the question) what percentage of JME games/apps actually use a game pad???

No offence to you @nesta.bentum, you brought up a great question and triggered another from myself of which I look forward to seeing for it is a curiosity to myself.

Thanks,

Adam

I tend to set it up in all of mine. Using Lemur, it’s pretty easy to use the same handling code for keys, joystick, and mouse. The code doesn’t care… so it’s easy to support it.

I think my Lemur Gem camera input example shows this:

When setting up your mappings, you can even have different scales for different axes, invert them, etc… very powerful. (and you can use it without the rest of Lemur as InputMapper works on its own, too… though Lemur is pretty nice even if I do say so myself.)

Hi @pspeed,

Well that is some GREAT feedback for sure!!!

I played with Lemur when I was deciding the UI for my application so I guess even though I use my own I’ll give it another look see…Thanks!!!

I am still interested in:

Just for my own curiosity and self metrics…Thanks!!!

Adam

First of all: thanks for all your great contributions!
I just now wanted to take a look at the TestJoystick example and run it but unfortunately, I get an Exception saying that the assets cannot be found. How exactly do I have to run this example for it to work?

Okay, I managed to make the example executable…but it says that it cannot find any joysticks. I had my wired PS4 gamepad and my wire/-less XBOX One gamepad connected…none of them worked. Does anybody know why?

Hi @nesta.bentum,

I’m not an M$ guy nor a XBOX or Playstation person either but I am (one of my degrees) an EE and I think (especially on M$) you’d need a driver and my reasoning is that

1.) That would be a reverse engineer of the HW to fit into the OS
2.) [Main reason] If M$ didn’t want the $$$$ they would allow such cross compatible “drivers”

PS being SONY, I think that would be a NO way on the M$ end.

Now is it doable???

Well I say everything (almost) is possible so and correct me if I am mistaken (it happens :wink: ) that you are on Windows??? And if so that leads back to writing a driver.

I mean this with all kindness, but M$ and their hype of UPNP (Universal Plug and Play) is just that hype for sure it will plug in and that is as far as they (M$) are committed to UPNP!

So it plugs in OK, but its M$ and that means “driver” for the OS has no idea what it is supposed to do.

Sorry, but thats the way it is…but I sure like a curious mind trying to as I put it “Connect door knobs to light bulbs”!

Adam