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

# Dealing with Controller Loss

> Dealing with Controller Loss

Having a controller associated to a user is critical for most games. When the
game loses all such controllers for a user (e.g., the battery is dead) the
standard approach for a single player game is to pause it and show a dialog
asking the user to please turn on a controller.

Using the [XUserFindControllerForUserWithUiAsync](/reference/system/xuser/functions/xuserfindcontrollerforuserwithuiasync)
function, games can improve on this experience. This functions takes an XUserHandle
as input and will show a dialog:

\<\<Gamer>>, you need a controller for this game.
Press and hold A to confirm the controller you would like to use

Once the user confirms their controller,  the game can call
[XUserFindControllerForUserWithUiResult](/reference/system/xuser/functions/xuserfindcontrollerforuserwithuiresult)
to get the APP\_LOCAL\_DEVICE\_ID of the chosen controller. More importantly, that
controller is now associated to that user. If that user then hits the nexus button,
the XBOX Guide will show that user's information in the Guide.

Note that the player can cancel out of this dialog without selecting a controller, and the title should handle this cancellation appropriately.  For example, a title could repeatedly call [XUserFindControllerForUserWithUiAsync](/reference/system/xuser/functions/xuserfindcontrollerforuserwithuiasync) to force a selection, or it could return to the title screen since there is no longer a user/controller mapping, or some other behavior which makes sense for the title.

Also note that, with this process, users can get associated to controllers that were previously associated to other users in the game. This is by design.

Anytime the association between a user and controller changes, there will be a
[XUserDeviceAssociationChangedCallback](/reference/system/xuser/functions/xuserdeviceassociationchangedcallback).
As a note, this event will also fire with the successful pairing of user to controller
that came from calling
[XUserFindControllerForUserWithUiAsync](/reference/system/xuser/functions/xuserfindcontrollerforuserwithuiasync).

## See Also

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


## Related topics

- [XUserFindControllerForUserWithUiAsync](/reference/system/xuser/functions/xuserfindcontrollerforuserwithuiasync.md)
- [XUserFindControllerForUserWithUiResult](/reference/system/xuser/functions/xuserfindcontrollerforuserwithuiresult.md)
- [Users](/build/core-features/common/user/user-toc.md)
- [User identity and XUser APIs in the GDK](/build/core-features/common/user/index.md)
- [Best practices for handling offline play](/services/xbox-services/develop/best-practices/live-best-practices-offline-play.md)
