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];
Signed-off-by: Aric Stewart aric@codeweavers.com
On 11/16/18 11:08 PM, Brendan McGrath wrote:
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];
On Sat, Nov 17, 2018 at 04:08:10PM +1100, Brendan McGrath wrote:
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)
This seems kind of inelegant. Is there some way to programmatically distinguish the device you have from a more typical gamepad? Maybe some SDL function that classifies the device, or the presence of non-rumble FFB?
If not, another approach would be to have a VID/PID override in the registry, which defaults to the Xbox values, but users can unset to allow the true VID/PID through.
Andrew
On 11/19/2018 10:57 AM, Andrew Eikum wrote:
On Sat, Nov 17, 2018 at 04:08:10PM +1100, Brendan McGrath wrote:
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)
This seems kind of inelegant. Is there some way to programmatically distinguish the device you have from a more typical gamepad? Maybe some SDL function that classifies the device, or the presence of non-rumble FFB?
If not, another approach would be to have a VID/PID override in the registry, which defaults to the Xbox values, but users can unset to allow the true VID/PID through.
Andrew
While we're at it, if we really do need a registry hack, a better place would probably be the existing WineBus key.
On 11/19/2018 11:06 AM, Zebediah Figura wrote:
On 11/19/2018 10:57 AM, Andrew Eikum wrote:
On Sat, Nov 17, 2018 at 04:08:10PM +1100, Brendan McGrath wrote:
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)
This seems kind of inelegant. Is there some way to programmatically distinguish the device you have from a more typical gamepad? Maybe some SDL function that classifies the device, or the presence of non-rumble FFB?
If not, another approach would be to have a VID/PID override in the registry, which defaults to the Xbox values, but users can unset to allow the true VID/PID through.
Andrew
While we're at it, if we really do need a registry hack, a better place would probably be the existing WineBus key.
Actually, now that I look at the code, doesn't the "Map Controllers" value already do exactly this?
I think the intent of "Map Controllers" is to define if the SDL controller functionality will be used or not - but this currently comes with the XBOX masquerade.
My intent is to allow use of the SDL controller functionality without the masquerade (i.e. call SDL_GameControllerOpen and get the SDL_CONTROLLER events).
On 20/11/18 11:35 am, Zebediah Figura wrote:
On 11/19/2018 11:06 AM, Zebediah Figura wrote:
On 11/19/2018 10:57 AM, Andrew Eikum wrote:
On Sat, Nov 17, 2018 at 04:08:10PM +1100, Brendan McGrath wrote:
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)
This seems kind of inelegant. Is there some way to programmatically distinguish the device you have from a more typical gamepad? Maybe some SDL function that classifies the device, or the presence of non-rumble FFB?
If not, another approach would be to have a VID/PID override in the registry, which defaults to the Xbox values, but users can unset to allow the true VID/PID through.
Andrew
While we're at it, if we really do need a registry hack, a better place would probably be the existing WineBus key.
Actually, now that I look at the code, doesn't the "Map Controllers" value already do exactly this?