-
Notifications
You must be signed in to change notification settings - Fork 18
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
[Feature request] Support 3rd party controllers that have extra buttons + gyro #73
Comments
Check your controllers with |
@antheas So the Apex 4 has many modes, let's focus on the ones available when the controller is connected wired via USB: Switch and PC: XInput, DInput Switchhhd.contrib hidraw
hhd.contrib evdev
XInputhhd.contrib hidrawNo entry found so couldn't capture anything. hhd.contrib evdev
dInputhhd.contrib hidraw
hhd.contrib evdev
|
Xinput does not appear in hidraw and only has the xbox 360 buttons. There is a chance there would be a manufacturer endpoint that shows the extra buttons in hidraw. Are you sure there arent any hidraw pages for xinput? Dinput appears in hidraw in general. It should only have one node, so thats the only interesting one really. Try running the command with sudo. Only controllers with rules in linux will work without. As for switch, its good that gyro works out of the box. But if there are no manufacturer interfaces it will not work. In general, usage pages starting with 0xff are vendor specific. If the company implements a controller tester for it, it's very likely it will list the buttons there for the tester to work. |
Yes, even tried with sudo, those are the only pages I see when in xinput:
Okay it works with sudo, I'll put the output for each of the following pages:
Hidraw 8: Usage Page: 0x0001 Usage: 0x0005 500hz
This is the page for the regular inputs + extra buttons to be read, all of them affect the value, the Z BTN is a toggle and does not reset its state as it enables the weird gyro mouse thing. Hidraw 9: Usage Page: 0x0001 Usage: 0x0001 500hz
This gives the value of the gyro when the Z BTN has been toggled, no other inputs are read Hidraw 10: Usage Page: 0xffa0 Usage: 0x0001 500hz
Looks like it's Hidraw 8 and 9 combined, could see the output for my button/stick inputs and the gyro when the "Z BTN" that enables mouse mode is toggled Hidraw 11: Usage Page: 0xffef Usage: 0x0000 NACouldn't capture anything, idk what its purpose is, nothing logged no matter what I input. Sidenote:
|
For my convenience, what does the kernel register each hidraw as? I edited your comment to emphasize the usage pages. Use |
Full dmesg output
|
Seems like
Then, I can only assume here and say that 10 is the vendor interface for the app and 11 is for firmware updates. To know more youd have to dump the hid descriptors with https://github.com/hhd-dev/hid-tools Gyro and mouse are different though. Can you see the gyro values in one of the reports always? |
eg if hidraw 10 always outputs gyro we are in business. Otherwise, you'll have to choose between buttons and gyro |
Actually scratch that. We can just mute the mouse thing and it will be fine. |
@antheas hidraw 10 always outputs gyro once the mouse thing has been toggled. It reports both the gyro (when enabled) and all the buttons/sticks/triggers/paddles (from what I've tested so far), in both mouse and gamepad mode. If the mouse mode toggle isn't on, it doesn't output the gyro values. |
Yes. Your device is a candidate for both hhd and a kernel driver. I would steer towards a kernel driver, for the lower CPU utilization and the fact that it can be upstreamed and such. That driver would just black list the first 2 hidraws while active and read the one with everything But it would not be too hard to add support for it in hhd. Perhaps as a proof of concept for the kernel driver. Much easier than a kernel driver for sure. The only problem right now is that hhd does not support plugin autodetection. But I had planned ahead when I made it so that is not that big of a deal. |
If the device has a windows application, open it up with wireshark and do some dumps. Theres a chance we can control gyro and the activation of other devices from it, as well as RGB if it has it. |
Superb news, yeah the Windows application has a lot of fancy features, the controller even has an OLED screen you can display your favorite GIF on loop, as well as LEDs customization. Some of the configuration can be done on the OLED display directly, switching saved profiles for example, but lots of customization is done through the Windows app. I'll try to do some dumps later in the evening. |
Since I also have the controller, I went ahead and did the wireshark dumps (sorry @yoyossef hope you don't mind). you can see them here https://github.com/zany130/hwinfo/tree/master/devices/Apex4/peripherals/windows I tried to match what I saw for some other devices, but if I being honest I have no clue what I am doing, lol (not even sure if I captured it right I did filter to the device (showed up as an xbox controller)) I probably should have separated some of the caps. For example, in RGB, I just switched through all the profiles and then finally off. Maybe I should have separated it by profile? Same with the joystick dump, I just went through all the options on that page (maybe I should have separated joystick mapping and joystick sensitivity) As you can see from the names of my captures, the controller has adaptive triggers (just like the Sony DualSense) and can even emulate the DualSense to get dual sense adaptive trigger effects in games. Unfortunately, I don't have any of the supported games, so I could only capture the toggle (a. |
How do you switch to dualsense? You can select the USB device before entering the capture through the gear Then while capturing you can do filters to focus in on what's going on |
Dualsense mode seems to be d-input that is activated only for a few selected exes from their software (like Overwatch and a few others), and it enables Adaptive Trigger and/or gyro support. Steam also happens to consider it as being a proper Dualsense when that mode is on it looks like, exes can be spoofed according to reddit: https://www.reddit.com/r/Controller/comments/1bez2vn/flydigi_apex_4_how_to_force_ds_mode_on_any_game/ |
D input in general uses the HID protocol The dualsense controller presents at least two interfaces: one HID device for the controller itself. Hhd can emulate that. And a multi channel audio device for the adaptive triggers. Hhd cannot, and there is no plans for it. However, if we can get the controller to do it that's that. The dualsense edge controller is exactly the same as the normal variant. The only additional part is when you press the back buttons, they appear on the report. If that's the case, there's potential for adding support for back buttons in steam together with gyro without needing any driver. And getting adaptive triggers as a bonus. They only activate when the controller uses the edge vid pid in sdl and steam, so you won't see them right now. But they will be in the report. |
Sorry I mispoke its morning Adaptive triggers are part of the hid report The audio is for the fancy rumble |
No worries, the difference with the dualsense is the lack of trackpad and lack of fancy haptic feedback (in fact I've heard that in d-input the vibration motors are completely off, I'd have to verify this), so we would have to capture and understand the events when that special Dualsense mode is on. I can do it over the week-end unless zany does/did it. |
The dualsense protocol is well documented You just need to capture whether the back buttons work in that mode. Probably not. And if the audio devices exist Doing rumble in dualsense mode is a bit complex but quite standard. Including rgb. But maybe they skipped that whole receiving part and just do some emulation for the triggers. Since you can still see the original controller Edit: actually if they support the triggers they did the receiving part. So its probably a bug I would say |
As for a bit of context on rumble: while the dualsense audio device is active the dualsense is replaying the audio as rumble In parallel, the games that send audio to the controller also send a compatibility rumble in the configuration report that is classic rumble. The dualsense is supposed to ignore this Unless the disable audio effects bit is set. Steam, proton, the kernel and games that do not support the special effects, turn that but on. So genuine controllers always have rumble We had to figure that out to get rumble working in death stranding that uses the audio rumble and has that bit off The led effects on that are also quite special and they work under hhd. Unfortunately not for GPD There are also 2 types of dualsense rumble: one they had on release and is a bit jarring, and one they added later that is much more similar to Xbox 360. They use different bits on the report and are scaled differently |
Unfortunately, you can only do this in the software
Oh, I didn't see that. So, should I redo the dumps with filters? |
Filters do not affect the dump. Selecting the USB device does. If the files are not too big, no. If they are yes. Also, some sensitive info might have snuck through. |
I've captured some traffic in said "DS Mode" by spoofing the Overwatch 2 exe with Chrome (like in the reddit example I had linked above). |
Nice thanks. Does overwatch have "standard" or "DS mode" adaptive triggers ? I'm guessing since you said "DS Mode" it has that. I ask because I remember a lot of the games on the adaptive trigger list only having "standard" adaptive triggers
ok then my dumps should be fine the biggest one was like 10mb and most where under 5mb EDIT: I wonder if it would be possible to get into this "DS Mode" with Linux by running the flydigi app on WINE... The furthest I got with that is the app running but unable to detect the controller... |
I've also captured traffic for the GIF upload thing (sidenote: the screen is always on with the GIF looping so having an option to upload a black GIF to turn it off could be a nice feature to have). But for some reason the flydigi app requires to switch to Xinput, I've captured it anyway, I won't PR it yet as it's quite a big file, I should filter it once I can reliably identify which traces are what.
Overwatch only offers DS mode. EDIT:
I wouldn't count on it, the app itself is quite unstable on Windows already |
Yeah a lot of the features of the app require the controller to be in xinput mode. I should mention all my captures where done in xinput mode. the reason being it will sometimes randomly switch you to xinput mode if your on dinput |
The app does reset itself and sets the pad to xinput quite randomly (bugs?) but I wouldn't say that xinput is required to change those settings necessarily, except for the screen GIF settings where it says it explicitly, the app pops out a warning alert that xinput is required. My guess is that we should capture as much dinput traffic as possible, what do you think @antheas ? (Also curious if you're seeing interesting stuff in my DS mode captures) |
Xinput is probably required because as you said the app is unstable. So for the app to detect the controller, the controller has to be in xinput mode. No need for them to have it working with all modes. |
My next move would be to start finding commands and move over to linux. Try to find the commands that make it change modes, then you can run them with |
found this https://github.com/ahungry/vader3/tree/master While not the Apex 4 controller, it is still a Flydigi controller. If you're still looking at this, @yoyossef, it may be useful? EDIT: another interesting tool doesn't seem to work with the apex 4 https://github.com/pipe01/flydigictl |
you can add support to steam for back buttons and gyro if the driver picks up the buttons and gyro |
Only dualsense and switch controllers support gyro, so youll get one of those glyphs At least until this releases: |
Interesting updates: apparently, Gyro sort of works in xinput mode on Linux. when configured like this I have the power-on button set to LB (no idea why its showing blank). This actually works on Linux (ie holding LB moves the left joystick according to the gyro) I wonder if there is some way to grab the gyro output, ignore the joystick movement, and then use that as a gyro in Steam. since this is xinput mode vibration also works (vibration does not work in dinput even in Windows with the software running, nor does it work in "DS mode") EDIT: also another interesting thing I found is if you get the controller into "DS mode" in a virtual machine and then remove the controller from the VM (Do not unplug the controller) it will achtally seemingly stay in "DS mode" but as far as I can tell there is no difference between this and dinput mode on linux. maybe all the magic happens in the software? |
Added some more hid report dumps into https://github.com/zany130/hwinfo/tree/master/devices/Apex4/peripherals/hid sorry if some of this is redundant, as @yoyossef already did most of this, but ... interestingly, I found that the 3rd hidraw device in dinput mode actually does outputs the gyro without the mouse when you have the mouse toggle off (circle button next to home) so the hidraw devices are as follows 1st. All controller inputs plus mouse gyro and buttons when mouse mode is toggled (circle button) like I said above, I didn't notice any difference in the hidraw reports, between normal dinput mode and getting the controller to go into "DS mode" through a Windows virtual machine |
Found a really nice app to test the controller on windows https://powgames.itch.io/game-controller-tester and found out some interesting things
so in summary it should be possible to have dinput mode expose both gyro and accelerometer sensors aswell as the extra back buttons and the extra circle button to steam, but we may not be able to get rumble working no real need investigating dualsense mode I think well maybe for adaptive trigger support? the controller already exposes everything we want (except vibration) in dinput on linux its just a matter of getting steam to recognize it |
got steam to recognize the extra buttons with this env
So, the reason the triggers became digital is because I was mapping to the trigger button instead of the trigger axis second so the correct env becomes
also disabled the gyro mouse with the following udev rule
the controller without gyro is on interface the mouse gyro is on interface and the controller with gyro is on interface I tried blacklisting interface |
Except vibration is a strong statement. Maybe the driver does not know how to make the controller vibrate But from what you're saying this is a kernel driver candidate Mind the fact that the only kernel drivers that support gyro are the steam deck, playstation and Nintendo ones So you'll need to do some copying around |
I was basing the lack of vibration more on the fact that even on Windows, there is no vibration when in either dinput mode or "DS mode" (which I think is just dinput mode with the product and vendor ID of the dualsense?). Is the best path forward to copy Windows software "DS mode" and bind the controller to the kernel PlayStation hid driver? That way we may also be able to get per-game adaptive triggers Unfortunately, this is beyond my ability. I just know how to do basic tinkering lol 😅 but it does look like what prevents steam from "seeing" the gyro in dinput mode is lack of gyro support by usbhid driver? (I think that's what get used) Stupid question but would it be possible to force it to use the PlayStation hid driver? |
Adaptive triggers are not part of the playstation driver. Linux has poor support for adaptive triggers so I don't think it's very worthwhile. Also back buttons which are more important would be missed. The best plan forward is to first document the dinput protocol, and then either make a patch to SDL or the kernel. Steam uses the SDL library which is maintained by valve for controller support. The SDL library supports the kernel drivers for gyro and all buttons, if they are exposed as the Nintendo and Playstation drivers expose them. SDL also has a large number of hand built drivers that connect to controllers directly through hid. And through that it supports touchpads, gyro, and RGB for most Microsoft, Nintendo, and Sony controllers. As far as steam is concerned, SDL contains a set of functions that receive a pid and vid and return if the controller is a Dualsense Edge controller, Dualsense, Nintendo, etc. Steam input calls those functions and depending on which one returns yes activates a different profile. Then, provided that Sdl has loaded the controller properly, those features work. However, you can have cases where say SDL cannot access the raw hid device. In that case, it falls back to the kernel driver which has a subset of features. So for example, a dualsense edge controller would still show up as if it has back button and RGB support but those features would not work. |
Which is a roundabout way of saying that if you want back buttons without valve's blessing, your controller has to identify as Xbox elite, Dualsense edge, or a joycon pair And if you want gyro, it needs to identify as a Dualsense edge or Nintendo controller. It is not possible to get steam input to support gyro without weird glyphs. You will also be able to see that when gyro or RGB works, they will be in the advanced controller settings in Steam. But if there's not a case for them in SDL, Steam Input will not let you use them |
Again, I may be completely out of my depth here and wrong, but wouldn't it be possible for some userspace driver application like Xboxdrv or SC-controller (and I am assuming hhd works similarly) to grab the Hidraw device that has gyro and everything and expose it as a controller, preferably a dual-sense controller? The problem is that I think Xboxdrv and sc-controller don't support Gyro. I know the ideal solution would be to deal with the controller upstream, but this could be POC or something. I already got the back buttons sort of working on Steam with the SDL mapping. However, as you said, since it's not identified as a DualSense Edge or any of the other known controllers that have paddle support, it doesn't activate the right profile for Steam input, meaning. At the same time, they are detected in the controller tester however, you can't map them. though interestingly I found if you apply a steam input profile from a known supported controller with paddles (like the deck or dual sense edge) you can get buttons mapped to the back paddles Just tried this with Persona 3 reload and I was able to get some actions mapped to the back buttons |
Oh didn't know about that workaround or I guess steam bug. Yes of course you can even remap the dinput controller into a dualsense edge with hhd. Hhd has support for dinput, xinput, and hidraw. If dinput works properly use that. Hidraw at 1000hz would use around 10% of a single core. If you do dinput that drops to 0 unless you're using the sticks. In which case you're looking at 7-10% again. Only while you're moving the sticks. Id look for a way of spoofing the vid/pid of the controller so steam thinks it's a dualsense edge out of the gate and you don't eat the CPU cost. Reminder we only do this hack for handheld devices because certain buttons come from a separate device and it's not possible to merge them in the kernel. Also, open an issue on SDL and reference this issue. I'm sure they would be happy to help and maybe steam gets support for this controller. |
I also benchmarked hhd yesterday and you would be happy to know it only adds .1ms to .5ms of latency depending on how the kernel feels about waking up the threads. |
I will do that. Ideally, it gets fixed there. Honestly, it sounds like the same amount of effort would need to be made to add it here or Steam/SDL. Sorry if I was bugging you or anything, but like I said, I've actually had zero experience with all this. Thanks for pointing me and @yoyossef in the right direction! |
No problem guys, getting better controller support is a win win for everyone. |
Just to give an update, it seems that with what we know of the controller right now, it won't be feasible to add support in SDL. I am still considering documenting the controller when I have time. I have just been really busy lately. |
First of all thank you for doing all of this, it looks like a really neat project, I'm soon receiving my GPD Win Max 2 and I can't wait to use this in gamemode.
Unfortunately exposing gyro, and paddle inputs across Steam is not only an issue on the handhelds you guys support.
Controllers like the Flydigi Apex 4 have 4 paddles, and gyro support that can't be exploited on Linux under gamemode. Not only because the drivers aren't supporting everything but also because Steam isn't letting us exploiting it.
I know this is not necessarily the scope of the project but the aim goal seem really close to what I want to achieve, I'd imagine the drivers for all the handhelds don't support everything all at once, so fixing all of this in the userspace + mocking it as a Dualsense Edge and/or Xbox Elite controller is a superb solution.
Would you think it'd be possible? Any hints on where I should start looking to expose my controller to hhd to enable controller mocks?
Thanks.
The text was updated successfully, but these errors were encountered: