XGameStreamingGetGamepadPhysicality

특정 게임 패드 판독값에서 실제 입력 매핑을 가져옵니다.

구문

HRESULT XGameStreamingGetGamepadPhysicality(
         IGameInputReading* gamepadReading,
         XGameStreamingGamepadPhysicality* gamepadPhysicality
)

매개 변수

gamepadReading _In_
형식: IGameInputReading*

쿼리 중인 게임 패드 판독값입니다.

gamepadPhysicality _Out_
형식: XGameStreamingGamepadPhysicality*

입력 판독값의 물질성(physicality)입니다.

반환 값

형식: HRESULT

성공한 경우 S_OK를 반환하고, 그렇지 않으면 오류 코드를 반환합니다.

잠재적인 오류

오류 코드 오류 값 오류 발생 원인
E_GAMESTREAMING_NOT_INITIALIZED 0x89245400 XGameStreaming 런타임이 아직 초기화되지 않았습니다. 다른 API를 호출하기 전에 XGameStreamingInitialize를 호출합니다.
E_GAMESTREAMING_NOT_STREAMING_CONTROLLER 0x89245404 스트리밍 컨트롤러에서 현재 판독값을 가져오지 않았습니다.

설명

게임은 입력이 물리적으로 연결된 컨트롤러에서 오느냐, 가상 컨트롤러 입력으로 변환된 터치 레이아웃이냐에 따라 게임이 컨트롤러 입력을 구분하려고 할 수도 있습니다.

예제 시나리오

게임에 A 버튼과 연결된 점프 작업이 있습니다. 가상 컨트롤러의 A 버튼 누름으로 구성된 점프 아이콘이 있는 터치 레이아웃을 제공합니다. 이 게임에서는 A점프와 연결되지 않도록 물리적 컨트롤러를 다시 매핑할 수도 있습니다.

게임은 게임의 요소와 상호 작용하기 위한 시각적 힌트를 제공할 수 있습니다(예: A를 눌러점프). 플레이어가 터치 레이아웃을 사용할 때 시각적 힌트에 터치 레이아웃 버튼의 아이콘이 표시되어야 합니다.

다음 코드 예제에서 게임에는 기본적으로 컨트롤러의 A 버튼에 연결된 점프 작업이 있습니다. 이 설정은 플레이어에서 사용자 지정할 수 있지만 화면의 터치 레이아웃은 고정되어 있으므로 터치 레이아웃에서 A 버튼을 누르면 항상 점프로 처리되어야 하며 물리적 컨트롤러의 A은 컨트롤러 매핑 사용자 지정을 위해 설정한 플레이어로 처리되어야 합니다.

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 
    }
}

요건

헤더: xgamestreaming.h

라이브러리: xgameruntime.lib

지원되는 플랫폼: Windows, Xbox One 패밀리 콘솔 및 Xbox Series 콘솔

참고 항목

XGameStreaming
XGameStreamingGamepadPhysicality
XGameStreaming 터치 적응