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

# When do user-to-controller associations take place?

> When do user-to-controller associations take place?

When a controller is successfully associated to a user, pushing the nexus
button on that controller will show that user's personalized experience in
the Guide and Dashboard. Users need to feel like they understand and control
when this happens. Anytime the association between a user and controller
changes, there will be a
[XUserDeviceAssociationChangedCallback](/reference/system/xuser/functions/xuserdeviceassociationchangedcallback).

New associations can be formed in the following ways:

* Anytime an account picker is shown.
* Calling [XUserAddAsync](/reference/system/xuser/functions/xuseraddasync).
* Calling [XUserFindControllerForUserWithUiAsync](/reference/system/xuser/functions/xuserfindcontrollerforuserwithuiasync).
* When there is a single user signed into the console, the first controller
  given input by the user will be associated to them.
* When a user chooses to launch (or relaunch) a game using an unassociated
  controller, that controller will automatically get associated to that user.
* Using the XBOX Accessories app, a user can associate a given controller to
  a user. When that controller is turned on, the specified user will be signed
  in and that controller than associated to that user.
* Plugging a battery back into a controller will automatically reassociated
  that controller with the previous owner

Associations can be lost when:

* The controller is turned off (e.g., battery loss)
* The user signs out
* The controller is associated to a new user (the original user will get
  that it is now lost.)

The following example illustrates how controller associations can change on the console,
events that get fired, and what actions a game might take.

| Step | Description                                                                | Game Actions                                                                                                                                   | User A  State                                                                                     | User B State                                                                                                    |
| ---- | -------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------- |
| 1    | User A is signed in and launches the game using controller 1.              | Game registers for *XUserDeviceAssociationChangedCallback* and calls *XUserAddAsync*.                                                          | User A is known to the game. Via the callback the game knows controller 1 is associated to User A | N/A                                                                                                             |
| 2    | During gameplay, the user goes back to home and the game is still running. |                                                                                                                                                | No change                                                                                         | N/A                                                                                                             |
| 3    | User A signs in User B using controller 1.                                 | *XUserDeviceAssociationChangedCallback* fires.                                                                                                 | User A is still known to the game but no longer has a controller associated to them.              | User B is signed into the console but not visible to the game. They are associated to controller 1.             |
| 4    | User A returns to the game, still using controller 1.                      | As a best practice, the game should call *XUserFindControllerForUserWithUiAsync* to ensure that User A is properly associated to a controller. | User A is associated to whatever controller they selected.                                        | If User A re-selected controller 1 instead of a new controller, User B is no longer associated to a controller. |

## See Also

[XUserAddAsync](/reference/system/xuser/functions/xuseraddasync)

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

[XUserFindControllerForUserWithUiAsync](/reference/system/xuser/functions/xuserfindcontrollerforuserwithuiasync)


## Related topics

- [Users](/build/core-features/common/user/user-toc.md)
- [User identity and XUser APIs in the GDK](/build/core-features/common/user/index.md)
- [XR-115 Adding and removing users or controllers in play](/publishing/certification/xr/xr-115.md)
- [Dealing with Controller Loss](/build/core-features/common/user/users-dealing-with-controller-loss.md)
- [XUserFindControllerForUserWithUiAsync](/reference/system/xuser/functions/xuserfindcontrollerforuserwithuiasync.md)
