virtual FReply OnKeyDown(const FGeometry& MyGeometry, const FKeyEvent& InKeyEvent) override { const FKey Key = InKeyEvent.GetKey(); if (Key == EKeys::Enter) { MenuOwner->HandleLoginUIClosed(TSharedPtr<const FUniqueNetId>(), 0); } else if (!MenuOwner->GetControlsLocked() && Key == EKeys::Gamepad_FaceButton_Bottom) { bool bSkipToMainMenu = true; { const auto OnlineSub = IOnlineSubsystem::Get(); if (OnlineSub) { const auto IdentityInterface = OnlineSub->GetIdentityInterface(); if (IdentityInterface.IsValid()) { TSharedPtr<GenericApplication> GenericApplication = FSlateApplication::Get().GetPlatformApplication(); const bool bIsLicensed = GenericApplication->ApplicationLicenseValid(); const auto LoginStatus = IdentityInterface->GetLoginStatus(InKeyEvent.GetUserIndex()); if (LoginStatus == ELoginStatus::NotLoggedIn || !bIsLicensed) { // Show the account picker. const auto ExternalUI = OnlineSub->GetExternalUIInterface(); if (ExternalUI.IsValid()) { ExternalUI->ShowLoginUI(InKeyEvent.GetUserIndex(), false, IOnlineExternalUI::FOnLoginUIClosedDelegate::CreateSP(MenuOwner, &FShooterWelcomeMenu::HandleLoginUIClosed)); bSkipToMainMenu = false; } } } } } if (bSkipToMainMenu) { const auto OnlineSub = IOnlineSubsystem::Get(); if (OnlineSub) { const auto IdentityInterface = OnlineSub->GetIdentityInterface(); if (IdentityInterface.IsValid()) { TSharedPtr<const FUniqueNetId> UserId = IdentityInterface->GetUniquePlayerId(InKeyEvent.GetUserIndex()); // If we couldn't show the external login UI for any reason, or if the user is // already logged in, just advance to the main menu immediately. MenuOwner->HandleLoginUIClosed(UserId, InKeyEvent.GetUserIndex()); } } } return FReply::Handled(); } return FReply::Unhandled(); }
FReply FSceneViewport::OnKeyDown( const FGeometry& InGeometry, const FKeyEvent& InKeyEvent ) { // Start a new reply state CurrentReplyState = FReply::Handled(); FKey Key = InKeyEvent.GetKey(); KeyStateMap.Add( Key, true ); //@todo Slate Viewports: FWindowsViewport checks for Alt+Enter or F11 and toggles fullscreen. Unknown if fullscreen via this method will be needed for slate viewports. if( ViewportClient && GetSizeXY() != FIntPoint::ZeroValue ) { // Switch to the viewport clients world before processing input FScopedConditionalWorldSwitcher WorldSwitcher( ViewportClient ); if (!ViewportClient->InputKey(this, InKeyEvent.GetUserIndex(), Key, InKeyEvent.IsRepeat() ? IE_Repeat : IE_Pressed, 1.0f, Key.IsGamepadKey())) { CurrentReplyState = FReply::Unhandled(); } } return CurrentReplyState; }
FReply FSceneViewport::OnKeyUp( const FGeometry& InGeometry, const FKeyEvent& InKeyEvent ) { // Start a new reply state CurrentReplyState = FReply::Handled(); FKey Key = InKeyEvent.GetKey(); KeyStateMap.Add( Key, false ); if( ViewportClient && GetSizeXY() != FIntPoint::ZeroValue ) { // Switch to the viewport clients world before processing input FScopedConditionalWorldSwitcher WorldSwitcher( ViewportClient ); if (!ViewportClient->InputKey(this, InKeyEvent.GetUserIndex(), Key, IE_Released, 1.0f, Key.IsGamepadKey())) { CurrentReplyState = FReply::Unhandled(); } } return CurrentReplyState; }
int32 UKismetInputLibrary::GetUserIndex(const FKeyEvent& Input) { return Input.GetUserIndex(); }