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

# DisconnectGamepad

> IXtfInputClient::DisconnectGamepad Method

Disconnects a specified virtual controller.

## Syntax

```cpp theme={null}
public:
HRESULT DisconnectGamepad(
         UINT64 controllerId
)  
```

### Parameters

*controllerId*\
Type: UINT64

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

Call **DisconnectGamepad** when virtual controller operations are complete, to ensure that resources allocated for the virtual controller are freed. Every call to [IXtfInputClient::ConnectGamepad](https://docs.xbox.com/reference/tools/xtf/xtfinput/classes/IXtfInputClient/methods/connectgamepad-ixtfinputclient-xtfinput-xbox-windows-m.md) should be paired with a call to **DisconnectGamepad**. Failure to disconnect a created gamepad will result in a memory leak. You may call [IXtfInputClient::DisconnectAllGamepads](https://docs.xbox.com/reference/tools/xtf/xtfinput/classes/IXtfInputClient/methods/disconnectgamepad-ixtfinputclient-xtfinput-xbox-windows-m.md) to ensure that all virtual controllers are disconnected in order to avoid a memory leak.

## 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::DisconnectAllGamepads](https://docs.xbox.com/reference/tools/xtf/xtfinput/classes/IXtfInputClient/methods/disconnectgamepad-ixtfinputclient-xtfinput-xbox-windows-m.md)


## Related topics

- [DisconnectAllGamepads](https://docs.xbox.com/reference/tools/xtf/xtfinput/classes/IXtfInputClient/methods/disconnectallgamepads-ixtfinputclient-xtfinput-xbox-windows-m.md)
- [ConnectGamepad](https://docs.xbox.com/reference/tools/xtf/xtfinput/classes/IXtfInputClient/methods/connectgamepad-ixtfinputclient-xtfinput-xbox-windows-m.md)
- [IXtfInputClient Interface (Interface contents)](https://docs.xbox.com/reference/tools/xtf/xtfinput/classes/IXtfInputClient/ixtfinputclient-xtfinput-xbox-windows-t.md)
- [XtfCreateInputClient](https://docs.xbox.com/reference/tools/xtf/xtfinput/methods/xtfcreateinputclient-xtfinput-xbox-windows-m.md)
- [XBOX Manager: remote control](https://docs.xbox.com/tools/tools-console/xbom/manager-tool-gamepad-input.md)
