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

> デバイス上の汎用コントローラー軸のラベルを取得します。

デバイス上の汎用コントローラー軸のラベルを取得します。

## 構文

```cpp theme={null}
uint32_t GetControllerAxisLabels(
    uint32_t labelArrayCount,
    GameInputLabel* labelArray
);
```

### パラメーター

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

*labelArray* の要素数。すべてのコントローラー軸のラベルを取得するには、[GetControllerAxisCount](https://docs.xbox.com/ja-jp/reference/input/gameinput/interfaces/igameinputdevice/methods/igameinputdevice_getcontrolleraxiscount.md) から返された値を渡します。

*labelArray*   \_Out\_writes\_to\_opt\_(labelArrayCount, return)\
型: [GameInputLabel](https://docs.xbox.com/ja-jp/reference/input/gameinput/enums/gameinputlabel.md)\*

コントローラー軸ごとに 1 つのラベルを受け取る配列へのポインター。`nullptr` を指定できます。その場合、何も書き込まれず、メソッドは 0 を返します。

### 戻り値

型: uint32\_t

*labelArray* に書き込まれた要素の数。これは *labelArrayCount* とデバイス上のコントローラー軸のラベル数のうち小さい方の値です。*labelArray* が `nullptr` の場合、またはデバイスにコントローラー軸のラベルがない場合は 0 です。

## 解説

各要素は、対応する軸に印字されている表示 (デバイスが報告する場合) を識別する [GameInputLabel](https://docs.xbox.com/ja-jp/reference/input/gameinput/enums/gameinputlabel.md) 値です。

[GetControllerAxisCount](https://docs.xbox.com/ja-jp/reference/input/gameinput/interfaces/igameinputdevice/methods/igameinputdevice_getcontrolleraxiscount.md) を呼び出してコントローラー軸のラベル数を取得し、そのサイズの配列を割り当ててから、`GetControllerAxisLabels` を呼び出して配列にデータを格納します。*labelArrayCount* がコントローラー軸のラベル数より小さい場合は、先頭から *labelArrayCount* 個の要素のみが書き込まれます。デバイスが接続されている間、デバイスのコントローラー軸のラベルは変化しないため、一度クエリを実行して結果をキャッシュできます。

ラベル配列の要素 *i* は、このデバイスからの読み取りについて [IGameInputReading::GetControllerAxisState](https://docs.xbox.com/ja-jp/reference/input/gameinput/interfaces/igameinputreading/methods/igameinputreading_getcontrolleraxisstate.md) から返される配列のインデックス *i* にある軸を表します。

次の例は、デバイスのコントローラー軸のラベルを取得する方法を示しています。

```cpp theme={null}
uint32_t axisCount = device->GetControllerAxisCount();
std::vector<GameInputLabel> axisLabels(axisCount);
axisLabels.resize(device->GetControllerAxisLabels(axisCount, axisLabels.data()));

std::vector<float> axisStates(reading->GetControllerAxisCount());
reading->GetControllerAxisState(static_cast<uint32_t>(axisStates.size()), axisStates.data());

for (size_t i = 0; i < axisLabels.size() && i < axisStates.size(); ++i)
{
    // axisLabels[i] is the label of the axis whose value is axisStates[i].
}
```

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) 構造体の `controllerInfo` メンバーが参照する [GameInputControllerInfo](https://docs.xbox.com/ja-jp/reference/input/gameinput/deprecated/structs/gameinputcontrollerinfo.md) 構造体の `controllerAxisLabels` メンバーから取得できました。

## 要件

**ヘッダー:** 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)\
[GetControllerAxisCount](https://docs.xbox.com/ja-jp/reference/input/gameinput/interfaces/igameinputdevice/methods/igameinputdevice_getcontrolleraxiscount.md)\
[GameInputLabel](https://docs.xbox.com/ja-jp/reference/input/gameinput/enums/gameinputlabel.md)\
[IGameInputReading::GetControllerAxisState](https://docs.xbox.com/ja-jp/reference/input/gameinput/interfaces/igameinputreading/methods/igameinputreading_getcontrolleraxisstate.md)\
[IGameInputDevice](https://docs.xbox.com/ja-jp/reference/input/gameinput/interfaces/igameinputdevice/igameinputdevice.md)

## バージョン履歴

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


## Related topics

- [GameInputLabel](https://docs.xbox.com/ja-jp/reference/input/gameinput/enums/gameinputlabel.md)
- [IGameInputDevice::GetControllerAxisCount](https://docs.xbox.com/ja-jp/reference/input/gameinput/interfaces/igameinputdevice/methods/igameinputdevice_getcontrolleraxiscount.md)
- [IGameInputDevice::GetControllerButtonLabels](https://docs.xbox.com/ja-jp/reference/input/gameinput/interfaces/igameinputdevice/methods/igameinputdevice_getcontrollerbuttonlabels.md)
- [IGameInputDevice::GetControllerButtonCount](https://docs.xbox.com/ja-jp/reference/input/gameinput/interfaces/igameinputdevice/methods/igameinputdevice_getcontrollerbuttoncount.md)
- [IGameInputDevice::GetControllerSwitchInfo](https://docs.xbox.com/ja-jp/reference/input/gameinput/interfaces/igameinputdevice/methods/igameinputdevice_getcontrollerswitchinfo.md)
