> ## Documentation Index
> Fetch the complete documentation index at: https://devdocs.xbox.com/llms.txt
> Use this file to discover all available pages before exploring further.

# XUserDeviceAssociationChange

> XUserDeviceAssociationChange

# XUserDeviceAssociationChange

Specifies the old and new device associations when a device association changes.

## Syntax

```cpp theme={null}
typedef struct XUserDeviceAssociationChange {  
    APP_LOCAL_DEVICE_ID deviceId;  
    XUserLocalId oldUser;  
    XUserLocalId newUser;  
} XUserDeviceAssociationChange  
```

### Members

*deviceId*\
Type: [APP\_LOCAL\_DEVICE\_ID](/reference/system/xuser/structs/app_local_device_id)

The ID of the device whose user association changes.

*oldUser*\
Type: [XUserLocalId](/reference/system/xuser/structs/xuserlocalid)

The old user ID associated with the device.

*newUser*\
Type: [XUserLocalId](/reference/system/xuser/structs/xuserlocalid)

The new user ID associated with the device.

## Remarks

All arguments to XUserDeviceAssociationChange can be "null":

* If deviceId is equal to **XUserNullDeviceId**, the user change applies to all devices, where all devices have associations with a signed-in user.
* If oldUser is equal to **XUserNullUserLocalId**, the device-user association is new.
* If newUser is equal to **XUserNullUserLocalId**, the existing device-user associaton is lost.

<Note>*newUser* can only reference users that were already added to the title via a call to [XUserAddAsync](/reference/system/xuser/functions/xuseraddasync). If the system picker was used to pair an input device to a user that the title doesn't know about, newUser will be equal to **XUserNullUserLocalId**. See [Users and input devices](/build/core-features/common/user/users-input-devices) for more information.</Note>

These memebers should be treated as raw byte structure that can be compared using memcmp or an equivalent method.  For example:

```cpp theme={null}
XUserDeviceAssociationChange *change; // incoming argument from callback

if(memcmp(&change->deviceId, &XUserNullDeviceId, sizeof(APP_LOCAL_DEVICE_ID) == 0))
{
}

if(memcmp(&change->newUser, &XUserNullUserLocalId, sizeof(XUserLocalId) == 0))
{
}
```

The [XUserDeviceAssociationChangedCallback](/reference/system/xuser/functions/xuserdeviceassociationchangedcallback) callback function uses a pointer to an XUserDeviceAssociationChange structure.

The callback function passes context to the [XUserRegisterForDeviceAssociationChanged](/reference/system/xuser/functions/xuserregisterfordeviceassociationchanged) function when the callback registers.

The [XUserRegisterForDeviceAssociationChanged](/reference/system/xuser/functions/xuserregisterfordeviceassociationchanged) function registers a callback for user device association change events.

## Requirements

**Header:** XUser.h

**Supported platforms:** Windows, XBOX One family consoles and XBOX Series consoles

## See also

[XUser](/reference/system/xuser/xuser_members)

[XUserDeviceAssociationChangedCallback](/reference/system/xuser/functions/xuserdeviceassociationchangedcallback)

[XUserRegisterForDeviceAssociationChanged](/reference/system/xuser/functions/xuserregisterfordeviceassociationchanged)


## Related topics

- [XUserDeviceAssociationChangedCallback](/reference/system/xuser/functions/xuserdeviceassociationchangedcallback.md)
- [XUser](/reference/system/xuser/xuser_members.md)
- [APP_LOCAL_DEVICE_ID](/reference/system/xuser/structs/app_local_device_id.md)
- [XUserRegisterForDeviceAssociationChanged](/reference/system/xuser/functions/xuserregisterfordeviceassociationchanged.md)
- [XUserUnregisterForDeviceAssociationChanged](/reference/system/xuser/functions/xuserunregisterfordeviceassociationchanged.md)
