InputRecorder
Captures raw input events into an in-memory buffer and flushes the buffer to disk on Stop(). Buffering avoids any file-I/O cost during gameplay — a 10-minute session at 60 fps with heavy input is well under 10 MB so the memory pressure is negligible. The recorder is owned by InputManager and receives forwarded events from the public On* sinks.
- Module
- Input
- Header
#include "Input/InputRecorder.h"- Namespace
Mowo
Frame boundaries are explicit: InputManager calls EndFrame() once per game frame, which writes a FrameMarker into the stream. The marker is what playback uses to advance frame-by-frame, so missing one collapses two recorded frames into one on replay.
Public functions
| Returns | Name | Description |
|---|---|---|
bool | Start | Starts buffering. |
bool | Stop | Flushes the buffer to disk. |
bool | IsActive | |
uint64_t | FrameCount | Frame counter incremented each EndFrame(). |
uint64_t | EventCount | |
void | OnKeyDown | Event sinks — called by InputManager when this recorder is active. |
void | OnKeyUp | |
void | OnCharInput | |
void | OnMouseButtonDown | |
void | OnMouseButtonUp | |
void | OnMouseMove | |
void | OnMouseScroll | |
void | OnMouseHorizontalScroll | |
void | OnMouseDelta | |
void | OnGamepadButtonDown | |
void | OnGamepadButtonUp | |
void | OnGamepadAxis | |
void | OnGamepadConnected | |
void | OnGamepadDisconnected | |
void | OnFingerDown | |
void | OnFingerMotion | |
void | OnFingerUp | |
void | OnFingerCanceled | |
void | EndFrame | Closes the current frame. |
Function details
Start
bool Start(const std::string& outputPath)Starts buffering. Returns false if outputPath resolves to a directory that doesn't exist (we don't auto-create). Existing files are silently overwritten on Stop().
Stop
bool Stop()Flushes the buffer to disk. Safe to call when not recording (no-op). Returns true if a file was written (i.e. Start() had been called).
IsActive
bool IsActive() constFrameCount
uint64_t FrameCount() constFrame counter incremented each EndFrame(). 0 before the first marker is written, so the count matches "number of frames fully captured".
EventCount
uint64_t EventCount() constOnKeyDown
void OnKeyDown(int vkCode)Event sinks — called by InputManager when this recorder is active. All record raw values, untouched (e.g. mouse positions stay in pixels, gamepad axes are pre-deadzone). Playback re-injects via the same sinks.
OnKeyUp
void OnKeyUp(int vkCode)OnCharInput
void OnCharInput(uint32_t codepoint)OnMouseButtonDown
void OnMouseButtonDown(MouseButton button)OnMouseButtonUp
void OnMouseButtonUp(MouseButton button)OnMouseMove
void OnMouseMove(float x, float y)OnMouseScroll
void OnMouseScroll(float delta)OnMouseHorizontalScroll
void OnMouseHorizontalScroll(float delta)OnMouseDelta
void OnMouseDelta(float dx, float dy)OnGamepadButtonDown
void OnGamepadButtonDown(int index, GamepadButton button)OnGamepadButtonUp
void OnGamepadButtonUp(int index, GamepadButton button)OnGamepadAxis
void OnGamepadAxis(int index, GamepadAxis axis, float value)OnGamepadConnected
void OnGamepadConnected(int index)OnGamepadDisconnected
void OnGamepadDisconnected(int index)OnFingerDown
void OnFingerDown(uint64_t fingerId, float x, float y, float pressure)OnFingerMotion
void OnFingerMotion(uint64_t fingerId, float x, float y, float dx, float dy, float pressure)OnFingerUp
void OnFingerUp(uint64_t fingerId, float x, float y, float pressure)OnFingerCanceled
void OnFingerCanceled(uint64_t fingerId)EndFrame
void EndFrame()Closes the current frame. InputManager calls this once per Update tick.