FSlateApplication::Get().IsMouseAttached() returns false in Remote Desktop

I’m trying to get the current mouse position in my c++ code. The code works well when i’m working directly on the machine with the editor. When i’m using the editor via RDP (Windows 7), it doesn’t.

FSlateApplication::Get().IsMouseAttached()

Unfortunately this snippet returns false, so no mouse position given with:

UGameViewportClient::GetMousePosition(FVector2D& MousePosition)

I just ran into this today, working in 4.12.5. I’m remoting from a windows 8 machine onto a windows 10 machine. The engine is using windows API calls to find mouse devices. What I’ve found:

  • Mouse connectivity is updated in FWindowsApplication::QueryConnectedMice()
  • GetRawInputDeviceInfoA is returning failure when called with the mouse’s device handle. In my case the first API call with a null buffer is returning a required buffer size of 2 characters, but passing a buffer of 4096 bytes to the subsequent call still results in failure. The windows documentation states this function will return -1 if the buffer isn’t big enough, but the fact that its failing with a 4k buffer is a fair indication that’s not the problem here.
  • Adding a call to GetLastError() returns 0, so no error code to go off of.
  • If you manually set bIsMouseAttached to true at the end of the function, it appears to make the mouse work as normal. Not a nice solution but it’s at least a way to unblock yourself when working over RDP.