Mouse axis is not captured without holding a mouse button

Hi!
Remember a strategy game like AoE, you got a mouse cursor for ui and the game at the same time.

In the PlayerController I set the input mode to FInputModeGameAndUI with begin play. When I start the game, I catch the mouse x axis event and have it do sth when not 0 - you will see, it is always zero unless the left or right mouse button is pressed.

When I change the input mode to FInputModeGameOnly, the mouse axes are captured on starting the game until I hit the left or right mouse button. The mouse axes are returning zero again. This can be circumvented with setting the input mode once again after releasing a mouse button. Unfortunately to this solution, I don’t have input on my UI anymore. Edit: The “show mouse cursor” flag is actually the cause (I’ve set it via code) - having it false, a mouseclick does not make it stop receiving input anymore.


Project Settings → Engine → Input → Viewport Properties seem to be ignored completely, the behavior doesn’t change on any setup there.

You can also check in code for GetWorld()->GetGameViewport()->Viewport->HasMouseCapture(), it gets false as soon as you click the viewport and I just don’t know how to bring it back to capturing.


Some other posts to the issue that never found a solution:

  • [438627 capture mouse xy movement deltas without requiring InputAction(s)][3]
  • [288211 get input mouse delta is always 0 if no mouse button is pressed][4]
  • [385 mouse axes are zero when there is no mouse press][5]
  • [404679 how to return mouse control without clicking the screen][6]
3 Likes

did you ever find a solution ??

1 Like

some relevant answers here
https://answers.unrealengine.com/questions/32550/showing-mouse-cursor-stops-input-from-mouse-axis.html
https://answers.unrealengine.com/questions/395313/view.html
https://answers.unrealengine.com/questions/260284/mousex-bindaxis-returning-0-unless-mouse-button-de.html

2 Likes