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

# IGameInputDevice::GetPnpPath

> Gets the Plug and Play device path of the input device as a UTF-8 string.

Gets the Plug and Play (PnP) device path of the input device as a UTF-8 string.

## Syntax

```cpp theme={null}
uint32_t GetPnpPath(
    uint32_t bufferByteCount,
    char* buffer
);
```

### Parameters

*bufferByteCount*   \_In\_\
Type: uint32\_t

The size, in bytes, of the buffer pointed to by *buffer*. Pass 0 to query the required size.

*buffer*   \_Out\_writes\_bytes\_opt\_(bufferByteCount)\
Type: char\*

The buffer that receives the null-terminated UTF-8 PnP path. Pass `nullptr` to query the required size.

### Return value

Type: uint32\_t

The size, in bytes, of the buffer required to hold the PnP path, including the null terminator.

## Remarks

The method writes the PnP path to *buffer* only if *buffer* isn't `nullptr` and *bufferByteCount* is greater than or equal to the required size. Otherwise, the buffer isn't modified. To retrieve the path, call the method once with a *bufferByteCount* of 0 and a *buffer* of `nullptr` to get the required size, allocate a buffer of that size, and then call the method again.

If the device doesn't have a PnP path, the required size is 1, and the method writes an empty string.

Use the PnP path to reference the underlying device through other APIs. Because the path is encoded as UTF-8, convert it to UTF-16 (for example, by using `MultiByteToWideChar` with `CP_UTF8`) before you pass it to Windows APIs that expect wide-character strings.

The PnP path doesn't change for the lifetime of the device object.

The following example retrieves the PnP path of a device.

```cpp theme={null}
std::string GetDevicePnpPath(IGameInputDevice* device)
{
    const uint32_t size = device->GetPnpPath(0, nullptr);
    if (size == 0)
    {
        return {};
    }

    std::vector<char> buffer(size);
    device->GetPnpPath(size, buffer.data());

    return std::string(buffer.data());
}
```

In GameInput v3 and earlier, this information was available from the `pnpPath` member of the [GameInputDeviceInfo](https://docs.xbox.com/reference/input/gameinput/deprecated/structs/gameinputdeviceinfo.md) structure returned by [IGameInputDevice::GetDeviceInfo](https://docs.xbox.com/reference/input/gameinput/deprecated/interfaces/igameinputdevice/methods/igameinputdevice_getdeviceinfo.md).

## Requirements

**Header:** GameInput.h

**Library:** gameinput.lib

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

## See also

[Overview of GameInput](https://docs.xbox.com/build/core-features/common/input/overviews/input-overview.md)\
[IGameInputDevice](https://docs.xbox.com/reference/input/gameinput/interfaces/igameinputdevice/igameinputdevice.md)\
[IGameInputDevice::GetDisplayName](https://docs.xbox.com/reference/input/gameinput/interfaces/igameinputdevice/methods/igameinputdevice_getdisplayname.md)\
[IGameInputDevice::GetContainerId](https://docs.xbox.com/reference/input/gameinput/interfaces/igameinputdevice/methods/igameinputdevice_getcontainerid.md)

## Version History

| Version | Changes |
| - | - |
| **v4** | Introduced. |


## Related topics

- [IGameInputDevice::GetDisplayName](https://docs.xbox.com/reference/input/gameinput/interfaces/igameinputdevice/methods/igameinputdevice_getdisplayname.md)
- [IGameInputDevice::GetContainerId](https://docs.xbox.com/reference/input/gameinput/interfaces/igameinputdevice/methods/igameinputdevice_getcontainerid.md)
- [GameInput Frequently Asked Questions](https://docs.xbox.com/build/core-features/common/input/overviews/input-faq.md)
- [Combining GameInput with existing input stacks](https://docs.xbox.com/build/core-features/common/input/porting/input-porting.md)
- [IGameInputDevice::GetSupportedInput](https://docs.xbox.com/reference/input/gameinput/interfaces/igameinputdevice/methods/igameinputdevice_getsupportedinput.md)
