Elite Dangerous appears to iterate input devices via DInput and will only defer to XInput if there is a HID device with a matching VID and PID.
The current behaviour of the SDLBUS is to masquerade any controller as an XBOX controller. This causes Elite Dangerous to treat any other type of contoller as a Joystick.
This patch allows this masquerading behaviour to be switched off via a REG_BINARY registry entry: HKCU\Software\Wine\XInput\MasqueradeXBOXController
0 - Turns it off (so it uses the real VID and PID 1 - Turns it on (so it uses the XBOX controller VID and PID)
The default behaviour is to leave it as is (i.e on).
Signed-off-by: Brendan McGrath brendan@redmandi.com --- dlls/winebus.sys/Makefile.in | 2 +- dlls/winebus.sys/bus_sdl.c | 19 ++++++++++++++++++- 2 files changed, 19 insertions(+), 2 deletions(-)
diff --git a/dlls/winebus.sys/Makefile.in b/dlls/winebus.sys/Makefile.in index d3421b49f1a..76cd9e28c39 100644 --- a/dlls/winebus.sys/Makefile.in +++ b/dlls/winebus.sys/Makefile.in @@ -1,5 +1,5 @@ MODULE = winebus.sys -IMPORTS = ntoskrnl setupapi +IMPORTS = ntoskrnl setupapi advapi32 EXTRALIBS = $(IOKIT_LIBS) $(UDEV_LIBS) EXTRAINCL = $(UDEV_CFLAGS) $(SDL2_CFLAGS) EXTRADLLFLAGS = -Wb,--subsystem,native diff --git a/dlls/winebus.sys/bus_sdl.c b/dlls/winebus.sys/bus_sdl.c index 6b2b28e8c90..22b63bad09b 100644 --- a/dlls/winebus.sys/bus_sdl.c +++ b/dlls/winebus.sys/bus_sdl.c @@ -39,6 +39,7 @@ #include "winbase.h" #include "winnls.h" #include "winternl.h" +#include "winreg.h" #include "ddk/wdm.h" #include "ddk/hidtypes.h" #include "wine/library.h" @@ -795,6 +796,22 @@ static void try_remove_device(SDL_JoystickID index) bus_remove_hid_device(device); }
+static BOOL masquerade_xbox_controller(void) +{ + HKEY hkey; + BOOL ret = TRUE; + + /* @@ Wine registry key: HKCU\Software\Wine\XInput */ + if (RegOpenKeyA(HKEY_CURRENT_USER, "Software\Wine\XInput", &hkey) == ERROR_SUCCESS) + { + DWORD data_size = sizeof(ret); + RegQueryValueExA(hkey, "MasqueradeXBOXController", NULL, NULL, (LPBYTE) &ret, &data_size); + } + + TRACE("MasqueradeXBOXController = %d\n", ret); + return ret; +} + static void try_add_device(SDL_JoystickID index) { DWORD vid = 0, pid = 0, version = 0; @@ -818,7 +835,7 @@ static void try_add_device(SDL_JoystickID index) controller = pSDL_GameControllerOpen(index);
id = pSDL_JoystickInstanceID(joystick); - if (controller) + if (controller && masquerade_xbox_controller()) { vid = VID_MICROSOFT; pid = PID_XBOX_CONTROLLERS[3];