How to reliably detect any input

The problem I want to solve:

  • Players who are AFK should be kicked from the game.

  • I have a timer to kick the player from a multiplayer game if they are AFK. Currently, it has a hook in the MyGamePlayerController to report input to the timer, which then resets itself.

  • However, if (for example) the pause menu is open, the timer does not get reset on input. The controller schemes are complicated, and often changing, and also there are several blueprints which may consume input.

  • I would ideally like a low-level solution to simply detect input, or read the raw state of the inputs. Does anything exist that I can use?

Thanks,

Arkady.

Player Controllers have a set of functions that allow you to check raw input, and you can check with FKey::AnyKey to get any input at all.

In the player controller, use IsInputKeyDown(FKey), WasInputKeyJustPressed(FKey), GetInputMouseDelta(floatX, floatY), and the other related functions to do your desired AFK detection.

If you want to check only keys that have related Action bindings, you’ll need to have your player controller bind to those and not consume input. They should get input before most other blueprints, but you may still have to sort out your input consumption priorities with other conflicting blueprints.