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

# IXtfInputClient::ConnectGamepad Method

> IXtfInputClient::ConnectGamepad Method

# IXtfInputClient::ConnectGamepad Method

Creates a virtual controller, and gets the device identifier for it.

<a id="syntaxSection" />

## Syntax

```cpp theme={null}
public:
HRESULT ConnectGamepad(
         UINT64 *pControllerId
)  
```

<a id="ID4EG" />

### Parameters

*pControllerId*\
Type: UINT64 \*

Pointer to a UINT64 that receives the device identifier of this [IXtfInputClient](/reference/tools/xtf/xtfinput/classes/IXtfInputClient/ixtfinputclient-xtfinput-xbox-windows-t).

<a id="ID4EP" />

### Return value

Type: HRESULT

HRESULT success or error code.

<a id="remarks" />

## Remarks

**ConnectGamepad** allocates system resources for each virtual controller created, as well as returns the identifier for the virtual controller that will be used to send input to a development console with [IXtfInputClient::SendGamepadReport](/reference/tools/xtf/xtfinput/classes/IXtfInputClient/methods/sendgamepadreport-ixtfinputclient-xtfinput-xbox-windows-m). Your code should wait 2 seconds after calling **ConnectGamepad** before calling [SendGamepadReport](/reference/tools/xtf/xtfinput/classes/IXtfInputClient/methods/sendgamepadreport-ixtfinputclient-xtfinput-xbox-windows-m), to ensure that the console has finished registering the new controller and is ready to accept input. Your code should always pair a call to **ConnectGamepad** with a call to [DisconnectGamepad](/reference/tools/xtf/xtfinput/classes/IXtfInputClient/methods/disconnectgamepad-ixtfinputclient-xtfinput-xbox-windows-m) to ensure that these system resources are freed for reuse. You may also call [IXtfInputClient::DisconnectAllGamepads](/reference/tools/xtf/xtfinput/classes/IXtfInputClient/methods/disconnectgamepad-ixtfinputclient-xtfinput-xbox-windows-m) to release all of the virtual controller resources at once.

<a id="requirements" />

## Requirements

**Header:** xtfinput.h

**Library:** xtfinput.lib

**Supported platforms:** Windows (for XBOX console tools)

## See also

[XtfInput](/reference/tools/xtf/xtfinput/xtfinput-xbox-microsoft-n)\
[IXtfInputClient](/reference/tools/xtf/xtfinput/classes/IXtfInputClient/ixtfinputclient-xtfinput-xbox-windows-t)\
[IXtfInputClient::ConnectGamepad](/reference/tools/xtf/xtfinput/classes/IXtfInputClient/methods/connectgamepad-ixtfinputclient-xtfinput-xbox-windows-m)\
[IXtfInputClient::DisconnectGamepad](/reference/tools/xtf/xtfinput/classes/IXtfInputClient/methods/disconnectgamepad-ixtfinputclient-xtfinput-xbox-windows-m)\
[IXtfInputClient::DisconnectAllGamepads](/reference/tools/xtf/xtfinput/classes/IXtfInputClient/methods/disconnectgamepad-ixtfinputclient-xtfinput-xbox-windows-m)


## Related topics

- [IXtfInputClient::DisconnectGamepad Method](/reference/tools/xtf/xtfinput/classes/IXtfInputClient/methods/disconnectgamepad-ixtfinputclient-xtfinput-xbox-windows-m.md)
- [IXtfInputClient::DisconnectAllGamepads Method](/reference/tools/xtf/xtfinput/classes/IXtfInputClient/methods/disconnectallgamepads-ixtfinputclient-xtfinput-xbox-windows-m.md)
- [IXtfInputClient::SendGamepadReport Method](/reference/tools/xtf/xtfinput/classes/IXtfInputClient/methods/sendgamepadreport-ixtfinputclient-xtfinput-xbox-windows-m.md)
- [IXtfInputClient::SendGamepadReportEx](/reference/tools/xtf/xtfinput/classes/IXtfInputClient/methods/ixtfinputclient_sendgamepadreportex.md)
- [IXtfInputClient::SendGamepadReportWithAudio](/reference/tools/xtf/xtfinput/classes/IXtfInputClient/methods/ixtfinputclient_sendgamepadreportwithaudio.md)
