[1/4] dinput: Keep username same between device objects.

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


On Thu, Feb 23, 2017 at 01:22:18AM +0200, Jetro Jormalainen wrote:
> @@ -1308,11 +1308,24 @@ HRESULT WINAPI IDirectInputDevice2WImpl_GetProperty(LPDIRECTINPUTDEVICE8W iface,
>          case (DWORD_PTR) DIPROP_USERNAME:
>          {
>              LPDIPROPSTRING ps = (LPDIPROPSTRING)pdiph;
> +            struct DevicePlayer *device_player;
>  
>              if (pdiph->dwSize != sizeof(DIPROPSTRING)) return DIERR_INVALIDPARAM;
>  
> -            lstrcpynW(ps->wsz, This->username, sizeof(ps->wsz)/sizeof(WCHAR));
> -            break;
> +            LIST_FOR_EACH_ENTRY(device_player, &This->dinput->device_players,
> +                struct DevicePlayer, entry)
> +            {
> +                if (IsEqualGUID(&device_player->guid, &This->guid))
> +                {
> +                    if (lstrlenW(device_player->username))

Please use *username instead of strlen in places where we don't
actually care about the string length. Same in the other patch.

> @@ -1390,10 +1403,32 @@ HRESULT WINAPI IDirectInputDevice2WImpl_SetProperty(
>          case (DWORD_PTR) DIPROP_USERNAME:
>          {
>              LPCDIPROPSTRING ps = (LPCDIPROPSTRING)pdiph;
> +            struct DevicePlayer *device_player;
> +            unsigned char found = 0;

Please use BOOL, TRUE, and FALSE for booleans. Some people use those
symbols for their static analyzers. Same in the other patch.

> @@ -56,6 +57,12 @@ struct dinput_device {
>      HRESULT (*create_device)(IDirectInputImpl *dinput, REFGUID rguid, REFIID riid, LPVOID *pdev, int unicode);
>  };
>  
> +struct DevicePlayer {
> +    GUID guid;

"guid" is a little vague. This refers to the specific device instance,
right? Maybe device_guid or instance_guid?

Andrew



More information about the wine-devel mailing list