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

# ConnectGamepad

> IXtfInputClient::ConnectGamepad Method

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

## Syntax

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

### Parameters

*pControllerId*\
Type: UINT64 \*

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

### Return value

Type: HRESULT

HRESULT success or error code.

## 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](https://docs.xbox.com/reference/tools/xtf/xtfinput/classes/IXtfInputClient/methods/sendgamepadreport-ixtfinputclient-xtfinput-xbox-windows-m.md). Your code should wait 2 seconds after calling **ConnectGamepad** before calling [SendGamepadReport](https://docs.xbox.com/reference/tools/xtf/xtfinput/classes/IXtfInputClient/methods/sendgamepadreport-ixtfinputclient-xtfinput-xbox-windows-m.md), 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](https://docs.xbox.com/reference/tools/xtf/xtfinput/classes/IXtfInputClient/methods/disconnectgamepad-ixtfinputclient-xtfinput-xbox-windows-m.md) to ensure that these system resources are freed for reuse. You may also call [IXtfInputClient::DisconnectAllGamepads](https://docs.xbox.com/reference/tools/xtf/xtfinput/classes/IXtfInputClient/methods/disconnectgamepad-ixtfinputclient-xtfinput-xbox-windows-m.md) to release all of the virtual controller resources at once.

## Requirements

**Header:** xtfinput.h

**Library:** xtfinput.lib

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

## See also

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


## Related topics

- [GAMEPAD_REPORT_EX](https://docs.xbox.com/reference/tools/xtf/xtfinput/structures/gamepad_report_ex.md)
- [GAMEPAD_REPORT structure](https://docs.xbox.com/reference/tools/xtf/xtfinput/structures/GAMEPAD_REPORT-xtfinput-xbox-windows-t.md)
- [DisconnectGamepad](https://docs.xbox.com/reference/tools/xtf/xtfinput/classes/IXtfInputClient/methods/disconnectgamepad-ixtfinputclient-xtfinput-xbox-windows-m.md)
- [SendGamepadReport](https://docs.xbox.com/reference/tools/xtf/xtfinput/classes/IXtfInputClient/methods/sendgamepadreport-ixtfinputclient-xtfinput-xbox-windows-m.md)
- [DisconnectAllGamepads](https://docs.xbox.com/reference/tools/xtf/xtfinput/classes/IXtfInputClient/methods/disconnectallgamepads-ixtfinputclient-xtfinput-xbox-windows-m.md)
