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

Arkadiusz Hiler ahiler at codeweavers.com
Tue Apr 13 14:03:03 CDT 2021


On Tue, Apr 13, 2021 at 10:54:12AM -0500, Zebediah Figura (she/her) wrote:
> 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 was just following what we already do for the display drivers
(winex11.drv, winemac.drv).

So we would need to add an .inf with an appropriate AddService directive
and install it instead of just adding the driver property pointing
to an empty driver key?

> 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.

I don't understand this comment. I tried to follow the function's usage
+ see how we end up creating a HID device out of the underlaying one but
the call chains are long and it gets confusing quickly.

Looks like SetupDiSelectBestCompatDrv() is used by
SetupDiCallClassInstaller(DIF_SELECTBESTCOMPATDRV) and that in turn is
used by ntoskrnl.exe with each function when adding a new PNP device.

It seems that whenever a specific driver (one of the implemenations in
winebus.sys) detects a new hardware it creates a device on it's own bus
(e.g. HIDRAW for udev) and then calls IoInvalidateDeviceRelations()

IoInvalidateDeviceRelations() -> handle_bus_relations() ->
enumerate_new_device() -> install_device_driver() ->
SetupDiCallClassInstaller(DIF_REGISTER_COINSTLLERS) ->
SetupDiRegisterCoDeviceInstllers() -> create_driver_key().

Which installs the winehid.ini for the device on the underlaying HIDRAW bus.

Then enumerate_new_device() ends up calling start_device() which creates
HID device by invoking hidclass.sys/pnp.c:PNP_AddDevice().

Right now hidclass.sys (just like the display drivers) seems to be in
charge of its own SetupAPI entries.

How exactly does SetupDiSelectBestCompatDrv() tie into that?

-- 
Cheers,
Arek



More information about the wine-devel mailing list