Gamepad constantly rotating down

I’m writing a same-screen multiplayer game that uses PS4 Gamepads. I have a problem with one of my pads in that the camera (controlled by the pad) keeps slowly rotating downwards. I assume this is a problem with the gamepad itself since it’s only this one gamepad that has the problem (and sometimes it magically works fine); however, it always works fine on the PS4.

My question is, can I do anything about it? Is there a config file, or can I counter this problem somehow?

More details: I use pretty much the same code from the JME examples, i.e. FlyByCamera. I map it with:-

joystick.getAxis( JoystickAxis.Z_ROTATION ).assignAxis( "jFLYCAM_Down"+id, "jFLYCAM_Up"+id );

and just read the result with

@Override
public void onAnalog(String name, float value, float tpf) {
.....
	} else if (name.equals("jFLYCAM_Down" + id)) {
		rotateCamera(value * (invertY ? -1 : 1), cam.getLeft());
            }

Thanks in advance.

Could you please write your exact gamepad model please? I doubt it’s a regular DS4.
JME’s gamepad support is kinda meh. Anything that doesn’t have button names exactly like DualShock something (don’t know the actual number), requires remapping. Thus all xbox-based pads which are more common for PC than PS-based ones (at least here) simply don’t work or require remapping by the user, which angers me, because all of them literally need the same remap. JME has internal joystick mappings file (jmonkeyengine/joystick-mapping.properties at master · jMonkeyEngine/jmonkeyengine · GitHub) and apart from PS-based pads only the remapped pads will work as intended. This approach is IMO stupid because 90% of pads don’t work out of the box.

To return to your problem, what you’re describing sounds exactly like what happened last time I plugged my XBONE S pad in before I made a pull request with required remappings. So make a file called joystick-mapping.properties in your assets directory. Then add remappings of your pad to that file and jme will pick them up. For figuring out how you have to remap it I’d recommend this jmonkeyengine/TestJoystick.java at 445f7ed010199d30c484fe75bacef4b87f2eb38e · jMonkeyEngine/jmonkeyengine · GitHub (it comes with jme3 tests project template in sdk).

I have 12 different brands of gamepads and joysticks I bought to test this and get it working at least in SOME of the cases. (It worked in exactly 0 cases before I added the support.) All 12 of those different brands work fine. Some are regular joysticks with add on buttons (flight sticks, etc.) some are PS-style and some are regular joysticks.

I’m truly sorry that Microsoft chose a totally different mapping for their joysticks than “everyone else on the planet”. But there you go.

And no matter what…

And I can’t emphasize this enough…

YOU WILL TOTALLY PISS OFF YOUR PLAYERS IF YOU DO NOT PROVIDE A WAY TO REMAP YOUR F**KING JOYSTICK INPUTS. PERIOD. No matter what.

So I think in 3.2 I will just completely remove this support and make everyone go back to the old way.

1 Like

Isnt it a deadzone setting causing this? Im quite sure it is.

Sounds a bit different than the XBOX problem to me. Since it sometimes works and is PS4 and is only one of two controllers exhibiting the problem.

To OP, are these both the same brand of joystick?

When you run the TestJoystick app what are the reported joystick names?

I’m assuming for a minute that these are real PS4 gamepads and that one of them may just have a slightly off calibration. You can see if any of the OS stuff let you calibrate it but in the end you will want to probably expand the “dead zone” a bit.

You can either do this by writing your own fly camera (not a bad idea anyway) or I believe there is a backdoor way to override the joystick’s dead zone by grabbing the axis in question, casting it to DefaultJoystickAxis, and calling setDeadZone().

http://javadoc.jmonkeyengine.org/com/jme3/input/Joystick.html#getYAxis--
http://javadoc.jmonkeyengine.org/com/jme3/input/DefaultJoystickAxis.html#setDeadZone-float-

Thanks for all the replies. I’m currently at work, but I’ll have a look and answer the questions when I get home. I’ve got 3 PS4 pads, two of which are second-hand, so I’ll have to check what the brand is.

Agreed. Another way to piss them off is for one of the most standard gamepads for PC to not work out of the box.

Never tried any flight sticks, but when it comes to gamepads it’s either PS or xbox knockoffs these days.

I need to correct this for you:
“Another way to piss them off is for various random clones of one of the allegedly most standard gamepads for PC to not work out of the box.”

I wonder if all of those Final Fantasy players are using X-box style gamepads or the specially designed PS2 style ones?

All I know is that I had 4-5 joysticks already, went to Amazon and bought the 4 cheapest ones to test with… and not a single one of the cheapest ones was XBox style. I also bought two that I actually like (because personally I like my joysticks next to each other instead of cross-eyed lopsided… but I recognize X-box users are used to sitting on one butt cheek).

Anyway, just keep bashing the support until I remove it completely. Or you can come up with a solution that might reasonably work for everyone. Since I apparently don’t have any xbox style gamepads (and I’ve spent enough on this endeavor that I’m likely to now remove anyway), it’s up to you guys to propose solutions. Is there a regex that would work?

I honestly don’t care anymore.

1 Like

You have some points there.
I’ve porposed a solution quite some time ago. Almost all xbox knockoffs have exactly same default button names and all of them need the same remap. So if the joystick handler detects that layout, maybe it could automatically switch to xbox remap?
I might take a look at the code and see how this could be done.

The only thing we have is the name the driver gives us. For the joystick itself and the buttons/axes.

Yes. I tested with 2 xbox based pads (XBONE S and Logitech Chillstream) and both report same axis/button names. I suspect all xbox based pads are handled with the same driver (one driver per xbox generation), but that might not be true.

I’ve had a look at all 3 of my PS4 controllers and they all look identical to me, complete with Sony branding, but one is doing the rotating thing (most of the time). I can only assume it’s slightly broken. I did get a couple second-hand.

Increasing the dead zone size should fix it. I suspect the PS4 auto-calibrates or something… or just has a larger dead zone to begin with.

1 Like

After heavy use the sticks tend to slacken off too. My two boys dont exactly handle them with care, but i mean as you mentioned already, there should be an in-game config anyway.

I dont think i’ve ever got that far tbh thinking about it. Iv never delved into the joystick api. My options screens are usually debug screen conversions :stuck_out_tongue: