[2/4] dinput: Handle username in EnumDevicesBySemantics.

Andrew Eikum aeikum at codeweavers.com
Mon Feb 27 10:12:36 CST 2017


On Thu, Feb 23, 2017 at 01:22:19AM +0200, Jetro Jormalainen wrote:
> @@ -955,6 +998,14 @@ static HRESULT WINAPI IDirectInput8AImpl_EnumDevicesBySemantics(
>  
>      didevi.dwSize = sizeof(didevi);
>  
> +    if (ptszUserName)
> +    {
> +        username_size = MultiByteToWideChar(CP_ACP, 0, ptszUserName, -1, 0, 0);
> +        MultiByteToWideChar(CP_ACP, 0, ptszUserName, -1, username_w, username_size);

Normally, we use the return from MultiByteToWideChar to allocate the
destination buffer. You could switch to that. I'm not opposed to doing
it on the stack like this, but then there's no need for username_size.
You can just pass the size of the buffer in WCHARs as the last param
of MultiByteToWideChar.

Andrew



More information about the wine-devel mailing list