LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Games (https://www.linuxquestions.org/questions/linux-games-33/)
-   -   HowTo: Getting Steam, WINE, Game Controllers Working Together (https://www.linuxquestions.org/questions/linux-games-33/howto-getting-steam-wine-game-controllers-working-together-4175618012/)

dugan 11-20-2017 02:03 PM

HowTo: Getting Steam, WINE, Game Controllers Working Together
 
HowTo: Getting Steam, WINE, Game Controllers Working Together

Part 1: Native Games

Most Linux-native game use SDL2, which has hardcoded support for most gamepads. With a kernel gamepad driver (as in, without userspace drivers such as xboxdrv or ds4drv), most gamepads should work out of the box.

If yours does not, you can add its mapping to SDL2 by setting the SDL_GAMECONTROLLERCONFIG environment variable. To generate the value that makes your gamepad work, you can use the following program:
Refer to the following for background:Part 2: Steam Games in WINE

Overview

There are currently two protocols that games in Windows can use for gamepad support. If the game expects an Xbox 360 pad, it's using XInput. If it expects you to bind gamepad controls to game actions before playing, it's using DirectInput. In the following video, you can hear Icculus explaining the difference between the two:Controller support is an issue in WINE because as of this writing (WINE 2.21), WINE does not support XInput. Rather, it sees all connected controllers as DirectInput controllers. Hence, we'll use a program called x360ce, which is normally used on Windows to get DirectInput controllers working with XInput games.

There are many guides, both written and video, to using x360ce, and most of the ones aimed at Windows gamers apply to WINE gamers. One particularly good one for WINE users is here:I'm aware that many of these previous guides recommend using xboxdrv. That is now outdated information. Do not use xboxdrv unless you're actually having issues without it. I've found that it certainly isn't needed for either an Xbox One S controller or a Wii U Pro Controller.

Another issue is that WINE accepts input from both of the interfaces that Linux creates per gamepad: the evdev interface (/dev/input/event) and the joydev interface (/dev/input/js). We'll deal with that by disabling the joydev interface.

For the following steps, you need a 64-bit multilib system and a WOW64-enabled WINE build. In other words, the same wine binary needs to be able to run both 64-bit and 32-bit Windows applications.

Setting Up XInput Emulation

With the gamepad plugged in, and when ~/.local/share/wineprefixes/x36ce does not exist:

Code:

export WINEPREFIX=~/.local/share/wineprefixes/x360ce
WINEARCH=win32 winecfg
winetricks -q dotnet45
cd $WINEPREFIX/drive_c
mkdir x360ce
cd x360ce
unzip ~/Downloads/x360ce.zip
wine control
wine x360ce
export -n WINEPREFIX

In "wine control", disable the "(js)" gamepad, and leave the "(event)" gamepad active. The "js" interface is deprecated, and the "event" interface is its replacement. If you keep both enabled, WINE will see both as a separate joystick. This does cause problems.

In x360ce, you set your gamepad's button mappings. For the sticks, the axes increase when going up and right. When you're ready, save. The output should be the following file:
  • x360ce.ini
It probably also output the following DLL file:
  • xinput1_3.dll
This is functionally identical to the xinput.dll you can download as an x360ce resource.

Save the x360ce.ini file.

Testing XInput Emulation

Download XInputTest and unzip it:

Code:

cd ~/.wine/drive_c
unzip ~/Downloads/x360ce\ vibmod\ 3.1.4.1.zip

Fire up winecfg. Go to the "Applications" tab and add a profile for XInputTest.exe, which is where you unzipped it to. For that profile, add an override for xinput1_3.dll to have the native version loaded before the builtin version.

Go into "wine control" and disable the "(js)" gamepad.

Now you're ready to test your gamepad:

Code:

cd x360ce\ vibmod\ 3.1.4.1
WINEDEBUG=loaddll wine XInputTest

XInputTest should now be responding when you test with your gamepad!

In your terminal, you should see confirmation that your XInput DLL override is being loaded:

Code:

trace:loaddll:load_native_dll Loaded L”C:\\x360ce vibmod 3.1.4.1\\xinput1_3.dll” at 0x2cd0000: native
Installing Steam

Create a new 64-Bit WINE bottle for Steam.

Code:

export WINEPREFIX=~/.local/share/wineprefixes/steam
winecfg
wine control

In "wine control", disable the (js) gamepad.

Then install Steam:

Code:

winetricks -q steam
Steam will have created two launchers:
  • ~/Desktop/Steam.desktop
  • ~/.local/share/applications/wine/Programs/Steam/Steam.desktop
Each will look like the following:

Code:

[Desktop Entry]
Name=Steam
Exec=env WINEPREFIX="/home/dugan/.local/share/wineprefixes/steam" /usr/bin/wine C:\\\\windows\\\\command\\\\start.exe /Unix /home/dugan/.local/share/wineprefixes/steam/dosdevices/c:/users/Public/Desktop/Steam.lnk
Type=Application
StartupNotify=true
Path=/home/dugan/.local/share/wineprefixes/steam/dosdevices/c:/Program Files/Steam
Icon=BAC4_steam.0
StartupWMClass=steam.exe

Add WINEDEBUG flags to the Exec lines so that they disable logging:

Code:

Exec=env WINEDEBUG="-all" WINEPREFIX="/home/dugan/.local/share/wineprefixes/steam" /usr/bin/wine C:\\\\windows\\\\command\\\\start.exe /Unix /home/dugan/.local/share/wineprefixes/steam/dosdevices/c:/users/Public/Desktop/Steam.lnk
Disabling logging is one of the most valuable optimizations you can add. In many games, it will lead to a significant increase in speed. You're not going to see this logging anyway if you're running Steam from the shortcut. If you need logging, run WINE from a terminal.

You probably also want change the name to something like:

Code:

Name=Steam (32-Bit WINE)
Feel free to add a comment below that line:

Code:

Comment=Steam for Windows
Because we allowed winemenubuilder to run, you might discover file associations that might need to be set back:

Code:

> xdg-mime query default application/pdf
wine-extension-pdf.desktop
> xdg-mime default xpdf.desktop application/pdf

Enjoy!

From this point on you will launch Steam from the shortcut, use Steam to install your games, and, when you're ready to play, use Steam to launch them.

Use the terminal to test and set up overrides on a game-by-game basis. Set WINEPREFIX in the environment, fire up winecfg, and browse for the game's .exe. Then set whatever overrides are needed for that game.

If a game needs x360ce overrides, you'll start by copying x360ce's xinput1_3.dll to the same directory as the game's .exe, along with your x360ce.ini. Some games might need that DLL renamed (e.g. to xinput1_4.dll); use WINEDEBUG=loaddll to find out.

Example: Wolfenstein: The New Order

Wolfenstein: The New Order is a 64-Bit game. So you download the 64-bit xinput DLL for x360ce:Then you rename it to xinput1_3.dll, and put both it, and your x360ce.ini file, in the same directory as the game's executable. Then you set WINEPREFIX to Steam, fire up winecfg, and set an override so that it prefers the native xinput1_3.dll when it's running the game's executable.

Example: Deathsmiles

Deathsmiles recognizes both XInput and DirectInput. If you allow it to receive both XInput and DirectInput game controller input, (and/or if you have both the js and event joystick interfaces active), then the game will think it's receiving input from two game controllers, and you'll mysteriously find yourself controlling two characters with one controller. (I've seen Steam forum posts indicating that this can also happen when you run the game on Windows).

The solution is to use the DirectInput Blocker from here:
Set DeathSmiles up with x360ce as usual (put x360ce.ini and the 32-bit xinput1_3.dll in the game's directory, set the DLL override). Then add the DirectInput Blocker (dinput8.dll) to the game's directory, and add a native override for that too.

(This also applies to DoDonPachi Resurrection, except that DoDonPachi Resurrection messes up less dramatically if you miss a step).

Part 3: Steam Controller

Setting up a Steam Controller is similar to setting up any other gamepad. Start by replacing the xinput DLL from x360ce with one from dumbxinputemu. This is like x360ce, except that it doesn't need to be configured. Instead, it has hardcoded mappings that are correct for the Steam Controller's Xbox 360 emulation.

Then, you have three options for how to set up your Steam Controller mappings.

You can can use sc-controller.

The next two options use Steam for Linux to set the mappings.

The first option is to use Steam for Linux's Big Picture Mode to set up your Steam Controller for the game, and then to make sure that Steam is running at the same time that the game is. In most cases, that means you'll have both Steam for Linux and Steam for Windows running at the same time.

You can set up Steam for Linux's desktop configuration to be correct for the game, as demonstrated in the following video:The second option write a shell script to run the game, add it to Steam for Linux as a non-Steam game, and set up your Steam Controller for that game.

dugan 11-22-2017 12:02 AM

Just one follow up:

If you're adding WINE game to Linux Steam as a non-Steam game, name it the Steam app id. For example, Wolfenstein: The New Order is 201810, so name the shortcut 201810. Then you have access to the community Steam Controller configurations for that game!

Then you download and set a Steam Grid banner for the shortcut, so you can tell which game it is.

dugan 03-06-2018 10:34 PM

I've noticed that as of WINE 3.3, almost none of the above is needed. All you really need to do is set your SDL_GAMECONTROLLERCONFIG string correctly (as you would for SDL2 games). I set it for my DualShock 4, and both XInputTest and Ducktales: Remastered started working correctly with my DualShock 4, with no further configuration needed.

Subnautica 05-19-2018 04:33 PM

Thank you for the explanations.

I'm really confused though.
I installed Steam through playonlinux (4.2.11) which worked fine. Than I installed Cuphead through Steam which also worked and the game runs perfectly.
I'm using Wine 3.8 on KDE Neon (Ubuntu LTS).

My controller is a 8Bitdo SFC 30, connected via Bluetooth. In the Wine control panel > Game controllers > Test joystick I can verify that it's working.
BUT to get it working in Steam, I have to configure the controller in Steam and thats where I'm stuck.
When I go to Steam > Settings > Controller > General Controller Settings Wine says "DWrite.dll missing fatal error" and Steam crashes.
It's the same when I try to launch Big Picture mode.

I'm relatively new to Linux and the whole Wine, playonlinux, winetricks etc. is quite complex to be honest. I feel really close though.
Thanks in advance

dugan 05-19-2018 06:41 PM

Are you talking about that Steam Controller/Big Picture thing?

You launch Linux Steam in Big Picture Mode and set up your controller via Linux Steam. Then you launch either your Windows game or Windows Steam. That means that Linux Steam will handle your controller setup for your Windows game. You'll either have Linux Steam running in Big Picture Mode in the background, or you'll have Linux Steam's overlay over your Windows game.

Disable the overlay in Windows Steam and don't launch it in Big Picture Mode. In many cases, yes, this does mean you'll have both Linux Steam and Windows Steam running at the same time.

Subnautica 05-20-2018 05:47 AM

@dugan THANK YOU SO MUCH IT WORKED!! I don't know where I and others would be without Linux wizards like you.

To sum all steps I have done for others and myself:

If you want to
  • run Cuphead on KDE Neon 5.12 (Ubuntu LTS 16.04)
  • with an AMD Radeon Polaris GPU (In my case the RX570)
  • and use a Generic Bluetooth Gamepad (In my case the 8Bitdo SFC 30)
do the following:
  1. Install Playonlinux out of the Software center. It currently has version 4.2.10 in there which should work fine. (I used 4.2.11 in the end)
  2. Start Playonlinux and click on "+ Install a program" on the left section. Click on the "Accessories" field on top and search for Steam. Click Steam and hit "Install" in the bottom right. Go through the installation and follow the hints of Playonlinux. This Steam install will be refered to as "Windows Steam" later.
    It will throw an error the first startup but it should work fine nonetheless. You can basically follow this tutorial
  3. Update the Wine version used for the Steam install in Playonlinux:
    In Playonlinux highlight the Steam entry and click on "Configure" on the left > "General" Tab > "Wine version". Click the "+" Button next to it and in the "Wine versions (x86)" tab add Wine 3.8 to the right section. Follow through the installation process and afterwards you should be able to pick Wine 3.8 in the dropdown in from the Steam configure section.
  4. Plug in your USB Bluetooth Dongle (or activate a built in one) and connect your Bluetooth gamepad to it.
  5. Verify that your gamepad works:
    In the Steam entry configuration go to the "Wine" tab > "Control Panel" > "Game Controllers" > "Joysicks" Tab. You should see your connected gamepad here in two entries "js", and "event". Disable the "js" entry.
    Click on the "Test Joystick" Tab and see if your gamepad button presses are showing up.
  6. Get Cuphead running:
    Start Steam out of Playonlinux and log in to your account. Then go to your library and click install in your Cuphead entry. (Buy it here if you don't already have it) After the installation you sould be able to run Cuphead normally out of Steam and it should run fine (with keyboard inputs).
    Close Cuphead, Steam and Playonlinx.
  7. Install the native Steam Linux client out of the Valve .deb package. Yes we will be running two different Steam instances simulateously, one for Cuphead and one to handle the gamepad inputs.
    To install the native Steam client follow the official tutorial by Valve. (It refers to Ubuntu 12.04 but it works anyways)
  8. Verify that native Steam works:
    Start it and see if it works.
    If you run into the known issue that Steam appears in the taskbar but then disappears (crashes without error) like I did follow the recommended solution in this Tutorial to fix this and leave a thumbs up for the author.
    You can check if you have the same problem by running /usr/bin/steam in the terminal and see if you get missing radeon driver errors.
  9. When you have your native Steam running and open go to Steam > "Settings" > "General Controller Settings". Check "Generic Gamepad Configuration support" and pick your connected gamepad in the list. You can now map you gamepad buttons there. Close everything.

So far the installation and configuarion part.
To start Cuphead with gamepad support do the following:
  1. Connect your gamepad
  2. Start your native Linux Steam client and switch to Big Picture mode. (Your gamepad should work here). You can also start Big Picture mode directly.
  3. Minimize Big Picture mode eg. by hitting alt+F1
  4. On the same (virtual) desktop start your Windows Steam either through Playonlinux or by using the direct shortcut
  5. In Windows Steam start Cuphead like before
  6. In Cuphead go to "Settings" > "Controls" and map your gamepad buttons to the keyboard bindings
  7. Have fun playing Cuphead with your gamepad on Linux!
  8. Buy the (awesome) soundtrack on vinyl [optional]

dugan 07-13-2018 10:03 PM

I just did Steam Controller test on slackware-current (SDL 2.0.8, kernel 4.14.55, wine staging 3.11). I left SDL_GAMECONTROLLERCONFIG unset, installed Ducktales: Remastered (which uses XInput on Windows) in Windows Steam, added it to Linux Steam as a non-Steam game, set its Steam Controller configuration to the "Gamepad" template in Big Picture mode, and launched it. It then correctly treated the Steam Controller as an Xbox 360 controller. No further setup needed.

dugan 07-14-2018 01:30 AM

Just tried Valkyria Chronicles. It just needed the DirectInput Blocker (link and information in the top post) to work properly with my Xbox One S controller.


All times are GMT -5. The time now is 09:47 PM.