libsdl-org / SDL

Simple Directmedia Layer
https://libsdl.org
zlib License
9.4k stars 1.74k forks source link

[Feature request] Motion control support for PXN P50L 3rd party switch pro controller #9269

Closed askryan closed 6 months ago

askryan commented 6 months ago

The PXN P50L (product linked below) has motion control support, and I've tested it and found that the gyro works in Steam games. Would you guys be able to add it to SDL so it could be used for motion controls in CEMU?

Amazon link to product Official website description of controller

slouken commented 6 months ago

Steam uses SDL for controllers. Does this not work with testcontroller in the SDL main repo?

askryan commented 6 months ago

I'll try that right now

askryan commented 6 months ago

I'm sorry I'm new to github and I'm not really sure about what I should do. I cloned the repository and downloaded it, how would I run testcontroller?

slouken commented 6 months ago

What OS and build environment are you using?

askryan commented 6 months ago

I am using Windows 11, Build 23H2

askryan commented 6 months ago

I downloaded visual studio community. To run testcontroller, do I run the SDL.sln file located in the VisualC-GDK folder?

slouken commented 6 months ago

Open the one in the VisualC directory, it'll have testcontroller as one of the targets you can build.

askryan commented 6 months ago

I built testcontroller image Did I do something wrong? I'm sorry for taking up your time, I was just told to create an issue by someone in the Cemu discord if I wanted SDL to add support for the controller

slouken commented 6 months ago

Nope, it built successfully. You want to right click on testcontroller and set it as startup project and then hit F5 to run it.

askryan commented 6 months ago

With your help, I finally got the program to run, and everything (including the gyro) seems to be functioning properly. I'm not sure why the buttons won't register in Cemu. Here's a video of me pressing different buttons and the mapping not registering in cemu

https://github.com/libsdl-org/SDL/assets/79998400/e7d7dddd-b6a4-4182-b47e-8ee0b94ba467

slouken commented 6 months ago

cemu may be using an older version of SDL.

You can grab the latest SDL DLL from the latest release and replace the SDL2.dll in cemu and see if that fixes it. If cemu is 32-bit you'll want this: https://github.com/libsdl-org/SDL/releases/download/release-2.30.1/SDL2-2.30.1-win32-x86.zip otherwise you'll want this: https://github.com/libsdl-org/SDL/releases/download/release-2.30.1/SDL2-2.30.1-win32-x64.zip

askryan commented 6 months ago

Oddly enough, the motion controls randomly started working and I can now use them in cemu games (without me changing the SDL version). Thank you so much for your assistance today. I wonder what caused it to suddenly start working

slouken commented 6 months ago

Well, great! :)

AntTheAlchemist commented 6 months ago

I wonder what caused it to suddenly start working

Hi askryan, welcome.

testcontroller uses hints SDL_HINT_JOYSTICK_HIDAPI_PS5_RUMBLE & SDL_HINT_JOYSTICK_HIDAPI_PS4_RUMBLE enable extended inputs on the controller, so LED, sensors and rumble work, and they stay enabled until the controller is powered down. I'm guessing that behaviour is specific to PS controllers, but I wonder if something similar is happening for your switch controller when HIDAPI opens it? Does it still work after the controller is turned off and on again?

askryan commented 5 months ago

Hello AntTheAlchemist,

I have found that motion controls continue to work even when the controller is powered off and on again. However, it may be possible that using testcontroller triggered something that allowed extended inputs to be detected. Another possibility I thought of was that using testcontroller may have caused the controller I had to be detected as an official switch pro controller, which is supported by the SDL API, while before it was just detected as the PXN P50L, which doesn't have official support built into SDL.

askryan commented 5 months ago

But then again, the gyro was detected on Steam even before I tried all this stuff, so maybe none of these theories are correct.