I’m working on input handling in my game and i’m facing an unexpected behavior when GameViewport looses the focus (either when i alt+tab outside the game windows or when i give focus to any of my UMG widget)
void UGameViewportClient::LostFocus(FViewport* InViewport)
calls
PlayerController->FlushPressedKeys();
that clears out any pressed input (keyboard key and gamepad button)
void UGameViewportClient::ReceivedFocus(FViewport* InViewport)
Does not refresh which keys and gamepad buttons are currently pressed…
I want my Character to crouch only when the player hold a button so i’m listening to IE_Pressed / IE_Released to toggle crouch but UGameViewportClient::LostFocus calls IE_Released on everything even if the key is still down.
If i hold “crouch”, open a menu and come back to the game the crouch button is considered as released even if it is still down, I must release and press it again to get my character crouched.
Is there a way to force PlayerInput to refresh its keydown when UGameViewportClient receive focus again ?