Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Possible problem with linking multiple /dev/input devices together for PS5 controller #16

Open
alecfriedman3 opened this issue Sep 11, 2024 · 5 comments

Comments

@alecfriedman3
Copy link

Noticed a very strange problem that I think I've narrowed down to here (though could be wrong as there are a few moving pieces in this setup, but I'll explain why I think this library is the root cause). I'm using Sunshine for game streaming, which creates an emulated PS5 controller for motion control through this library. As far as I can tell, Sunshine appears to be using this library correctly (and very simply). An emulated controller is created as expected, however some applications are not able to link the multiple eventX devices back together.

I noticed the problem using an application AntiMicroX to map controller inputs to keyboard events. AntiMicroX would show a gyro section in its UI when a native PS5 controller was connected directly to my machine, but that field was missing from the emulated PS5 controller from Sunshine (created with inputtino). Using evtest, I'm able to see the "... Motion Sensors" /dev/input/eventx item for the emulated controller, so it definitely exists, and the "... Motion Sensors" input does respond to gyro changes from the device in evtest (since the device inputs do exist, that implies Sunshine is likely not the root cause)

Next I dug into AntiMicroX's code, and what I ultimately found, by building AntiMicroX from source and attaching a debugger, was that SDL_GameControllerHasSensor (referenced usage here) errors for every available SDL_SENSOR_<TYPE>, which would imply that SDL is not actually able to unify the sensors back to the primary controller. (Because I've now traced this issue down to native SDL library calls failing, that implies AntiMicroX is likely not the culprit)

Now again, I know there are a bunch of moving pieces here in my particular setup. I haven't attempted to reproduce this outside the context of this setup, but I suspect if I did I may run into the same issue. AntiMicroX is just making a few SDL_ library calls, Sunshine is just making a call straight to inputtino to create the controller, and I find it unlikely the bug originates from SDL itself, which leaves inputtino as the only piece left in the chain.

I would try to create a small cpp app to reproduce, but I already spent too much time tracing the issue and don't really have more time to dedicate to it LOL. Happy to bring this over to one of the other projects mentioned if you're not able to reproduce and think one of them may actually be the root cause.

@ABeltramo
Copy link
Member

Thanks for the very detailed report, that's highly appreciated!

You went down the rabbit hole uh? If you're interested in what lies below that SDL call I've written a bit of rationale behind the matching in SDL in here. My guess is that AntiMicroX is linked to an old SDL version for some reason, can you double-check that? Also, is it running in the host or is it via Flatpak or some container like that?

As a side note, to better test SDL + joypads I've forked a little CLI utility that you can easily compile and test: https://github.com/games-on-whales/sdl-jstest you can run it with sdl2-jstest --gamecontroller 0 if that also doesn't pick up the virtual device then it could either be the SDL version or possibly something weird with the udev rules..

@alecfriedman3
Copy link
Author

alecfriedman3 commented Sep 11, 2024

Way down the rabbit hole yes lmao. AntiMicroX reports it's using SDL version 2.30.7 in its logs. All apps running native on OpenSUSE Tumbleweed. Another thing to note is that Steam is able to pick up the gyro, and it works flawlessly through steam input, but Steam may be unifying the inputs in some other way. I was able hack around what I was trying to do by using the virtual controller steam-input creates, so I don't necessarily need a fix here, but figured it's worth surfacing at least.

I'll see if I can give sdl2-jstest a try soon. The possibility of something weird with udev rules did also occur, but I didn't do too much digging in that direction

@ABeltramo
Copy link
Member

Right, so that's the very latest SDL2 fresh from release. I can try upgrading my local installation and see if I can reproduce the issue (I'm currently at 2.30.0).

If you could give sdl2-jstest a quick try I'd be interested to know if that works!

@alecfriedman3
Copy link
Author

Alright, yep. Confirmed same behavior in sdl2-jstest. Virtual controller shows no gyro or accel controls, but native PS5 controller shows both. Interestingly when I turned on the real PS5 controller, sdl2-jstest couldn't even find the virtual one until I turned off the real one (don't think that's related though).

@ABeltramo
Copy link
Member

Thanks for confirming, I'll test out the latest SDL version on my end too. If that still works on my side I'm afraid it'll be some permission issue with the udev rules..

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants