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

# XInputGetDeviceId

> XInputGetDeviceId

Retrieves the device ID for the specified controller.

## Syntax

```cpp theme={null}
DWORD XInputGetDeviceId(  
         DWORD dwUserIndex,  
         APP_LOCAL_DEVICE_ID * pDeviceId  
)  
```

### Parameters

*dwUserIndex*   \_In\_\
Type: DWORD

Index of the gamer associated with the device; a value in the range of 0 to `XUSER_MAX_COUNT - 1`.

*pDeviceId*   \_Out\_\
Type: APP\_LOCAL\_DEVICE\_ID\*

ID of the device at the specified user index.

### Return value

Type: DWORD

If the function successfully retrieves the device ID, it returns `ERROR_SUCCESS`.

If the controller is not connected, the function returns `ERROR_DEVICE_NOT_CONNECTED`.

If the function fails, it returns a Win32 error code.

## Remarks

An application-local device ID uniquely identifies a device, even across restarts of the title or the system. For more information, see [Device IDs](https://docs.xbox.com/build/core-features/common/input/overviews/input-devices.md#deviceIdsSection).

For more information about using XInputOnGameInput, see [The XInputOnGameInput wrapper](https://docs.xbox.com/build/core-features/common/input/porting/input-porting-xinput.md#xinputWrapperSection).

## Requirements

**Header:** XInputOnGameInput.h

**Library:** xgameruntime.lib

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

## See also

[Porting from XInput to GameInput](https://docs.xbox.com/build/core-features/common/input/porting/input-porting-xinput.md)\
[XInputOnGameInput](https://docs.xbox.com/reference/input/xinputongameinput/xinputongameinput_members.md)


## Related topics

- [Users and input devices](https://docs.xbox.com/build/core-features/common/user/users-input-devices.md)
- [APP_LOCAL_DEVICE_ID](https://docs.xbox.com/reference/system/xuser/structs/app_local_device_id.md)
- [Porting from XInput to GameInput](https://docs.xbox.com/build/core-features/common/input/porting/input-porting-xinput.md)
- [XInputOnGameInput (API contents)](https://docs.xbox.com/reference/input/xinputongameinput/xinputongameinput_members.md)
- [XInputGetAudioDeviceIds](https://docs.xbox.com/reference/input/xinputongameinput/functions/xinputgetaudiodeviceids.md)
