[PATCH 2/5] xinput.sys: Introduce new xinput.sys driver.

Zebediah Figura (she/her) zfigura at codeweavers.com
Mon Aug 23 11:41:19 CDT 2021


On 8/18/21 2:31 AM, Rémi Bernon wrote:
> Currently only acting as a pass-through driver, matching any device with
> a WINEBUS\WINE_COMP_XINPUT compatible id.
> 
> This creates new PDO on the bus, adding the &IG_ device ID suffix to the
> original device ID (replacing an eventual &MI_ suffix), and removes the
> need to set the suffix on winebus.sys side.
> 
> Signed-off-by: Rémi Bernon <rbernon at codeweavers.com>
> ---
>   configure.ac                    |   1 +
>   dlls/winebus.sys/main.c         |  27 +--
>   dlls/xinput.sys/Makefile.in     |   8 +
>   dlls/xinput.sys/main.c          | 393 ++++++++++++++++++++++++++++++++
>   dlls/xinput.sys/xinput.inf      |  22 ++
>   dlls/xinput.sys/xinput.rc       |  20 ++
>   dlls/xinput.sys/xinput.sys.spec |   1 +
>   loader/wine.inf.in              |   1 +
>   8 files changed, 457 insertions(+), 16 deletions(-)
>   create mode 100644 dlls/xinput.sys/Makefile.in
>   create mode 100644 dlls/xinput.sys/main.c
>   create mode 100644 dlls/xinput.sys/xinput.inf
>   create mode 100644 dlls/xinput.sys/xinput.rc
>   create mode 100644 dlls/xinput.sys/xinput.sys.spec
> 
> diff --git a/configure.ac b/configure.ac
> index 7237289a2ad..7ff7869b37e 100644
> --- a/configure.ac
> +++ b/configure.ac
> @@ -3895,6 +3895,7 @@ WINE_CONFIG_MAKEFILE(dlls/xaudio2_7)
>   WINE_CONFIG_MAKEFILE(dlls/xaudio2_7/tests)
>   WINE_CONFIG_MAKEFILE(dlls/xaudio2_8)
>   WINE_CONFIG_MAKEFILE(dlls/xaudio2_9)
> +WINE_CONFIG_MAKEFILE(dlls/xinput.sys)
>   WINE_CONFIG_MAKEFILE(dlls/xinput1_1)
>   WINE_CONFIG_MAKEFILE(dlls/xinput1_2)
>   WINE_CONFIG_MAKEFILE(dlls/xinput1_3)
> diff --git a/dlls/winebus.sys/main.c b/dlls/winebus.sys/main.c
> index e360416b5dd..17720bffbc5 100644
> --- a/dlls/winebus.sys/main.c
> +++ b/dlls/winebus.sys/main.c
> @@ -152,8 +152,6 @@ static CRITICAL_SECTION device_list_cs = { &critsect_debug, -1, 0, 0, 0, 0 };
>   static struct list pnp_devset = LIST_INIT(pnp_devset);
>   
>   static const WCHAR zero_serialW[]= {'0','0','0','0',0};
> -static const WCHAR miW[] = {'M','I',0};
> -static const WCHAR igW[] = {'I','G',0};
>   
>   static inline WCHAR *strdupW(const WCHAR *src)
>   {
> @@ -201,25 +199,17 @@ static WCHAR *get_instance_id(DEVICE_OBJECT *device)
>   
>   static WCHAR *get_device_id(DEVICE_OBJECT *device)
>   {
> +    static const WCHAR input_formatW[] = {'&','M','I','_','%','0','2','u',0};
>       static const WCHAR formatW[] = {'%','s','\\','v','i','d','_','%','0','4','x',
>               '&','p','i','d','_','%','0','4','x',0};
> -    static const WCHAR format_inputW[] = {'%','s','\\','v','i','d','_','%','0','4','x',
> -            '&','p','i','d','_','%','0','4','x','&','%','s','_','%','0','2','i',0};
>       struct device_extension *ext = (struct device_extension *)device->DeviceExtension;
>       DWORD len = strlenW(ext->busid) + 34;
> -    WCHAR *dst;
> +    WCHAR *dst, *tmp;
>   
>       if ((dst = ExAllocatePool(PagedPool, len * sizeof(WCHAR))))
>       {
> -        if (ext->input == (WORD)-1)
> -        {
> -            sprintfW(dst, formatW, ext->busid, ext->vid, ext->pid);
> -        }
> -        else
> -        {
> -            sprintfW(dst, format_inputW, ext->busid, ext->vid, ext->pid,
> -                    ext->is_gamepad ? igW : miW, ext->input);
> -        }
> +        tmp = dst + sprintfW(dst, formatW, ext->busid, ext->vid, ext->pid);
> +        if (ext->input != (WORD)-1) sprintfW(tmp, input_formatW, ext->input);
>       }
>   
>       return dst;
> @@ -245,12 +235,17 @@ static WCHAR *get_compatible_ids(DEVICE_OBJECT *device)
>       {
>           'W','I','N','E','B','U','S','\\','W','I','N','E','_','C','O','M','P','_','H','I','D',0
>       };
> -    DWORD len = strlenW(hid_compat);
> +    static const WCHAR xinput_compat[] =
> +    {
> +        'W','I','N','E','B','U','S','\\','W','I','N','E','_','C','O','M','P','_','X','I','N','P','U','T',0
> +    };
> +    struct device_extension *ext = (struct device_extension *)device->DeviceExtension;
> +    DWORD len = strlenW(ext->is_gamepad ? xinput_compat : hid_compat);
>       WCHAR *dst;
>   
>       if ((dst = ExAllocatePool(PagedPool, (len + 2) * sizeof(WCHAR))))
>       {
> -        strcpyW(dst, hid_compat);
> +        strcpyW(dst, ext->is_gamepad ? xinput_compat : hid_compat);
>           dst[len + 1] = 0;
>       }
>   

It also occurs to me that you could put the winebus parts in a separate 
patch, or even combine them with patch 3/5.



More information about the wine-devel mailing list