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

Virpil controller support #6839

Closed
cyb3rd4d opened this issue Jun 10, 2023 · 50 comments
Closed

Virpil controller support #6839

cyb3rd4d opened this issue Jun 10, 2023 · 50 comments

Comments

@cyb3rd4d
Copy link

Hello dear Proton community

I recently bought a Virpil controller (a Constellation Alpha) and it was recognized as a game pad by my Steam games (Elite Dangerous and Star Wars Squadrons). I tried a lot of different versions of Proton with those games, official, experimental and also from GE.

I was pretty sure that was a Proton (or at least a Steam) issue, and not a Wine issue, because my controller works in Star Citizen that I run through Lutris. I only had to open the wine control panel for my game, run the game controllers settings and move my controller from the xinput section to the "connected" one (the first section of the window settings).

But for my Steam games, I tried a lot of things I found on wine forums, Reddit etc... mainly tweeking regedit keys with no luck, until I found this post: https://www.reddit.com/user/xatrekak/comments/12hnz0d/fixing_vkb_and_virpil_hotas_running_on_linux/ which fixed my issue.

Here is the content of the post:

So there is an issue with the VIRPIL and VKB products being detected as xbox controllers when Running them on Linux, particularly with Elite: Dangerous. Here is how I fixed it.

After weeks of trouble shooting this is the workarounds that I came up with. Hopefully this helps.

This is the standard documented fix:

Open regedit in your WINEPREFIX

Navigate to HKEY_LOCAL_MACHINE\System\CurrentControlSet\Services\winebus

Create a new DWORD named "Enable SDL" with value 0

Create a new DWORD named "Map Controllers" with value 0

In theory the two values above should prevent wine from mapping your devices to xinput. In my experience this alone does not resolve the problem, so if you still have issues then we need to remove every trace of xinput from the registry without completely nuking the controller (which is what happens when you indiscriminately delete the PID/VID entries from the registry) so also complete the following steps:

Navigate to HKEY_LOCAL_MACHINE\System\CurrentControlSet\Enum\WINEXINPUT

Delete every folder heading under this

Navigate to HKEY_LOCAL_MACHINE\System\CurrentControlSet\Enum\WINEBUS

Expand every heading that matches the VID/PID of your HOTAS (execute lsusb from the terminal to find your VID/PID)

you should see a long ass folder with a name similar to 273&03000000443300009043000011010000&0&0

Change these key values

Name "Service": change the data from xinput -> winehid

Name "DeviceDesc": change the data from: Wine XInput compatible device -> Wine HID compatible device

Name "CompatiableIds": The data field is a multi line input field. delete everything except: WINEBUS\WINE_COMP_HID

Here are some other things related to my setup that some people have found to be necessary and some have had luck without needing:

Running from lutris instead of though Steam/proton

wine version >= lutris-GE-Proton7-27-x86_64

I didn't had to run the game through Lutris though. After applying the regedit changes, my controller axes and buttons became available in the Elite Dangerous settings.

I really hope this feedback will be useful to improve the Proton support of Virpil controllers.

@kisak-valve
Copy link
Member

Hello @cyb3rd4d, the workaround you've shared is a pretty strong hint that your issue is with libSDL not knowing about your controller, not Proton.

Bypassing libSDL is not a practical option to improve support for your device. Instead, take a look at how your controller interacts with SDL's test utilities and maybe a native Linux game that uses SDL for controller input, see how it behaves, and file an upstream issue report with libSDL with your findings.

@cyb3rd4d
Copy link
Author

Hello @kisak-valve, thank you for your reply!

I just installed the packages sdl-jstest and sdl2-jstest from the AUR and I tested my joystick with those two utilities, the buttons and the axes behaves correctly.

I also forgot to mention that my joystick works out of the box on Windows in Elite Dangerous.

@kakra
Copy link
Contributor

kakra commented Aug 29, 2023

Do you guys have VID/PIDs of the Virpil controller so I could add it to my PR ValveSoftware/wine#197?

@cyb3rd4d
Copy link
Author

Thank you @kakra, I found 3344:412f

❯ lsusb
Bus 001 Device 004: ID 3344:412f Leaguer Microelectronics (LME) R-VPC Stick MT-50CM2

@kakra
Copy link
Contributor

kakra commented Aug 30, 2023

To make it work, try the following steps (replace 0x3344/0x412F by your specific USB device ID):

  1. Make sure, the wine-proton prefix isn't running (stop the game)
  2. In the game properties, change your launch options to PROTON_ENABLE_HIDRAW=0x3344/0x412F %command%
  3. Go to the compatdata directory of the affected game and create a backup of pfx/system.reg at some other location
  4. Open pfx/system.reg in a text editor and remove all whole sections which contain values or names with these:
    • lines containing both vid_3344 and pid_412f
    • lines containing both VID_3344 and PID_412F

Ensure that you have deployed udev rules for your controller. You should find a file in /etc/udev/rules.d containing something like these:

# Leaguer Microelectronics (LME) R-VPC Stick MT-50CM2
KERNEL=="hidraw*", ATTRS{idVendor}=="3344", ATTRS{idProduct}=="412f", MODE="0660", TAG+="uaccess"

(if not, create 60-steam-input.rules with those lines and reboot)

Now start the game: Your Virpil should now be properly detected.

If this works, I'll add your controller to my list of patches.

@kakra
Copy link
Contributor

kakra commented Aug 30, 2023

Thank you @kakra, I found 3344:412f

Do you have just one stick and this is the right grip? Or is it a compound device having both throttle and joystick combined into a single USB device?

@cyb3rd4d
Copy link
Author

It's not a compound device, just a base (MongoosT-50CM2) and a grip (Constellation ALPHA-R).

To make it work, try the following steps:

Can you wait until Saturday or Sunday? I don't have a lot of free time during the week.

kakra added a commit to kakra/wine-proton that referenced this issue Sep 1, 2023
kakra added a commit to kakra/wine-proton that referenced this issue Sep 1, 2023
kakra added a commit to kakra/wine-proton that referenced this issue Sep 1, 2023
@cyb3rd4d
Copy link
Author

cyb3rd4d commented Sep 2, 2023

OK I followed your procedure, I just uninstall the game and reinstalled it before just to make sure to have a clean environment. The Proton version I used is 8.0-3.

The udev rule did not exist so I created the file and I rebooted before launching the game, my Virpil was detected with all its buttons and axes! THANK YOU SO MUCH!!!

But isn't it too restrictive to target my product ID to determine if it's a Virpil controller? Shouldn't we only target the vendor ID?

@kakra
Copy link
Contributor

kakra commented Sep 2, 2023

But isn't it too restrictive to target my product ID to determine if it's a Virpil controller? Shouldn't we only target the vendor ID?

Yeah it is restrictive but OTOH, what if Virpil made other type of devices, too, which should not be handled in that way? It probably needs a more generic approach, like looking at the HID descriptor itself and identifying some common traits of the controller, i.e., my VKB has 128 buttons in the descriptor. So if it would be the VKB VID with 128 buttons, we could say it's a joystick. This may be oversimplified but I think one gets the idea.

For the moment, it would be useful to also know the PID if the left grip. Any chance you could get that from somewhere, maybe a friend?

@cyb3rd4d
Copy link
Author

cyb3rd4d commented Sep 2, 2023 via email

@stoertebecker
Copy link

I just received my Constellation Alpha-R and a WarBRD-D Base from Virpil and was following the instuctions here. Creating a udev rule and adding the PROTON_ENABLE_HIDRAW environment variable did the trick, my joystick works perfectly fine with proton 8 in DCS World (haven't tried other games yet). Thank you very much for this info :)

Playing around with the virpil software, i noticed something: the device got a new product ID several times.
I'm not 100% sure anymore but i think first time it happened when i created a new profile for it, second time when i did the firmware update and a third time when i tried the "split by 32 buttons" option on the profile page in the software. Again, not 100% sure but on this third time it might have changed to the ID that it had in the beginning.

This 32 button split option says that this could help if a game doesn't understand input devices with more than 32 buttons. I'm not sure what it is supposed to do tho. Sounds like it would split the device into several virtual 32 button devices maybe?

The Vendor ID stays the same tho (3344).

Anyways... since my device did change the PID i doubt that checking the PID is a good option (maybe cyb3rd4d can confirm this change of the product ID if you play around in the virpil software?).

I only have this Virpil device but i doubt that Virpil has any devices that should act like an xbox controller. But i also don't know if it would be a good idea to simply enable HIDRAW on all devices with VID 3344.

@kakra
Copy link
Contributor

kakra commented Sep 2, 2023

This 32 button split option says that this could help if a game doesn't understand input devices with more than 32 buttons. I'm not sure what it is supposed to do tho. Sounds like it would split the device into several virtual 32 button devices maybe?

See here: ValveSoftware/wine#197

What the split does is creating a compound device of four individual input devices. Linux still sees it as a single device because the kernel doesn't implement compound devices for generic HID drivers but because Proton wine handles the raw HID devices, it should properly pass through to the game which see four joysticks then each with 32 buttons.

I only have this Virpil device but i doubt that Virpil has any devices that should act like an xbox controller. But i also don't know if it would be a good idea to simply enable HIDRAW on all devices with VID 3344.

I'm not sure where the problem comes from. I think it's SDL which forces wine into making it an XInput device which in turn makes games see it as an Xbox controller.

How many buttons does Virpil create?

@stoertebecker
Copy link

stoertebecker commented Sep 2, 2023

How many buttons does Virpil create?

It comes with 6 axis and 31 buttons and this is also what is setup in the default profile and also what windows sees.

The software allowes to set up 6 more axis and up to 128 buttons in total. If you configure some of those extra buttons, the "Game Controller Settings" of windows shows only one buttons more (then 32, i guess this is just a limitation of that UI tho) but the virpil tester thing sees all extra buttons that are configured.

@kakra
Copy link
Contributor

kakra commented Sep 2, 2023

Do both show devices show 31 buttons? This makes it a bit difficult to make it generic. I've changed VKB detection now to detect 128 buttons and the VID, and fall back to PID if there are not 128 buttons. But for Virpil? Should we go with 31 buttons? Or 128?

@stoertebecker
Copy link

Yes, with the default profile it shows 31 buttons in both, the virpil tester and the windows controller settings.
In the input device section of manjaro system settings (KDE) it also shows 31 buttons.

The actual name of the device can also be changed in the software. Funny thing is: even the VID and PID can be customized in the software (still don't understand why it randomly changes the PID even if i don't touch that field). I doubt that anyone would ever change that but theoretically, not even the vendor ID is a constant thing with this device.

I actually do think that checking only for VID 3344 is probably the most "plug and play" way for virpil stuff. I still think that other virpil devices should be tested first. I unfortunately don't know anyone with virpil stuff tho.

kakra added a commit to kakra/wine-proton that referenced this issue Sep 2, 2023
This is useful to detect some devices which do not have a well-known
PID set.

Link: ValveSoftware/Proton#6839 (comment)
kakra added a commit to kakra/wine-proton that referenced this issue Sep 2, 2023
@kakra
Copy link
Contributor

kakra commented Sep 2, 2023

I actually do think that checking only for VID 3344 is probably the most "plug and play" way for virpil stuff. I still think that other virpil devices should be tested first. I unfortunately don't know anyone with virpil stuff tho.

I've changed the logic: ValveSoftware/wine@d4112ed

For the udev rules, it should be fine to just compare the VID.

@cyb3rd4d
Copy link
Author

cyb3rd4d commented Sep 3, 2023

Anyways... since my device did change the PID i doubt that checking the PID is a good option (maybe cyb3rd4d can confirm this change of the product ID if you play around in the virpil software?).

I tried to enable the "split by 32 buttons" option but that did not change the PID. Changing some other things in the customization tool neither. I'm on the latest firmware version so I could not try to update it.

kakra added a commit to kakra/steam-devices that referenced this issue Sep 3, 2023
This adds generic hidraw support for Thrustmaster because at least T16000m throttle and joystick also need hidraw access.

Also it add Virpil and VKB as mentioned here:
- ValveSoftware/wine#197
- ValveSoftware/Proton#6839
kakra added a commit to kakra/wine-proton that referenced this issue Sep 12, 2023
This is useful to detect some devices which do not have a well-known
PID set.

Link: ValveSoftware/Proton#6839 (comment)
kakra added a commit to kakra/wine-proton that referenced this issue Sep 12, 2023
@kakra
Copy link
Contributor

kakra commented Sep 27, 2023

I tried to enable the "split by 32 buttons" option but that did not change the PID. Changing some other things in the customization tool neither. I'm on the latest firmware version so I could not try to update it.

I think for Elite Dangerous to see the virtual devices, they really need to appear as a different PIDs. So that may be why you can change the PID. I think VKB has a similar thing. If VID/PID is identical, Elite Dangerous sees just one device. People who buy two identical joysticks for twin-stick see the same problem: ED sees just one joystick, and you need to get external tools which can create virtual joysticks.

kakra added a commit to kakra/wine-proton that referenced this issue Oct 3, 2023
This is useful to detect some devices which do not have a well-known
PID set.

Link: ValveSoftware/Proton#6839 (comment)
kakra added a commit to kakra/wine-proton that referenced this issue Oct 3, 2023
@kakra
Copy link
Contributor

kakra commented Jun 5, 2024

@ArsenCross I submitted a series of patches to better support your controllers out-of-the-box. See ValveSoftware/wine#240.

@ArsenCross
Copy link

ArsenCross commented Jun 5, 2024

@ArsenCross Some games, e.g. Elite Dangerous, cannot handle two separate devices on the same device ID.
... snipped...
Elite doesn't care about how many buttons a device has.

That's actually a relatively recent change with Elite. Elite is actually the reason my throttle is configured to be a compound device right now so unless they removed functionality when they added support for direct input devices with more than 32 buttons I find it unlikely Elite is the cause.

As I was writing this I went on a ramble that caused me to do some further testing and MWO which I've also used the devices in is not seeing the compound devices second set of buttons either. The same was true for the official VPC Tester software when I was trying it last night after I had made my post.

I think my solution is going to be to reflash the firmware on the throttle into a single device however I'm roadblocked by the inability to pass through the device through to Wine or my Windows VM. That however is not a problem for this thread.

Edit: Didn't see this...

@ArsenCross I submitted a series of patches to better support your controllers out-of-the-box. See ValveSoftware/wine#240.

That's amazing and you're awesome @kakra.

Edit2: A side note, the compound device's second half tested I mentioned - MWO of course was launched and tested through steam (with the same launch options as Elite) but the VPC Tester software was installed to my machine with Wine and tested without the aid of steam compatibility programming. If that tells you anything useful.

Plagman pushed a commit to ValveSoftware/wine that referenced this issue Jun 6, 2024
Some games support a maximum of 32, 50 or 64 buttons specifically, thus
we're seeing HOTAS configurations out there which are adjusted to show
exactly that amount of buttons.

Let's add it as a heuristic for Virpil game controllers.

Link: ValveSoftware/Proton#6839 (comment)
@kakra
Copy link
Contributor

kakra commented Jun 6, 2024

@ArsenCross The changes have been merged to bleeding edge Proton, so you can try it out in a few hours by switching your Proton beta choice to bleeding edge.

Plagman pushed a commit to ValveSoftware/wine that referenced this issue Jun 20, 2024
Some games support a maximum of 32, 50 or 64 buttons specifically, thus
we're seeing HOTAS configurations out there which are adjusted to show
exactly that amount of buttons.

Let's add it as a heuristic for Virpil game controllers.

Link: ValveSoftware/Proton#6839 (comment)
@LucyDemooon
Copy link

3344:40d4 VPC Constellation ALPHA Prime [R]

@kakra
Copy link
Contributor

kakra commented Jun 22, 2024

3344:40d4 VPC Constellation ALPHA Prime [R]

How many buttons does it have according to evtest?

@LucyDemooon
Copy link

LucyDemooon commented Jun 26, 2024

32 buttons

> Event type 1 (EV_KEY)
>     Event code 288 (BTN_TRIGGER)
>     Event code 289 (BTN_THUMB)
>     Event code 290 (BTN_THUMB2)
>     Event code 291 (BTN_TOP)
>     Event code 292 (BTN_TOP2)
>     Event code 293 (BTN_PINKIE)
>     Event code 294 (BTN_BASE)
>     Event code 295 (BTN_BASE2)
>     Event code 296 (BTN_BASE3)
>     Event code 297 (BTN_BASE4)
>     Event code 298 (BTN_BASE5)
>     Event code 299 (BTN_BASE6)
>     Event code 300 (?)
>     Event code 301 (?)
>     Event code 302 (?)
>     Event code 303 (BTN_DEAD)
>     Event code 704 (BTN_TRIGGER_HAPPY1)
>     Event code 705 (BTN_TRIGGER_HAPPY2)
>     Event code 706 (BTN_TRIGGER_HAPPY3)
>     Event code 707 (BTN_TRIGGER_HAPPY4)
>     Event code 708 (BTN_TRIGGER_HAPPY5)
>     Event code 709 (BTN_TRIGGER_HAPPY6)
>     Event code 710 (BTN_TRIGGER_HAPPY7)
>     Event code 711 (BTN_TRIGGER_HAPPY8)
>     Event code 712 (BTN_TRIGGER_HAPPY9)
>     Event code 713 (BTN_TRIGGER_HAPPY10)
>     Event code 714 (BTN_TRIGGER_HAPPY11)
>     Event code 715 (BTN_TRIGGER_HAPPY12)
>     Event code 716 (BTN_TRIGGER_HAPPY13)
>     Event code 717 (BTN_TRIGGER_HAPPY14)
>     Event code 718 (BTN_TRIGGER_HAPPY15)
>     Event code 719 (BTN_TRIGGER_HAPPY16)

@kakra
Copy link
Contributor

kakra commented Jun 27, 2024

32 buttons

Then it should be automatically be detected by ValveSoftware/wine@991ad98.

@RavenX8
Copy link

RavenX8 commented Jul 19, 2024

32 buttons

Then it should be automatically be detected by ValveSoftware/wine@991ad98.

When flashing a Virpil device with new firmware, it by default changes the PID to a random value. For example my right CM2 stick is VID:3344 and PID:4138. It wouldn't be caught by the patch because I have it configured as 60 buttons.

@kakra
Copy link
Contributor

kakra commented Jul 19, 2024

When flashing a Virpil device with new firmware, it by default changes the PID to a random value. For example my right CM2 stick is VID:3344 and PID:4138. It wouldn't be caught by the patch because I have it configured as 60 buttons.

That's correct. I wonder if we can hint something via a udev tag @rbernon?

OTOH, @RavenX8 can't you just configure 128 buttons without assigning anything above 60? Or 64 buttons at least...

@RavenX8
Copy link

RavenX8 commented Jul 19, 2024

@kakra From what I can tell, to set it to 128 buttons, you would actually have to assign all 128 logical buttons to a physical button on the stick before the flashing process would actually report them.

Honestly setting up just an extra 30 buttons was a pita since you have to set them manually, I can't imagine doing 96 extra after updating the FW. (the firmware update tool does have the ability to export your button config but I have had trouble using it in the past so I usually just reconfigure my buttons every time I update the FW)

@kakra
Copy link
Contributor

kakra commented Jul 19, 2024

So this is different from VKB where I set the amount of buttons reported by HID, and then can assign physical buttons to the slots or leave them empty? VKB would report 128 buttons, but would I would only assign part of it.

@ArsenCross
Copy link

@ArsenCross The changes have been merged to bleeding edge Proton, so you can try it out in a few hours by switching your Proton beta choice to bleeding edge.

Sorry I'm so late chiming in. Was awhile before I could touch games again. I'm running the game in Proton Experimental and my Constellation L & R sticks are both detected in the game, bindable and flyable. This was tested with a fresh installation of Elite to ensure the file tampering was reversed.

Thank you for the fix.

I do still have 03EB2055 failing to detect by Elite (The other side of the compound device being 03EB2065) which is one of the two compound devices for the CM2 throttle unit in the compound device configuration. I think this ID being included should take care of the throttle in compound device configuration.

I've had some other issues with bindings being lost by Elite after several restarts of the game but I'm not sure if it was a device disconnect or a problem with the game itself retaining the files. I've done no actual analysis as to why this happened yet but it did result in my initial rebinding process being wiped. I'll chime in if I have any worthwhile input on it.

@kakra
Copy link
Contributor

kakra commented Jul 23, 2024

I've had some other issues with bindings being lost by Elite after several restarts of the game but I'm not sure if it was a device disconnect or a problem with the game itself retaining the files. I've done no actual analysis as to why this happened yet but it did result in my initial rebinding process being wiped. I'll chime in if I have any worthwhile input on it.

Never ever touch the bindings in game if not all devices that are part of the custom bindings are connected. Otherwise it will wipe the missing devices away. You can copy the custom.4.0.binds to a different name (e.g., mysettings.4.0.binds), then open it in the text editor and replace the custom name in the xml element with your file name (that is, mysettings in this example). It will then appear as a fixed item in the drop down of the game settings.

I do still have 03EB2055 failing to detect by Elite (The other side of the compound device being 03EB2065)

Okay, I can suggest another change. Can you lsusb the device so we can give it a name in the code comments? Thank you for confirming that the previous changes do work for you.

@ArsenCross
Copy link

Okay, I can suggest another change. Can you lsusb the device so we can give it a name in the code comments? Thank you for confirming that the previous changes do work for you.

Yes, yes I can:
Bus 005 Device 015: ID 03eb:2055 Atmel Corp. VPC Throttle MT-50 CM2
Bus 005 Device 037: ID 03eb:2065 Atmel Corp. LUFA Test and Measurement Demo Application

Also yeah, I do have several binding files and I copy from backup as needed. I even have a no-stick binding for what I consider to be "standardized" controls for KB/M bringing it more in line with what you'd expect if you came form a background of growing up on space games, shooters and the like.

Part of my last response was the result of testing performed with the bindings profiles and matching the entries on a freshly populated "BindingLoadingErrors.log" which let me confirm in writing that Elite wasn't able to detect that device.

@kakra
Copy link
Contributor

kakra commented Jul 23, 2024

When flashing a Virpil device with new firmware, it by default changes the PID to a random value

Then the easiest solution would be to set a well-known PID if that is possible.

Plagman pushed a commit to ValveSoftware/wine that referenced this issue Aug 21, 2024
Some games support a maximum of 32, 50 or 64 buttons specifically, thus
we're seeing HOTAS configurations out there which are adjusted to show
exactly that amount of buttons.

Let's add it as a heuristic for Virpil game controllers.

Link: ValveSoftware/Proton#6839 (comment)
@ChaosRifle
Copy link

ChaosRifle commented Aug 24, 2024

When flashing a Virpil device with new firmware, it by default changes the PID to a random value

Then the easiest solution would be to set a well-known PID if that is possible.

unfortunately, PID is user modifiable on these things, and in many cases, must be modified. VID is user-modifiable too. PID is modified because the factory PID for left/right sticks would be identical (the bases are agnostic, where the brains are), causing issues in some games. Same for identical control panels. VID should not change though, and all virpil devices should report as a generic HID.

in theory, if the VID of virpil is seen (which should always be the same (3344) but technically a user could change this, albeit there is no real reason AFAIK to do so other than 'make funny number'.) at 3344, treating it as a 128 button capable device should work the same for all virpil hardware. They do have a mode to split to 32 button block segments for legacy support, but they should still report as VID 3344.

part of the issue is how customizable they are. its all user defined by rewriting the firmware EEPROM. you can change the name, VID(you shouldnt do this), PID, and even number of axis/buttons by creating virtual ones in firmware, so at say, 10% of a throttle axis it presses a keystroke to do fingerlifts in a DCS jet. or inverse, doing virtual axis from a rotary encoder. different revisions of the boards will have different outputs, and different users will have different preferences. the only constant is they are all generic up-to-128 button, up-to-8 axis devices. They SHOULD be on VID 3344, but technically, a user can change that too, though no good reason exists to do so, AFAIK.

bylaws pushed a commit to bylaws/wine that referenced this issue Sep 6, 2024
This is useful to detect some devices which do not have a well-known
PID set.

Link: ValveSoftware/Proton#6839 (comment)
Link: ValveSoftware/wine#197
bylaws pushed a commit to bylaws/wine that referenced this issue Sep 6, 2024
Some games support a maximum of 32, 50 or 64 buttons specifically, thus
we're seeing HOTAS configurations out there which are adjusted to show
exactly that amount of buttons.

Let's add it as a heuristic for Virpil game controllers.

Link: ValveSoftware/Proton#6839 (comment)
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

9 participants