Mouse capture works as expected when in full screen mode, but when windowed, it doesn’t fully capture.
In Widowed mode, the mouse turns invisible as expected and I can play the game normally, but if I move the mouse quickly and use the left mouse button, I am able to click on things in my desktop. Worsening the situation clicking on anything in the desktop will make the game lose focus and the windows mouse cursor to appear.
Doing some testing, I can see that in windowed mode the mouse is still moving, albeit invisible, and the game tries to keep the mouse within the confines of the window., but it’s not perfect and moving the mouse very quickly can get the mouse momentarily out of the window.
I’m on UE 5.1.
This is a Lyra-based project so all the mouse capturing settings seem generally correct. In the project settings I can see I have Capture Mouse On Launched enabled, and Default Viewport Mouse Capture Mode to “Capture Mouse Permanently Including Initial Mouse Down”.
I do use “SetInputModeGameOnly” in my character blueprint as well.
Any ideas why this would be? Is it a limitation using Unreal?
Ok, I figured it out. Seems like a bug to me. When not in fullscreen mode, we use a borderless window and in the Engine in SlateUser.cpp , the function LockCursorInternal has the following code: const int32 ClipRectAdjustment = bIsBorderlessGameWindow ? 0 : 1;
which allows the OS cursor to become visible at the margins of the game window and allows players to click on the desktop.
Changing it to: const int32 ClipRectAdjustment = 1;
fixed the issue for us.
windowed capture behaving different from fullscreen is expected, in windowed mode the OS still owns the pointer outside your client rect, so fast flicks escape before the game re-centers it. lyra just exposes the engine default here.
if you need the cursor hard confined to the game window on a windowed build, thats an OS level clip, not an input mode. Kiosk Lockdown Toolkit is a kiosk mode plugin for Unreal Engine 5 that confines the mouse to the game window or to one monitor of a multi screen setup, from blueprint: Kiosk Lockdown Toolkit — Block Alt+Tab, Win Key & Taskbar for Kiosks | Fab
for gameplay-only capture though, Set Input Mode Game Only plus hide cursor during play is usually enough, the hard clip is for public screens where the mouse must never leave.