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

# XInputGetDeviceId

> XInputGetDeviceId

# XInputGetDeviceId

Retrieves the device ID for the specified controller.

<a id="syntaxSection" />

## Syntax

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

<a id="parametersSection" />

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

<a id="retvalSection" />

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

<a id="remarksSection" />

## 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](/build/core-features/common/input/overviews/input-devices#deviceIdsSection).

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

<a id="requirementsSection" />

## Requirements

**Header:** XInputOnGameInput.h

**Library:** xgameruntime.lib

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

<a id="seealsoSection" />

## See also

[Porting from XInput to GameInput](/build/core-features/common/input/porting/input-porting-xinput)\
[XInputOnGameInput](/reference/input/xinputongameinput/xinputongameinput_members)


## Related topics

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