Was looking for the same thing.
Usually input is pumped from the Messages Queues. Input (especially keyboard input) will only be placed in the queue of the focused application.
To retrieve events if the application is not focused, you can register hooks.
Though the hooks I was able to register did not work for me when the application was in the background.
Never the less I was looking for events from my XBox controller, and the hooks did not even catch those when the application was in the foreground.
When you use the RawInput plugin, you can fix it by copying the plugin to your project and changing the code:
FRawInputWindows::FRawInputWindows(const TSharedRef<FGenericApplicationMessageHandler>& InMessageHandler)
// Register a default device if desired
const uint32 Flags = RIDEV_INPUTSINK;//0; ** // CHANGE HERE**
const int32 PageID = 0x01;
int32 DeviceID = 0x04;
DefaultDeviceHandle = RegisterInputDevice(RIM_TYPEHID, Flags, DeviceID, PageID);
For the Flags, see here: https://docs.microsoft.com/en-us/win…rawinputdevice
When running the Editor:
The editor has performance throttels when in the background which can cause problems with the input even though the input should be queued by the system (?!?!).
1: One severe when the editor is minimized: hard throtteling to 3FPS.
To fix it you need to create a custom UUnrealEdEngine and register it in DefaultEngine.ini config file.
Then in the custom UUnrealEdEngine override:
// We want the engine to always run full performance
virtual bool ShouldThrottleCPUUsage() const override
2: The second causes a 5ms sleep when in background and can only be fixed with a custom engine
Remove or change the code
if( HadFocus && !HasFocus )
// Drop our priority to speed up whatever is in the foreground.
SetThreadPriority( GetCurrentThread(), THREAD_PRIORITY_BELOW_NORMAL );
else if( HasFocus && !HadFocus )
// Boost our priority back to above normal as initially set in WindowsRunnableThread::CreateInternal.
SetThreadPriority( GetCurrentThread(), THREAD_PRIORITY_ABOVE_NORMAL );
if( !HasFocus )
// Sleep for a bit to not eat up all CPU time.
HadFocus = HasFocus;