[ue 4.5-pre] PlayerController->GetMousePosition returns false

PlayerController->GetMousePosition function returns false as if no attached mouse device was detected.
Same code works fine in 4.4

UE version: src CL 2306883 by Marsh in 4.5 branch

Hi TimGS,

Just a real quick check. When you noticed that you were getting false returned, was your mouse positioned outside of the game window? The mouse position check has been changed in 4.5 and now returns false if the mouse is outside of the game window. I did a quick test of the GetMousePosition function in PlayerController, and in 4.4 it always returned true, but in 4.5 it only returned true if the mouse was inside the game window.

Hey, . It always returns false for me no matter where mouse is. It returns false even in Fullscreen mode.

UPDATE: I added some logging check for every part of if statement in UGameViewportClient::GetMousePosition(FVector2D& MousePosition):

if (Viewport && bMouseOverViewport && FSlateApplication::Get().IsMouseAttached())

and yes, the only one that’s FALSE is bMouseOverViewport. It’s strange because it’s false even when I’m hitting my buttons inside viewport so I’m sure mouse is in it…

UPDATE 2: I just downloaded and compiled latest 4.5-branch and function works. I forgot to mention that I made a small edit in source code in WindowsCursor.cpp which loads my custom .cur files (which works perfectly and mouse style changes). So it gives me 2 options why it returns true in fresh build and false in older one:

  • it has something to do with latest commits
  • it has something to do with my edit
    I’ll continue research and see.

I synced my fork to the latest 4.5-branch and now everything works. Seems like it was the 1st option. Lucky me. =)