다음을 통해 공유


IGameInputReading::GetGamepadState(v2)

게임 패드 상태를 기술하는 입력 수치에 대한 보기를 검색합니다.

구문

bool GetGamepadState(
    GameInputGamepadState* state
);

매개 변수

state _Out_
형식: GameInputGamepadState*

게임 패드로 해석되는 입력입니다.

반환 값

형식: bool

게임 패드를 성공적으로 해석한 경우 true를 반환합니다. 게임 패드로 인식되지 않는 입력을 읽으려고 시도할 때는 false를 반환합니다.

비고

IGameInputReading::GetInputKind 메서드를 호출하여 일부 IGameInputReading에 대한 유효한 해석을 반환하는 Get\*State 함수를 확인하세요. 각 Get*State 함수에는 IGameInputReading::GetInputKind 열거형에 대응하는 항목이 존재합니다. 해당 IGameInputReading::GetInputKind 플래그가 설정되지 않은 Get*State 함수를 호출하려고 하면 함수는 기본값인 미사용 값과 false 반환 값을 반환합니다.

다음 C++ 샘플은 게임 패드 상태를 읽는 방법을 보여줍니다.

void PlayerCrouch();
void PlayerStand();
void PlayerReload();
void PlayerMove(float, float);
void SetCameraOrientation(float, float);

void ProcessGamepadState(
    _In_ IGameInputReading * prevReading,
    _In_ IGameInputReading * currentReading) noexcept
{
    GameInputGamepadState prevState, currentState;
    prevReading->GetGamepadState(&prevState);
    currentReading->GetGamepadState(&currentState);

    GameInputGamepadButtons changedButtons = prevState.buttons ^ currentState.buttons;
    GameInputGamepadButtons pressedButtons = changedButtons & currentState.buttons;
    GameInputGamepadButtons releasedButtons = changedButtons ^ pressedButtons;

    if (pressedButtons & GameInputGamepadRightShoulder)
    {
        PlayerCrouch();
    }
    else if (releasedButtons & GameInputGamepadRightShoulder)
    {
        PlayerStand();
    }

    if (pressedButtons & GameInputGamepadLeftShoulder)
    {
        PlayerReload();
    }

    PlayerMove(currentState.leftThumbstickX, currentState.leftThumbstickY);
    SetCameraOrientation(currentState.rightThumbstickX, currentState.rightThumbstickY);
}

요구 사항

헤더: GameInput.h

라이브러리: gameinput.lib

지원되는 플랫폼: Windows

참고 항목

입력 API 개요
IGameInputReading
IGameInputReading::GetInputKind