libsdl-org / SDL

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

Flydigi Apex 4 support #10161

Closed zany130 closed 2 months ago

zany130 commented 3 months ago

as recommended here https://github.com/hhd-dev/hhd/issues/73#issuecomment-2204345871 it sounds like this would be the best place to get this supported? If not could you please point me in the right direction, I have no experience with these kinds of things :sweat_smile:

I found that the Flydigi Apex 4 controller has four interfaces

  1. normal gamepad
  2. gyro mouse device toggled with a button on the controller (circle button next to home)
  3. gamepad with gyro
  4. unknown, maybe firmware updates or the Windows software.

Right now, Steam and other SDL applications are reading the first interface, meaning they do not see the gyro.

In the above issue, it was recommended that this could maybe be fixed in SDL?

slouken commented 3 months ago

I picked up the Apex 4 controller, and it looks like the third interface only has gyro data when mouse mode is enabled. I verified this on both Windows and Linux. I haven't installed the Space Station software or anything, so this is the default firmware out of the box.

The reason why SDL only sees the first interface is because the third interface is using a custom vendor-specific usage page and usage, and that's being ignored right now.

slouken commented 3 months ago

If you can figure out what needs to be sent to the controller to enable gyro data with the mouse mode off, then we could create an SDL hidraw driver that supports the back buttons and the gyro simultaneously.

zany130 commented 3 months ago

I picked up the Apex 4 controller, and it looks like the third interface only has gyro data when mouse mode is enabled. I verified this on both Windows and Linux.

Hmmm that's strange on Linux I saw what I assumed was gyro data (but might be wrong) on the 3rd interface with mouse mode off .

I treated with the hid-recoeder

And moving the controller around changed the values

slouken commented 3 months ago

I believe you, but maybe something put the controller into a mode where it reports that data? Maybe a firmware update, or the Windows app turning on DS mode?

zany130 commented 3 months ago

Yes I will investigate I don't think it's ds mode as I currently have that off and I don't think that affects Linux anyway

It could be firmware update.

EDIT: fwiw this is the output I am talking about that I think is gyro https://asciinema.org/a/RSp7loKVR1IufltoVpFNOphK6

for that test I had the controller wired and I only moved the controller around. i did not touch any of the sticks or buttons.

I also had the gyro mouse off

I then repeatedly placed the controller on a table lifted it up and placed it back down

I saw some of the values going to 0 when placed on a table and then changed when picked up.

So this is gyro correct? I just want to make sure because I might be wrong lol like I saId no experience with any of this lol

EDIT2: this is my settings in the app image

I wonder if the gyro mapping has anything to do with it...

EDIT3: Intresting that it! if I have gyro mapping disabled in the software I no longer get gyro( or whatever that data was) without toogleing the gyro mouse first in hid recorder

so it seems a gyro mapping has to be set in the software from my testing it doesn't seem to matter what mapping you set (there is mouse, left stick, and right stick) It also doesn't seem to matter if its in "Racing mode" or "FPS mode" for the gyro

from what I understand from reviews and the manual the difference should be fps mode is full gyro in all directions, and racing should be just for left and right tilts

the strange thing is I don't need to press the toggle button that set for this (in my case is LB) to get the gyro output in hid recorder

zany130 commented 2 months ago

would this be enough to get gyro support added in a SDL driver?

not sure if this is "true" gyro or just the same thing as the mouse mode when you press the circle button

slouken commented 2 months ago

Given that you need to set a gyro mapping in software, and it looks like we can't tell if that's set, I'm going to say this isn't enough to add gyro support in an SDL driver. If we can find out whether gyro is enabled, then that might change, but I'm going to go ahead and close this for now.

zany130 commented 1 month ago

sorry for bumping this but just wanted to add a few observations I made.

This might of already been obvious but

there 2 ways the controller sends gyro data to the OS (this is both on linux and windows WITHOUT the driver software running (more on that in a bit)

  1. Natively in switch mode
  2. Emulating some other input device (a mouse or one controller analog stick either left or right) and mapping that device to the controller's gyro

The second way of sending gyro can further be separated into two catagory's

This is what pressing the "circle button" (extra button next to home) does in dinput mode and is what flydigi refers to as" flymouse". All the OS sees is the normal controller and a virtual mouse which is mapped to gyro by the controllers firmware.

This is the Gyro mapping I mentioned you can set up in software. You can map gyro to either analog sticks, or to the "fly mouse" (controller virtual mouse)

Interestingly, mouse Gryo doesn't need the driver software running (it does require the software to set it up), but analog stick gyro does (this is true on BOTH windows and Linux)

zany130 commented 6 days ago

@slouken, what about the back paddles? What would have to be done to get those supported? Rumble is the other thing not working in dinput mode but I am guessing that would be in the kernel?