class

InputManager

Module
Input
Header
#include "Input/InputManager.h"
Namespace
Mowo

Properties

TypeNameDescription
static constexpr intMaxGamepadsDefault 4.

Constructors

SignatureNameDescription
InputManager()InputManager
~InputManager()~InputManager

Public functions

ReturnsNameDescription
voidInitialize
voidShutdown
voidUpdateFrame update - call at start of each frame
boolIsKeyDown
boolIsKeyPressed
boolIsKeyReleased
boolIsKeyDown
boolIsKeyPressed
boolIsKeyReleased
boolIsShiftDown
boolIsControlDown
boolIsAltDown
boolIsMouseButtonDown
boolIsMouseButtonPressed
boolIsMouseButtonReleased
floatGetMouseX
floatGetMouseY
voidGetMousePosition
floatGetMouseDeltaX
floatGetMouseDeltaY
voidGetMouseDelta
floatGetScrollDelta
boolIsGamepadConnected
boolIsGamepadButtonDown
boolIsGamepadButtonPressed
boolIsGamepadButtonReleased
floatGetGamepadAxis
voidOnGamepadButtonDownThe platform layer addresses pads by PHYSICAL index — the slot SDL's enumeration handed the device on connect.
voidOnGamepadButtonUp
voidOnGamepadAxis
voidOnGamepadConnected
voidOnGamepadConnecteddeviceId is a stable identity for the hardware (the SDL GUID string); a pad that carries one lands in the slot the user last assigned it.
voidOnGamepadDisconnected
boolAssignGamepadSlotExplicit player-slot assignment.
intGetGamepadPhysicalIndexPhysical index feeding a logical slot, -1 when nothing is mapped there.
const std::string&GetGamepadDeviceId
voidSetGamepadSlotPreferencesPathPer-user slot preferences: <Project>/Saved/Config/InputUser.mdfb when a project is open, else the per-user product dir.
const std::string&GetGamepadSlotPreferencesPath
boolLoadGamepadSlotPreferences
boolSaveGamepadSlotPreferences
voidSetGamepadNativeHandleWindow hands the opaque SDL_Gamepad* through here so GamepadInput can drive rumble.
boolRumbleGamepadRumble — forwards to GamepadInput.
boolRumbleGamepadTriggers
voidStopGamepadRumble
voidOnGamepadSensorWindow feeds SDL_EVENT_GAMEPAD_SENSOR_UPDATE here (same device index as OnGamepadAxis); tests inject synthetic samples through it.
boolGetGamepadGyroGyro (rad/s) / accelerometer (m/s^2).
boolGetGamepadAccel
boolSetGamepadLedLight-bar colour 0..1; false when the pad has no RGB LED.
TouchInput&GetTouch
const TouchInput&GetTouch
voidOnFingerDownWindow calls these from SDL_EVENT_FINGER_* after converting normalised 0..1 coords to window pixels.
voidOnFingerMotion
voidOnFingerUp
voidOnFingerCanceled
KeyboardInput&GetKeyboard
const KeyboardInput&GetKeyboard
MouseInput&GetMouse
const MouseInput&GetMouse
GamepadInput&GetGamepad
const GamepadInput&GetGamepad
voidOnKeyDownEvent handlers - called by Window.
voidOnKeyUp
voidOnMouseButtonDown
voidOnMouseButtonUp
voidOnMouseMove
voidOnMouseScroll
voidOnMouseHorizontalScroll
voidOnCharInput
voidSetMouseDelta
voidInjectKeyDownSynthetic input for tests, automation and accessibility tooling.
voidInjectKeyUp
voidInjectMouseButtonDown
voidInjectMouseButtonUp
voidInjectMouseMove
voidInjectMouseDelta
voidInjectMouseScroll
voidInjectGamepadButtonDown
voidInjectGamepadButtonUp
voidInjectGamepadAxis
voidInjectFingerDown
voidInjectFingerUp
voidResetDeviceStateOnFocusLossFocus loss: the OS never delivers key-ups for keys held across an Alt-Tab, so every held key/button gets a synthetic release through the normal Up sinks (releases are never suppressed and triggers see a real Completed edge), and axes/deltas zero.
uint32_tGetFocusLossSerialBumped by every focus-loss reset.
const std::vector<uint32_t>&GetCharBuffer
voidSetInputModeGameplay sets the input mode when a menu opens/closes.
EInputModeGetInputMode
voidSetUIConsumedCurrentEvent"consumed" means the UI ACTED on this one event — a widget handled it, a modal or menu owned it, or the focused widget swallowed it.
boolIsGameInputSuppressed
EInputDeviceGetLastInputDeviceUpdated on every device event so a HUD can query which button-prompt family to show.
boolLastInputWasGamepad
voidSetGamepadKindPhysical index (Window calls it on connect); the family lands on the logical slot the pad resolves to.
EInputDeviceGetGamepadKind
voidSetCursorLockRequestedCursor lock request (for FPS-style mouse capture) Game code calls these, engine applies them each frame.
boolIsCursorLockRequested
boolIsCursorLockSuppressedByEscapeEngine-internal: sync pass uses this to decide whether to actually engage.
voidNotifyUserEscapedLockESC handler calls this — locks out re-engagement until the user clicks in the window or game code does an explicit lock=false → lock=true cycle.
voidNotifyUserClickedMouse click clears the escape — the next sync re-engages if the game still wants the lock.
voidSetCursorVisibleCursor visibility (separate from lock)
boolIsCursorVisibleRequested
voidSetCursorConfineMode
ECursorConfineGetCursorConfineModeThe mode the sync pass should honour: the i.CursorConfine override when it is set, else what game code asked for.
ECursorConfineGetRequestedCursorConfineMode
boolShouldConfineCursorWhat the engine's sync pass should apply this frame.
boolStartRecording
boolStopRecording
boolIsRecording
boolStartPlayback
voidStopPlayback
boolIsPlaying
boolIsPlaybackFinished
voidEndInputFrameEngine hook — called once per frame after Update() + window event pump + SetMouseDelta so the recorder's frame marker bundles every event from *this* frame.

Function details

InputManager

C++
InputManager()

~InputManager

C++
~InputManager()

Initialize

C++
void Initialize()

Shutdown

C++
void Shutdown()

Update

C++
void Update()

Frame update - call at start of each frame

IsKeyDown

C++
bool IsKeyDown(KeyCode key) const

IsKeyPressed

C++
bool IsKeyPressed(KeyCode key) const

IsKeyReleased

C++
bool IsKeyReleased(KeyCode key) const

IsKeyDown

C++
bool IsKeyDown(int vkCode) const

IsKeyPressed

C++
bool IsKeyPressed(int vkCode) const

IsKeyReleased

C++
bool IsKeyReleased(int vkCode) const

IsShiftDown

C++
bool IsShiftDown() const

IsControlDown

C++
bool IsControlDown() const

IsAltDown

C++
bool IsAltDown() const

IsMouseButtonDown

C++
bool IsMouseButtonDown(MouseButton button) const

IsMouseButtonPressed

C++
bool IsMouseButtonPressed(MouseButton button) const

IsMouseButtonReleased

C++
bool IsMouseButtonReleased(MouseButton button) const

GetMouseX

C++
float GetMouseX() const

GetMouseY

C++
float GetMouseY() const

GetMousePosition

C++
void GetMousePosition(float& x, float& y) const

GetMouseDeltaX

C++
float GetMouseDeltaX() const

GetMouseDeltaY

C++
float GetMouseDeltaY() const

GetMouseDelta

C++
void GetMouseDelta(float& dx, float& dy) const

GetScrollDelta

C++
float GetScrollDelta() const

IsGamepadConnected

C++
bool IsGamepadConnected(int index = 0) const

IsGamepadButtonDown

C++
bool IsGamepadButtonDown(GamepadButton button, int index = 0) const

IsGamepadButtonPressed

C++
bool IsGamepadButtonPressed(GamepadButton button, int index = 0) const

IsGamepadButtonReleased

C++
bool IsGamepadButtonReleased(GamepadButton button, int index = 0) const

GetGamepadAxis

C++
float GetGamepadAxis(GamepadAxis axis, int index = 0) const

OnGamepadButtonDown

C++
void OnGamepadButtonDown(int index, GamepadButton button)

The platform layer addresses pads by PHYSICAL index — the slot SDL's enumeration handed the device on connect. Every sink below translates that to the LOGICAL player slot the queries, bindings (gamepad_index) and the recorder speak; see AssignGamepadSlot.

OnGamepadButtonUp

C++
void OnGamepadButtonUp(int index, GamepadButton button)

OnGamepadAxis

C++
void OnGamepadAxis(int index, GamepadAxis axis, float value)

OnGamepadConnected

C++
void OnGamepadConnected(int index)

OnGamepadConnected

C++
void OnGamepadConnected(int index, const std::string& deviceId)

deviceId is a stable identity for the hardware (the SDL GUID string); a pad that carries one lands in the slot the user last assigned it.

OnGamepadDisconnected

C++
void OnGamepadDisconnected(int index)

AssignGamepadSlot

C++
bool AssignGamepadSlot(int currentSlot, int newSlot)

Explicit player-slot assignment. Without it the first pad plugged in is always player 1, so a couch session cannot put the host's pad on slot 2 without re-plugging in the right order. Swaps the pad in currentSlot with whatever occupies newSlot (state, native handle and family move with it) and remembers the choice per device id in the user file, so the next connect of that hardware lands in the same slot.

GetGamepadPhysicalIndex

C++
int GetGamepadPhysicalIndex(int slot) const

Physical index feeding a logical slot, -1 when nothing is mapped there.

GetGamepadDeviceId

C++
const std::string& GetGamepadDeviceId(int slot) const

SetGamepadSlotPreferencesPath

C++
void SetGamepadSlotPreferencesPath(const std::string& path)

Per-user slot preferences: <Project>/Saved/Config/InputUser.mdfb when a project is open, else the per-user product dir. Resolved lazily on the first connect so a manager created before the project loads still writes next to that project.

GetGamepadSlotPreferencesPath

C++
const std::string& GetGamepadSlotPreferencesPath() const

LoadGamepadSlotPreferences

C++
bool LoadGamepadSlotPreferences()

SaveGamepadSlotPreferences

C++
bool SaveGamepadSlotPreferences() const

SetGamepadNativeHandle

C++
void SetGamepadNativeHandle(int index, void* sdlGamepad)

Window hands the opaque SDL_Gamepad* through here so GamepadInput can drive rumble. nullptr clears (disconnect path).

RumbleGamepad

C++
bool RumbleGamepad(int index, float lowFreq, float highFreq, uint32_t durationMs)

Rumble — forwards to GamepadInput. lowFreq/highFreq in 0..1, duration in milliseconds (0 stops). Out-of-range index or unsupported pad → false.

RumbleGamepadTriggers

C++
bool RumbleGamepadTriggers(int index, float leftTrigger, float rightTrigger, uint32_t durationMs)

StopGamepadRumble

C++
void StopGamepadRumble(int index)

OnGamepadSensor

C++
void OnGamepadSensor(int index, bool gyro, float x, float y, float z)

Window feeds SDL_EVENT_GAMEPAD_SENSOR_UPDATE here (same device index as OnGamepadAxis); tests inject synthetic samples through it.

GetGamepadGyro

C++
bool GetGamepadGyro(int index, GamepadInput::SensorSample& out)

Gyro (rad/s) / accelerometer (m/s^2). The first call starts the pad's sensor stream; returns false until a pad that has the sensor delivers it. Aiming reads the gyro, the scanner/flashlight sway reads the accelerometer.

GetGamepadAccel

C++
bool GetGamepadAccel(int index, GamepadInput::SensorSample& out)

SetGamepadLed

C++
bool SetGamepadLed(int index, float r, float g, float b)

Light-bar colour 0..1; false when the pad has no RGB LED. Scanner and health state use it. i.RumbleScale does not apply.

GetTouch

C++
TouchInput& GetTouch()

GetTouch

C++
const TouchInput& GetTouch() const

OnFingerDown

C++
void OnFingerDown(uint64_t fingerId, float x, float y, float pressure)

Window calls these from SDL_EVENT_FINGER_* after converting normalised 0..1 coords to window pixels.

OnFingerMotion

C++
void OnFingerMotion(uint64_t fingerId, float x, float y, float dx, float dy, float pressure)

OnFingerUp

C++
void OnFingerUp(uint64_t fingerId, float x, float y, float pressure)

OnFingerCanceled

C++
void OnFingerCanceled(uint64_t fingerId)

GetKeyboard

C++
KeyboardInput& GetKeyboard()

GetKeyboard

C++
const KeyboardInput& GetKeyboard() const

GetMouse

C++
MouseInput& GetMouse()

GetMouse

C++
const MouseInput& GetMouse() const

GetGamepad

C++
GamepadInput& GetGamepad(int index)

GetGamepad

C++
const GamepadInput& GetGamepad(int index) const

OnKeyDown

C++
void OnKeyDown(int vkCode)

Event handlers - called by Window. When a recording is active the On* call forwards to the recorder before touching the subsystem. When a playback is active the On* call is *suppressed* — real OS events get dropped on the floor for the duration of the replay so they can't pollute the recorded state. The playback re-enters these same sinks via an internal "injecting" flag that bypasses both gates so injected events still reach the subsystems and never re-record.

OnKeyUp

C++
void OnKeyUp(int vkCode)

OnMouseButtonDown

C++
void OnMouseButtonDown(MouseButton button)

OnMouseButtonUp

C++
void OnMouseButtonUp(MouseButton button)

OnMouseMove

C++
void OnMouseMove(float x, float y)

OnMouseScroll

C++
void OnMouseScroll(float delta)

OnMouseHorizontalScroll

C++
void OnMouseHorizontalScroll(float delta)

OnCharInput

C++
void OnCharInput(uint32_t codepoint)

SetMouseDelta

C++
void SetMouseDelta(float dx, float dy)

InjectKeyDown

C++
void InjectKeyDown(int vkCode)

Synthetic input for tests, automation and accessibility tooling. An injected event lands in the device subsystems exactly like a replayed one: it bypasses the playback suppression gate and the UI-consumed gate, and is never recorded (a recording should capture the user, not the harness driving them).

InjectKeyUp

C++
void InjectKeyUp(int vkCode)

InjectMouseButtonDown

C++
void InjectMouseButtonDown(MouseButton button)

InjectMouseButtonUp

C++
void InjectMouseButtonUp(MouseButton button)

InjectMouseMove

C++
void InjectMouseMove(float x, float y)

InjectMouseDelta

C++
void InjectMouseDelta(float dx, float dy)

InjectMouseScroll

C++
void InjectMouseScroll(float delta)

InjectGamepadButtonDown

C++
void InjectGamepadButtonDown(int index, GamepadButton button)

InjectGamepadButtonUp

C++
void InjectGamepadButtonUp(int index, GamepadButton button)

InjectGamepadAxis

C++
void InjectGamepadAxis(int index, GamepadAxis axis, float value)

InjectFingerDown

C++
void InjectFingerDown(uint64_t fingerId, float x, float y, float pressure)

InjectFingerUp

C++
void InjectFingerUp(uint64_t fingerId, float x, float y, float pressure)

ResetDeviceStateOnFocusLoss

C++
void ResetDeviceStateOnFocusLoss()

Focus loss: the OS never delivers key-ups for keys held across an Alt-Tab, so every held key/button gets a synthetic release through the normal Up sinks (releases are never suppressed and triggers see a real Completed edge), and axes/deltas zero. Without this the character walks into a wall forever after a focus switch mid-WASD.

GetFocusLossSerial

C++
uint32_t GetFocusLossSerial() const

Bumped by every focus-loss reset. Anything that latches key state OUTSIDE the device bitsets (the editor fly camera keeps its own WASD flags) polls this once a frame and drops its latches when it moves — the OS never sends those key-ups either.

GetCharBuffer

C++
const std::vector<uint32_t>& GetCharBuffer() const

SetInputMode

C++
void SetInputMode(EInputMode mode)

Gameplay sets the input mode when a menu opens/closes. The platform event pump sets the per-event "UI consumed this" flag from the UI layer's return value BEFORE forwarding the event to the On* sinks below; those sinks then drop the event for gameplay when IsGameInputSuppressed() is true. Device tracking (below) still updates regardless — a suppressed gamepad press still means the player is on a gamepad.

GetInputMode

C++
EInputMode GetInputMode() const

SetUIConsumedCurrentEvent

C++
void SetUIConsumedCurrentEvent(bool consumed)

"consumed" means the UI ACTED on this one event — a widget handled it, a modal or menu owned it, or the focused widget swallowed it. It must never mean "something is focused": a HUD button that keeps focus after a click would then suppress every key the game reads for as long as it holds it. The resulting policy, per event class: key down / character suppressed only when the UI took THAT key, so a focused text box eats typing and nothing else key up / button up never suppressed (the Up sinks ignore the gate), or a key held into a focus change stays down mouse button down suppressed only when a widget handled the press; a click nobody took reaches the game mouse motion / wheel suppressed only while a widget is dragging or scrolling with it, so mouse look survives a cursor resting over the HUD gamepad the UI layer never sees pad events, so only EInputMode::UIOnly withholds them

IsGameInputSuppressed

C++
bool IsGameInputSuppressed() const

GetLastInputDevice

C++
EInputDevice GetLastInputDevice() const

Updated on every device event so a HUD can query which button-prompt family to show. The gamepad *family* (Xbox / PlayStation / Nintendo / generic) is resolved by the platform layer on connect and pushed via SetGamepadKind; per-slot until then it is GamepadGeneric.

LastInputWasGamepad

C++
bool LastInputWasGamepad() const

SetGamepadKind

C++
void SetGamepadKind(int index, EInputDevice kind)

Physical index (Window calls it on connect); the family lands on the logical slot the pad resolves to.

GetGamepadKind

C++
EInputDevice GetGamepadKind(int index) const

SetCursorLockRequested

C++
void SetCursorLockRequested(bool lock)

Cursor lock request (for FPS-style mouse capture) Game code calls these, engine applies them each frame. The "user escaped" sticky flag (set by NotifyUserEscapedLock when ESC fires) overrides game intent — even if a script calls this every Update, the engine won't re-engage the lock until the user *clicks* in the window (Unity-style "ESC frees, click re-locks"). Setting lock=false from game code clears the escape too, so a hand-off between scripts works naturally.

IsCursorLockRequested

C++
bool IsCursorLockRequested() const

IsCursorLockSuppressedByEscape

C++
bool IsCursorLockSuppressedByEscape() const

Engine-internal: sync pass uses this to decide whether to actually engage. While true, ignore m_wantCursorLock.

NotifyUserEscapedLock

C++
void NotifyUserEscapedLock()

ESC handler calls this — locks out re-engagement until the user clicks in the window or game code does an explicit lock=false → lock=true cycle.

NotifyUserClicked

C++
void NotifyUserClicked()

Mouse click clears the escape — the next sync re-engages if the game still wants the lock. Window calls this on any button-down. A click the UI took is not the click this means. In a non-modal pause screen — the default — the first press on a menu button re-engaged the lock, the cursor went back to relative mode, and the menu could not be clicked again.

SetCursorVisible

C++
void SetCursorVisible(bool visible)

Cursor visibility (separate from lock)

IsCursorVisibleRequested

C++
bool IsCursorVisibleRequested() const

SetCursorConfineMode

C++
void SetCursorConfineMode(ECursorConfine mode)

GetCursorConfineMode

C++
ECursorConfine GetCursorConfineMode() const

The mode the sync pass should honour: the i.CursorConfine override when it is set, else what game code asked for.

GetRequestedCursorConfineMode

C++
ECursorConfine GetRequestedCursorConfineMode() const

ShouldConfineCursor

C++
static bool ShouldConfineCursor(ECursorConfine mode, bool windowFocused, bool cursorLocked)

What the engine's sync pass should apply this frame. Focus is a hard gate in every mode: confining a cursor the user has alt-tabbed away from is how an application stops being closable.

StartRecording

C++
bool StartRecording(const std::string& outputPath)

StopRecording

C++
bool StopRecording()

IsRecording

C++
bool IsRecording() const

StartPlayback

C++
bool StartPlayback(const std::string& inputPath)

StopPlayback

C++
void StopPlayback()

IsPlaying

C++
bool IsPlaying() const

IsPlaybackFinished

C++
bool IsPlaybackFinished() const

EndInputFrame

C++
void EndInputFrame()

Engine hook — called once per frame after Update() + window event pump + SetMouseDelta so the recorder's frame marker bundles every event from *this* frame. No-op when not recording.

Generated from Input/InputManager.h via input.json · Nov 2, 2026Version 1.0.0