> ## Documentation Index
> Fetch the complete documentation index at: https://devdocs.xbox.com/llms.txt
> Use this file to discover all available pages before exploring further.

# XGameStreamingGetGamepadPhysicality

> XGameStreamingGetGamepadPhysicality

# XGameStreamingGetGamepadPhysicality

特定のゲームパッドの読み取りから入力の物理性マッピングを取得します。

<a id="syntaxSection" />

## Syntax

```cpp theme={null}
HRESULT XGameStreamingGetGamepadPhysicality(
         IGameInputReading* gamepadReading,
         XGameStreamingGamepadPhysicality* gamepadPhysicality
)
```

<a id="parametersSection" />

### Parameters

*gamepadReading*   \_In\_\
型: IGameInputReading\*

照会するゲームパッドの読み取り。

*gamepadPhysicality*   \_Out\_\
型: [XGameStreamingGamepadPhysicality](/reference/system/xgamestreaming/enums/xgamestreaminggamepadphysicality)\*

入力読み取りの物理性。

<a id="retvalSection" />

### Return value

型: HRESULT

成功した場合は **S\_OK** を返します。それ以外の場合はエラー コードを返します。

**想定されるエラー**

| エラー コード                                      | エラー値       | エラーの理由                                                                                                                                                     |
| -------------------------------------------- | ---------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------- |
| E\_GAMESTREAMING\_NOT\_INITIALIZED           | 0x89245400 | XGameStreaming ランタイムが初期化されていません。他の API を呼び出す前に [XGameStreamingInitialize](/reference/system/xgamestreaming/functions/xgamestreaminginitialize) を呼び出してください。 |
| E\_GAMESTREAMING\_NOT\_STREAMING\_CONTROLLER | 0x89245404 | 現在の読み取りはストリーミング コントローラーからのものではありません。                                                                                                                       |

<a id="remarksSection" />

## Remarks

ゲームは、入力が物理的に接続されたコントローラーからのものか、それとも仮想コントローラー入力に変換されたタッチ レイアウトからのものかによって、コントローラー入力を区別する必要がある場合があります。

**シナリオ例**

ゲームには **A** ボタンに関連付けられた *ジャンプ* アクションがあります。ゲームは *ジャンプ* アイコンが仮想コントローラーの **A** ボタン押下として構成されたタッチ レイアウトを提供しています。また、ゲームはプレイヤーが物理コントローラーを再マッピングし、**A** をジャンプに関連付けないようにする機能も提供します。

ゲームでは、ゲーム内の要素との操作について視覚的なヒントを提示できます (例: **A** を押して *ジャンプ*)。プレイヤーがタッチ レイアウトを使用している場合、視覚的なヒントはタッチ レイアウトのボタンのアイコンを表示する必要があります。

<a id="exampleSection" />

## Example

次のコード例では、ゲームは既定でコントローラーの **A** ボタンに *ジャンプ* アクションを紐付けています。この設定はプレイヤーによってカスタマイズ可能ですが、画面上のタッチ レイアウトは固定されているため、タッチ レイアウトからの **A** ボタン押下は常に *ジャンプ* として扱う必要があり、物理コントローラーからの **A** は、プレイヤーがコントローラー マッピングのカスタマイズで設定した内容として扱う必要があります。

```cpp theme={null}
void Game::Update(DX::StepTimer const& timer)
{
    g_gameInput->GetCurrentReading(GameInputKind::GameInputKindController, g_gamepad, &reading);
    
    GameInputGamepadState state;
    reading->GetGamepadState(&state);

    XGameStreamingGamepadPhysicality physicality = XGameStreamingGamepadPhysicality::None;
    
    HRESULT hr = XGameStreamingGetGamepadPhysicality(reading, &physicality);

    if ((state.buttons & GameInputGamepadA) != GameInputGamepadNone)
    {
        if (SUCCEEDED(hr))
        {
            if ((physicality & XGameStreamingGamepadPhysicality::AVirtual) == 
                XGameStreamingGamepadPhysicality::AVirtual)
            {
                // 'A' Input came from touch layout
                // Perform 'jump' action, if applicable
            }
            else if ((physicality & XGameStreamingGamepadPhysicality::APhysical) == 
                 XGameStreamingGamepadPhysicality::APhysical)
            {
                // 'A' Input came from the physical controller.
                // Lookup 'A' from the user's customized controller mapping.
                // Perform whatever action A is mapped to, if applicable.
            }
        }
        else
        {
            // Physicality not present on this gamepad.
            // Perform input 'A' action as if there were no stream.
        }
    }

    // UI icon updates.
    // If the player is using the touch layouts, then show touch iconography, 
    // otherwise switch to the physical controller iconography.
    if (SUCCEEDED(hr))
    {
        if ((physicality & XGameStreamingGamepadPhysicality::AllVirtual) != 
            XGameStreamingGamepadPhysicality::None)
        {
            // At least one input is coming from virtual touch layout.
            // Update UI icons to match the touch layouts.
        } 
        else 
        {
            if ((physicality & XGameStreamingGamepadPhysicality::AllPhysical) != 
                XGameStreamingGamepadPhysicality::None)
            {
                // At least one input is coming from a physical controller.
                // Update UI icons to match a physical controller inputs (for example, LT/LB/RT/RB icon).
            }
        }
    }
    else
    {
        // Use the default non-streaming behavior for UI icons 
    }
}
```

<a id="requirementsSection" />

## Requirements

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

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

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

<a id="seealsoSection" />

## See also

[XGameStreaming](/reference/system/xgamestreaming/xgamestreaming_members)\
[XGameStreamingGamepadPhysicality](/reference/system/xgamestreaming/enums/xgamestreaminggamepadphysicality)\
[XGameStreaming Touch Adaptation](/reference/system/xgamestreaming/xgamestreaming_members#TouchAdaptation)


## Related topics

- [XGameStreamingGamepadPhysicality](/ja-jp/reference/system/xgamestreaming/enums/xgamestreaminggamepadphysicality.md)
- [XGameStreaming](/ja-jp/reference/system/xgamestreaming/xgamestreaming_members.md)
- [タッチ コントロール構築のデザイナーズ ガイド](/ja-jp/build/core-features/common/game-streaming/building-touch-layouts/game-streaming-tak-designers-guide.md)
- [XGameStreamingGetAssociatedFrame](/ja-jp/reference/system/xgamestreaming/functions/xgamestreaminggetassociatedframe.md)
- [GAMEPAD_VIBRATION](/ja-jp/reference/tools/xtf/xtfinput/structures/gamepad_vibration.md)
