[PATCH 2/2] hidclass.sys: Create Driver reg key for HID devices.

Zebediah Figura (she/her) zfigura at codeweavers.com
Tue Apr 13 10:54:12 CDT 2021


On 4/13/21 10:31 AM, Arkadiusz Hiler wrote:
> SDL doesn't use HID devices directly if they don't have SPDRP_DRIVER
> registry property set. It uses another input method as a fallback instead.
> 
> Since SDL_Joystick GUIDs are dependant on the input method this can mess
> with mappings and controller type detection.
> 
> The change fixes Hades wrongly displaying Xbox prompts with Sony controllers
> over winebus.sys/bus_udev.c.

It seems that Windows actually installs a null function driver (i.e. one 
with the SPSVCINST_ASSOCSERVICE flag set) for HID devices, so setupapi 
will create the key automatically in this case.

I'm not sure how that interacts with drivers that also want to layer 
onto the HID device; probably it means our SetupDiSelectBestCompatDrv() 
implementation needs to be less stubby.

> 
> Signed-off-by: Arkadiusz Hiler <ahiler at codeweavers.com>
> ---
>   dlls/hidclass.sys/Makefile.in | 2 +-
>   dlls/hidclass.sys/device.c    | 9 +++++++++
>   2 files changed, 10 insertions(+), 1 deletion(-)
> 
> diff --git a/dlls/hidclass.sys/Makefile.in b/dlls/hidclass.sys/Makefile.in
> index be4af747853..ffc49e65257 100644
> --- a/dlls/hidclass.sys/Makefile.in
> +++ b/dlls/hidclass.sys/Makefile.in
> @@ -1,7 +1,7 @@
>   MODULE    = hidclass.sys
>   IMPORTLIB = hidclass
>   IMPORTS   = hal ntoskrnl
> -DELAYIMPORTS = setupapi hid
> +DELAYIMPORTS = setupapi hid kernelbase
>   
>   EXTRADLLFLAGS = -mno-cygwin
>   
> diff --git a/dlls/hidclass.sys/device.c b/dlls/hidclass.sys/device.c
> index fc1dfd07db1..4554181e8bd 100644
> --- a/dlls/hidclass.sys/device.c
> +++ b/dlls/hidclass.sys/device.c
> @@ -80,6 +80,7 @@ NTSTATUS HID_LinkDevice(DEVICE_OBJECT *device)
>       HDEVINFO devinfo;
>       GUID hidGuid;
>       BASE_DEVICE_EXTENSION *ext;
> +    HKEY hkey;
>   
>       HidD_GetHidGuid(&hidGuid);
>       ext = device->DeviceExtension;
> @@ -104,6 +105,14 @@ NTSTATUS HID_LinkDevice(DEVICE_OBJECT *device)
>               FIXME( "failed to register device info %x\n", GetLastError());
>               goto error;
>           }
> +
> +        hkey = SetupDiCreateDevRegKeyW(devinfo, &Data, DICS_FLAG_GLOBAL, 0, DIREG_DRV, NULL, NULL);
> +        if (hkey == INVALID_HANDLE_VALUE)
> +        {
> +            FIXME( "failed to create driver reg key %x\n", GetLastError() );
> +            goto error;
> +        }
> +        RegCloseKey(hkey);
>       }
>       else if (GetLastError() != ERROR_DEVINST_ALREADY_EXISTS)
>       {
> 



More information about the wine-devel mailing list