ValveSoftware / ValveSoftware/wine
Dead zone handling
Nobody has claimed this yet.
- Dominant language
- C
- Stars
- 2k
- Forks
- 488
- PR merge metrics
- No merged PRs in 30d
Description
Wine's current implementation of xinput uses SDL on Linux. This shows the following problem:
Microsoft clearly points out that xinput device have no dead zones on the API level, dead zones must be handled by the game itself: https://docs.microsoft.com/en-us/windows/win32/xinput/getting-started-with-xinput
But on Linux, SDL handles dead zones for evdev devices, and devices from joydev have dead zones at the kernel level. The current work-around is to set flatness to zero for such devices in the kernel. So Proton currently has no way to control this.
This has a big impact on any gamepad-controlled game played in Proton and makes a very bad experience when precision is needed such as in fast first person games, simulations etc. Evidence shows that the situation is greatly improved by setting the flatness to 0 at the Linux layer so SDL or joydev will no longer handle dead zones, in consequence Proton will see no dead zones from the lower layers and can pass unfiltered input data through the xinput API.
Since reading from evdev exposes no dead zones, the best approach would probably be to patch SDL to have an API call if one wants to receive input data without any dead zones applied. Proton could then just switch dead zones from SDL off and receive unfiltered inputs. Wine can already apply its own dead zone handler if games set that property, so that's probably all that's needed.
An intermediate solution would be that Proton makes that switchable on a game-per-game basis by setting flatness for devices to zero at launch time, and restoring the original value when the game quits. Maybe it's fine to just to that for any game and instead set the default Wine dead zone to 10%.
We currently implemented that in xpadneo by reducing the fuzz parameter by a factor of 8 for Xbox controllers which already makes a perceivable smoother and more direct input experience. We also shrunk the dead zone by 25% which improves the situation a little for games requiring precise control. We also added a driver option for high-precision mode which turns dead zones off, and that has a huge impact on game experience. xow is probably following soon at least partially with a similar solution. But this can only be a work-around as it messes with joydev (games and applications may not expect to have a joydev without dead zones). The xpad driver walks the middle ground by using 128 as the dead zone but this is no solution on either side because it makes joydev jittery without eliminating the dead zone for xinput games.
@aeikum I wonder what the best solution would be?
See also:
https://github.com/atar-axis/xpadneo/pull/232
https://github.com/medusalix/xow/issues/105
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with Wine's current xinput implementation and trace how SDL, evdev, and joydev dead zones reach Proton. Review the linked XInput documentation and the related xpadneo and xow discussions; done requires an agreed approach for preserving unfiltered input without breaking existing device behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- c, linux
- Domain
- operating-systems
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100