> ## 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::GetDisplayName

> 入力デバイスのフレンドリ表示名を UTF-8 文字列として取得します。

入力デバイスのフレンドリ表示名を UTF-8 文字列として取得します。

## 構文

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

### パラメーター

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

*buffer* が指すバッファーのサイズ (バイト単位)。必要なサイズを照会するには 0 を渡します。

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

null で終わる UTF-8 の表示名を受け取るバッファー。必要なサイズを照会するには `nullptr` を渡します。

### 戻り値

型: uint32\_t

表示名を格納するために必要なバッファーのサイズ (null 終端文字を含む、バイト単位)。

## 解説

このメソッドは、*buffer* が `nullptr` ではなく、*bufferByteCount* が必要なサイズ以上の場合にのみ、表示名を *buffer* に書き込みます。それ以外の場合、バッファーは変更されません。表示名を取得するには、まず *bufferByteCount* に 0、*buffer* に `nullptr` を指定してメソッドを呼び出して必要なサイズを取得し、そのサイズのバッファーを割り当ててから、もう一度メソッドを呼び出します。

デバイスに表示名がない場合、必要なサイズは 1 になり、メソッドは空の文字列を書き込みます。

表示名は、デバイスの "フレンドリ" 名です。アプリケーションの UI に表示できますが、ローカライズされている保証はありません。GameInput はこの文字列を複数の場所から検索し、最終的なフォールバックの 1 つはデバイスのファームウェアです。

表示名は、デバイス オブジェクトの有効期間中は変化しません。

次の例では、デバイスの表示名を取得します。

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

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

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

GameInput v3 以前では、この情報は [IGameInputDevice::GetDeviceInfo](https://docs.xbox.com/ja-jp/reference/input/gameinput/deprecated/interfaces/igameinputdevice/methods/igameinputdevice_getdeviceinfo.md) から返される [GameInputDeviceInfo](https://docs.xbox.com/ja-jp/reference/input/gameinput/deprecated/structs/gameinputdeviceinfo.md) 構造体の `displayName` メンバーから取得できました。

## 要件

**ヘッダー:** GameInput.h

**ライブラリ:** gameinput.lib

**サポートされているプラットフォーム:** Windows、XBOX One ファミリー本体、XBOX Series 本体

## 関連項目

[GameInput の概要](https://docs.xbox.com/ja-jp/build/core-features/common/input/overviews/input-overview.md)\
[IGameInputDevice](https://docs.xbox.com/ja-jp/reference/input/gameinput/interfaces/igameinputdevice/igameinputdevice.md)\
[IGameInputDevice::GetPnpPath](https://docs.xbox.com/ja-jp/reference/input/gameinput/interfaces/igameinputdevice/methods/igameinputdevice_getpnppath.md)

## バージョン履歴

| バージョン | 変更内容 |
| - | - |
| **v4** | 導入されました。 |


## Related topics

- [IGameInputDevice::GetPnpPath](https://docs.xbox.com/ja-jp/reference/input/gameinput/interfaces/igameinputdevice/methods/igameinputdevice_getpnppath.md)
- [IGameInputDevice::GetDeviceFamily](https://docs.xbox.com/ja-jp/reference/input/gameinput/interfaces/igameinputdevice/methods/igameinputdevice_getdevicefamily.md)
- [IGameInputDevice::GetDeviceId](https://docs.xbox.com/ja-jp/reference/input/gameinput/interfaces/igameinputdevice/methods/igameinputdevice_getdeviceid.md)
- [IGameInputDevice::GetXInputDeviceIndex](https://docs.xbox.com/ja-jp/reference/input/gameinput/interfaces/igameinputdevice/methods/igameinputdevice_getxinputdeviceindex.md)
- [IGameInputDevice::GetUsage](https://docs.xbox.com/ja-jp/reference/input/gameinput/interfaces/igameinputdevice/methods/igameinputdevice_getusage.md)
