[4.7] Game focus lost on full screen launch

When launching a packaged game that forces fullscreen mode, mouse and keyboard focus is still at windows desktop until mouse is moved into game window and clicked.
This is a small annoyance on a single monitor setup, but a big issue on multi monitor or VR setup. In VR mode you will not notice the mouse moving around on your desktop.

Steps to replicate:

  1. Create a new first person project

  2. Create level blueprint: Event_begin_play > Execute console command “Fullscreen”

  3. Package game for shipping (32 bit) and launch it

If I do the same steps in UE4.6.1 and earlier the game launches in full screen mode and keyboard and mouse inputs are immediately sent to the game, and not to the desktop.

Thanks!

Hey -

I was able to reproduce your issue and have submitted a report to our internal tracking system (UE-6988) for further investigation.

Cheers

Hi ,

I just compiled the latest 4.7 engine from Github today hoping that this bug was fixed by now. While testing I noticed that this issue is not just limited to fullscreen mode. Windowed gaming is also unable to gain focus at launch.

I really hope this bug will be fixed for the final 4.7, because I don’t want to release a commercial game that launches without game focus.

Cheers,

Hey

Thanks for your concern. I can confirm that this is still being investigated by engineers as to the cause and best solution for the bug, unfortunately it’s difficult to estimate an exact time frame as to when the fix will be implemented.

Is there a work around? Kind of hard to ship a game if keyboard focus is broken on launch.

Hey -

Adding a “Set Input Mode Game Only” node on Begin Play will force the mouse and controls to the game window on launch. This will effectively overcome the “first click” issue.

Adding a Set Input Mode Game Only doesn’t work for me. Anything else to try? I have the engine source code, I could attempt to fix the code if I knew where to start. I have a VR app and I’m calling the fullscreen command in blueprints on launch if that makes any difference.

Where did you add your Set Input Mode Game Only node? Also, did you have a reference to your Player Controller connected to the Target pin? Doing so should lock the mouse to the viewport and allow immediate input of both mouse and keyboard.

OK, great that worked. Sorry, I didn’t know I had to connect the player controller. I think this is a show stopping bug. Glad there was a solution.

It works perfectly! :smiley:

Thanks a lot!

Tried this in the Driving Game sample project with 4.7.3 - it did not work. The game launches to fullscreen (-FULLSCREEN command line) but needs to be clicked once to accept gamepad inputs. I placed the Set Input Mode Game Only node as the first execution step for On Begin Play, connected the Player Controller to it and then routed that to the Delay and Play Sound at Location nodes that ship with the sample.

Hey duva-

Do you mean the Vehicle Game project in the Learn tab? Does adding the Set Input Mode Game Only node not have an effect in your project either?

Yes, this is the stock Vehicle Game project from the Learn tab with 4.7.3. Level blueprint attached.

Does the game window get initial focus when running standalone from the editor rather than running the command line? What about if you use the command ‘fullscreen’ rather than ‘r.FullScrceen 0’ in the level blueprint? Also are you running the command line of the editor project or of a packaged game?

I’ve been trying this with a packaged game: Win64 debug. I tried launching the game with -FULLSCREEN but didn’t get exclusive fullscreen which is why I put the console command in there. The game launches, goes full screen but it doesn’t accept gamepad inputs and you can see a mouse cursor. Click once and then you’re in and racing with the gamepad.

Hey duva-

Thanks for the additional information. The original report has been updated to include this info.

Cheers

This has been fixed, it should be working in 4.8.