http://bugs.winehq.org/show_bug.cgi?id=35815
Bug ID: 35815 Summary: Allow remapping of joystick buttons Product: Wine Version: 1.7.14 Hardware: x86 OS: Linux Status: UNCONFIRMED Severity: enhancement Priority: P2 Component: directx-dinput Assignee: wine-bugs@winehq.org Reporter: achurch+wine@achurch.org
Some Windows games only accept a limited number of joystick button inputs, presumably based on the set of joystick devices against which the game was tested. If the native driver for a device returns different button numbers than the Windows driver, this can prevent some common controller devices from being used with such games. For example, the PlayStation 3 controller reports its face buttons as button numbers 12-15, but apparently the commonly used Windows driver "MotioninJoy" remaps these to lower button numbers; due to that, some games (such as Astebreed: http://edelweiss.skr.jp/works/astebreed/) only accept up to 12 button inputs, preventing PS3 controllers from working properly.
The attached patch (against Wine 1.7.14) adds a "ButtonMap" configuration value to the DirectInput registry key, allowing the first 16 joystick button inputs reported by Wine to be remapped to arbitrary native joystick buttons. The format of the value is a comma-separated list of numbers, with the first number giving the (zero-based) physical button index for DirectInput button 0, the second number giving the physical button index for DirectInput button 1, and so on for up to 16 buttons.
http://bugs.winehq.org/show_bug.cgi?id=35815
--- Comment #1 from Bruno Jesus 00cpxxx@gmail.com --- Missing attachment.
http://bugs.winehq.org/show_bug.cgi?id=35815
--- Comment #2 from Andrew Church achurch+wine@achurch.org --- Created attachment 47815 --> http://bugs.winehq.org/attachment.cgi?id=47815 joystick-button-map.diff
Trying again.
https://bugs.winehq.org/show_bug.cgi?id=35815
--- Comment #3 from Austin English austinenglish@gmail.com --- This is your friendly reminder that there has been no bug activity for over a year. Is this still an issue in current (1.7.51 or newer) wine?
https://bugs.winehq.org/show_bug.cgi?id=35815
--- Comment #4 from Andrew Church achurch+wine@achurch.org --- Yes, this is still unresolved in current git.
https://bugs.winehq.org/show_bug.cgi?id=35815
winetest@luukku.com changed:
What |Removed |Added ---------------------------------------------------------------------------- CC| |winetest@luukku.com
--- Comment #5 from winetest@luukku.com --- (In reply to Andrew Church from comment #4)
Yes, this is still unresolved in current git.
patching file dlls/dinput/joystick.c Hunk #1 succeeded at 947 (offset 46 lines). patching file dlls/dinput/joystick_linux.c Hunk #1 succeeded at 762 (offset 115 lines). patching file dlls/dinput/joystick_linuxinput.c Hunk #1 succeeded at 825 (offset 18 lines). patching file dlls/dinput/joystick_osx.c Hunk #1 succeeded at 803 with fuzz 1 (offset 165 lines). patching file dlls/dinput/joystick_private.h
wine 1.9.15
https://bugs.winehq.org/show_bug.cgi?id=35815
Andrew Church achurch+wine@achurch.org changed:
What |Removed |Added ---------------------------------------------------------------------------- Attachment #47815|0 |1 is obsolete| |
--- Comment #6 from Andrew Church achurch+wine@achurch.org --- Created attachment 55194 --> https://bugs.winehq.org/attachment.cgi?id=55194 joystick-button-map.diff
Updated patch for wine-1.9.15
https://bugs.winehq.org/show_bug.cgi?id=35815
--- Comment #7 from winetest@luukku.com --- (In reply to Andrew Church from comment #6)
Created attachment 55194 [details] joystick-button-map.diff
Updated patch for wine-1.9.15
patching file dlls/dinput/joystick.c Hunk #1 succeeded at 961 (offset 14 lines). patching file dlls/dinput/joystick_linux.c Hunk #1 succeeded at 786 (offset 82 lines). patching file dlls/dinput/joystick_linuxinput.c Hunk #1 succeeded at 841 (offset 37 lines). patching file dlls/dinput/joystick_osx.c Hunk #1 succeeded at 803 (offset 42 lines). patching file dlls/dinput/joystick_private.h
against wine 1.9.20-git.
You should send your patch to wine-patches list for review. So it could be at somepoint merged into wine. This bug report should contain patch word so it would be easier to find this.
https://bugs.winehq.org/show_bug.cgi?id=35815
--- Comment #8 from Andrew Church achurch+wine@achurch.org --- As I've mentioned in other bug reports, I unfortunately don't have the time to go through Wine's (IMHO antiquated) patch submission process. You're welcome to submit it yourself if you like.
https://bugs.winehq.org/show_bug.cgi?id=35815
Andrew Church achurch+wine@achurch.org changed:
What |Removed |Added ---------------------------------------------------------------------------- Attachment #55194|0 |1 is obsolete| |
--- Comment #9 from Andrew Church achurch+wine@achurch.org --- Created attachment 55872 --> https://bugs.winehq.org/attachment.cgi?id=55872 joystick-button-map.diff
Updated patch for 1.9.20, just for the record.
https://bugs.winehq.org/show_bug.cgi?id=35815
winetest@luukku.com changed:
What |Removed |Added ---------------------------------------------------------------------------- CC| |00cpxxx@gmail.com
--- Comment #10 from winetest@luukku.com --- (In reply to Andrew Church from comment #8)
As I've mentioned in other bug reports, I unfortunately don't have the time to go through Wine's (IMHO antiquated) patch submission process. You're welcome to submit it yourself if you like.
Bruno are you interested to sending wine-patches? Since you have been involved joystick code so much recently. This bug should contain patch keyword. It doesnt matter much, but it gives better results with search.
https://bugs.winehq.org/show_bug.cgi?id=35815
Bruno Jesus 00cpxxx@gmail.com changed:
What |Removed |Added ---------------------------------------------------------------------------- Keywords| |hardware, patch
https://bugs.winehq.org/show_bug.cgi?id=35815
BieHDC byi5000@gmail.com changed:
What |Removed |Added ---------------------------------------------------------------------------- CC| |byi5000@gmail.com
--- Comment #11 from BieHDC byi5000@gmail.com --- the xbox360 controller is also wrongly detected. the LT and RT are mapped as individual axis, but they should be mapped as one axis which makes driving with the controller in for example GTA4 very difficult.
https://bugs.winehq.org/show_bug.cgi?id=35815
wine-bugs@theblob.org changed:
What |Removed |Added ---------------------------------------------------------------------------- CC| |wine-bugs@theblob.org
--- Comment #12 from wine-bugs@theblob.org --- I needed to remap joystick/gamepad buttons today as I wanted to try using the DualShock 4 with FFXIV on Linux and several buttons were mapped wrongly. (And axes, though those are already remappable using the registry so that wasn't a problem.)
I can confirm that the patch on this bug applies to wine-3.15 (with Gallium Nine patches) with a little bit of fuzz, and works to remap the buttons on a DualShock 4, but I'm a little worried that the registry key appears on sight to be global between all devices. I think, ideally, it should be settable per-device.
[addendum: For those wondering, the correct ButtonMap value for a DualShock 4 using this patch is "3,0,1,2,4,5,6,7,8,9,11,12,10,13,14,15"]
https://bugs.winehq.org/show_bug.cgi?id=35815
Alistair Leslie-Hughes leslie_alistair@hotmail.com changed:
What |Removed |Added ---------------------------------------------------------------------------- CC| |leslie_alistair@hotmail.com
--- Comment #13 from Alistair Leslie-Hughes leslie_alistair@hotmail.com --- Created attachment 63686 --> https://bugs.winehq.org/attachment.cgi?id=63686 Revised patch
Could someone please try this revised patch for remapping of joysticks buttons?
Thanks.
https://bugs.winehq.org/show_bug.cgi?id=35815
Alistair Leslie-Hughes leslie_alistair@hotmail.com changed:
What |Removed |Added ---------------------------------------------------------------------------- Status|UNCONFIRMED |STAGED Staged patchset| |https://github.com/wine-sta | |ging/wine-staging/tree/mast | |er/patches/dinput-remap-joy | |stick Ever confirmed|0 |1
https://bugs.winehq.org/show_bug.cgi?id=35815
--- Comment #14 from Sophira wine-bugs@theblob.org --- Hi Andrew,
I see your patch is in wine-staging - I came across it while applying the workarounds that the FFXIV community have devised for the new launcher failing to correctly render (see bug 47069). (Also, hi, I'm the poster of the Reddit thread!)
How do I use this new patch? Will the previous ButtonMap value that I posted for the DS4 continue to work with this patch, or do I need to change it?
https://bugs.winehq.org/show_bug.cgi?id=35815
--- Comment #15 from Sophira wine-bugs@theblob.org --- Ah, sorry, I thought the new patch was by Andrew. Apologies! That should have been directed to Alistair.
https://bugs.winehq.org/show_bug.cgi?id=35815
--- Comment #16 from Andrew Church achurch+wine@achurch.org --- I haven't tried the new patch, but from a quick comparison, it looks like it should behave the same way, yes -- the new patch just does the processing more cleanly than my code did.
Also, just to address your earlier concern, the key can be made app-specific like most other Wine registry keys (HKCU\Software\Wine\AppDefaults\foo.exe\DirectInput if I recall correctly).
https://bugs.winehq.org/show_bug.cgi?id=35815
Rémi Bernon rbernon@codeweavers.com changed:
What |Removed |Added ---------------------------------------------------------------------------- CC| |rbernon@codeweavers.com Resolution|--- |INVALID Status|STAGED |RESOLVED
--- Comment #17 from Rémi Bernon rbernon@codeweavers.com --- Wine now uses SDL by default for all the joystick and game controller device support.
SDL already has a quite extensive support for axes and button remapping, either through SDL_GAMECONTROLLERCONFIG environment variable or configuration files (there's also a community sourced database here https://github.com/gabomdq/SDL_GameControllerDB).
The old DInput remapping support has been removed, so this doesn't apply anymore and I'm going to mark this bug as invalid.
When SDL support has not been compiled in, Wine either acts as a pass-through to hidraw devices (or iohid on macOS), in which case I don't think it's possible to do any kind of mapping, or indeed still does some remapping from evdev to HID usages.
I opened a new bug to track some eventual change to make this evdev mapping customizable here: https://bugs.winehq.org/show_bug.cgi?id=51908.
https://bugs.winehq.org/show_bug.cgi?id=35815
Rémi Bernon rbernon@codeweavers.com changed:
What |Removed |Added ---------------------------------------------------------------------------- See Also| |https://bugs.winehq.org/sho | |w_bug.cgi?id=51908
https://bugs.winehq.org/show_bug.cgi?id=35815
Andrew Church achurch+wine@achurch.org changed:
What |Removed |Added ---------------------------------------------------------------------------- Attachment #55872|0 |1 is obsolete| |
--- Comment #18 from Andrew Church achurch+wine@achurch.org --- Created attachment 70860 --> https://bugs.winehq.org/attachment.cgi?id=70860 joystick-button-map-f712a98d.diff
Proof-of-concept patch updated for Git f712a98d
https://bugs.winehq.org/show_bug.cgi?id=35815
Andrew Church achurch+wine@achurch.org changed:
What |Removed |Added ---------------------------------------------------------------------------- Resolution|INVALID |--- Status|RESOLVED |REOPENED
--- Comment #19 from Andrew Church achurch+wine@achurch.org ---
When SDL support has not been compiled in, Wine either acts as a pass-through to hidraw devices (or iohid on macOS), in which case I don't think it's possible to do any kind of mapping, or indeed still does some remapping from evdev to HID usages.
I don't mean to be contrarian, but I in fact implemented exactly this sort of remapping against HEAD. See updated patch.
With respect to SDL support, that appears to be XInput only? I didn't see my SDL_GAMECONTROLLERCONFIG setting having any effect on DirectInput behavior (hence why I updated this patch in the first place).
https://bugs.winehq.org/show_bug.cgi?id=35815
--- Comment #20 from Rémi Bernon rbernon@codeweavers.com --- Well sure I didn't say it would not be possible to do some DInput-only remapping, just that it would not be ideal imho as it will only apply to DInput, and applications using another way to access the device will not see any mapping change.
I believe SDL_GAMECONTROLLERCONFIG could work, and its use is not XInput specific anymore. There may be some details to sort out here, as it only works if SDL exposes a "controller" device, but I believe that variable can actually make it do just that (force creation of a mapping from a SDL joystick to a SDL controller).
https://bugs.winehq.org/show_bug.cgi?id=35815
--- Comment #21 from Andrew Church achurch+wine@achurch.org --- Is there an easy way to see exactly where Wine's DInput is getting its joystick input from (on the host side)? I'm not familiar with the structure of the new code, and I didn't see anything obvious in dinput TRACE logs.
https://bugs.winehq.org/show_bug.cgi?id=35815
--- Comment #22 from Rémi Bernon rbernon@codeweavers.com --- It's getting it from winebus.sys now, which is then either getting it from SDL or evdev. You can have more details on the +plugplay debug channel (there should be some device creation messages mentioning where it's from).
https://bugs.winehq.org/show_bug.cgi?id=35815
Andrew Church achurch+wine@achurch.org changed:
What |Removed |Added ---------------------------------------------------------------------------- Status|REOPENED |RESOLVED Resolution|--- |INVALID
--- Comment #23 from Andrew Church achurch+wine@achurch.org --- Okay, I think I see what's going on - the data is coming from SDL, but I didn't get any effect from SDL_GAMECONTROLLERCONFIG because of a typo in the value (oops). I'm now able to affect the button mapping with SDL_GAMECONTROLLER_CONFIG settings; I don't see where the mapping is coming from (e.g., the Start button is reported as button ID 8, rather than 7 as seems to be suggested by https://source.winehq.org/git/wine.git/blob/HEAD:/dlls/winebus.sys/bus_sdl.c...), but since I can work those out by trial and error, this obviates the need for the patch in DInput.
Thanks for the explanation!
https://bugs.winehq.org/show_bug.cgi?id=35815
Gijs Vermeulen gijsvrm@gmail.com changed:
What |Removed |Added ---------------------------------------------------------------------------- Status|RESOLVED |CLOSED
--- Comment #24 from Gijs Vermeulen gijsvrm@gmail.com --- Closing.