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

> サポートされている軸やエフェクトの種類など、デバイス上のフォース フィードバック モーターに関する情報を取得します。

サポートされている軸やエフェクトの種類など、デバイス上のフォース フィードバック モーターに関する情報を取得します。

## 構文

```cpp theme={null}
uint32_t GetForceFeedbackMotorInfo(
    uint32_t infoArrayCount,
    GameInputForceFeedbackMotorInfo* infoArray
);
```

### パラメーター

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

*infoArray* の要素数。すべてのフォース フィードバック モーターを取得するには、[GetForceFeedbackMotorCount](https://docs.xbox.com/ja-jp/reference/input/gameinput/interfaces/igameinputdevice/methods/igameinputdevice_getforcefeedbackmotorcount.md) から返された値を渡します。

*infoArray*   \_Out\_writes\_to\_opt\_(infoArrayCount, return)\
型: [GameInputForceFeedbackMotorInfo](https://docs.xbox.com/ja-jp/reference/input/gameinput/structs/gameinputforcefeedbackmotorinfo.md)\*

フォース フィードバック モーターごとに 1 つの構造体を受け取る配列へのポインター。`nullptr` を指定できます。その場合、何も書き込まれず、メソッドは 0 を返します。

### 戻り値

型: uint32\_t

*infoArray* に書き込まれた要素の数。これは *infoArrayCount* とデバイス上のフォース フィードバック モーターの数のうち小さい方の値です。*infoArray* が `nullptr` の場合、またはデバイスにフォース フィードバック モーターがない場合は 0 です。

## 解説

各要素は [GameInputForceFeedbackMotorInfo](https://docs.xbox.com/ja-jp/reference/input/gameinput/structs/gameinputforcefeedbackmotorinfo.md) 構造体で、対応するモーターが駆動する軸と、そのモーターがサポートするフォース フィードバック エフェクトの種類を記述します。

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

情報配列の要素 *i* は、モーター インデックスが *i* のモーターを記述します。このインデックスを、[CreateForceFeedbackEffect](https://docs.xbox.com/ja-jp/reference/input/gameinput/interfaces/igameinputdevice/methods/igameinputdevice_createforcefeedbackeffect.md)、[IsForceFeedbackMotorPoweredOn](https://docs.xbox.com/ja-jp/reference/input/gameinput/interfaces/igameinputdevice/methods/igameinputdevice_isforcefeedbackmotorpoweredon.md)、[SetForceFeedbackMotorGain](https://docs.xbox.com/ja-jp/reference/input/gameinput/interfaces/igameinputdevice/methods/igameinputdevice_setforcefeedbackmotorgain.md) の *motorIndex* パラメーターとして使用します。

次の例は、デバイスのフォース フィードバック モーターを取得する方法を示しています。

```cpp theme={null}
uint32_t motorCount = device->GetForceFeedbackMotorCount();
std::vector<GameInputForceFeedbackMotorInfo> motorInfo(motorCount);
motorInfo.resize(device->GetForceFeedbackMotorInfo(motorCount, motorInfo.data()));

for (uint32_t motorIndex = 0; motorIndex < motorInfo.size(); ++motorIndex)
{
    if (motorInfo[motorIndex].isConstantEffectSupported)
    {
        GameInputForceFeedbackParams params = {};
        params.kind = GameInputForceFeedbackConstant;
        // Fill in the remaining effect parameters...

        Microsoft::WRL::ComPtr<IGameInputForceFeedbackEffect> effect;
        device->CreateForceFeedbackEffect(motorIndex, &params, &effect);
    }
}
```

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) 構造体の `forceFeedbackMotorInfo` メンバーから取得できました。

## 要件

**ヘッダー:** 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)\
[GetForceFeedbackMotorCount](https://docs.xbox.com/ja-jp/reference/input/gameinput/interfaces/igameinputdevice/methods/igameinputdevice_getforcefeedbackmotorcount.md)\
[GameInputForceFeedbackMotorInfo](https://docs.xbox.com/ja-jp/reference/input/gameinput/structs/gameinputforcefeedbackmotorinfo.md)\
[CreateForceFeedbackEffect](https://docs.xbox.com/ja-jp/reference/input/gameinput/interfaces/igameinputdevice/methods/igameinputdevice_createforcefeedbackeffect.md)\
[IsForceFeedbackMotorPoweredOn](https://docs.xbox.com/ja-jp/reference/input/gameinput/interfaces/igameinputdevice/methods/igameinputdevice_isforcefeedbackmotorpoweredon.md)\
[SetForceFeedbackMotorGain](https://docs.xbox.com/ja-jp/reference/input/gameinput/interfaces/igameinputdevice/methods/igameinputdevice_setforcefeedbackmotorgain.md)\
[GameInput でのフォース フィードバック](https://docs.xbox.com/ja-jp/build/core-features/common/input/advanced/input-forcefeedback.md)\
[IGameInputDevice](https://docs.xbox.com/ja-jp/reference/input/gameinput/interfaces/igameinputdevice/igameinputdevice.md)

## バージョン履歴

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


## Related topics

- [GameInputForceFeedbackMotorInfo](https://docs.xbox.com/ja-jp/reference/input/gameinput/structs/gameinputforcefeedbackmotorinfo.md)
- [GameInputFeedbackAxes](https://docs.xbox.com/ja-jp/reference/input/gameinput/enums/gameinputfeedbackaxes.md)
- [GameInput のフォースフィードバック](https://docs.xbox.com/ja-jp/build/core-features/common/input/advanced/input-forcefeedback.md)
- [IGameInputDevice::GetForceFeedbackMotorCount](https://docs.xbox.com/ja-jp/reference/input/gameinput/interfaces/igameinputdevice/methods/igameinputdevice_getforcefeedbackmotorcount.md)
- [IGameInputForceFeedbackEffect::GetDevice](https://docs.xbox.com/ja-jp/reference/input/gameinput/interfaces/igameinputforcefeedbackeffect/methods/igameinputforcefeedbackeffect_getdevice.md)
