InputPlayback
Reads a .mirec file produced by InputRecorder and replays its events into InputManager one frame at a time. The full event stream is read into a std::vector at Load() time — recordings are small (KB to single-digit MB for long sessions), so streaming from disk during gameplay would only add hitch risk for no real memory win.
- Module
- Input
- Header
#include "Input/InputPlayback.h"- Namespace
Mowo
Public functions
| Returns | Name | Description |
|---|---|---|
bool | Load | Loads path into memory and parses the header. |
void | Stop | Aborts playback. |
bool | IsActive | |
bool | IsFinished | True when the read cursor has reached the end of the stream. |
uint64_t | FrameCount | |
uint64_t | EventCount | |
uint64_t | CurrentFrame | |
void | InjectFrame | Replays every event up to and including the next FrameMarker into the given InputManager. |
Function details
Load
bool Load(const std::string& path)Loads path into memory and parses the header. Returns false if the file can't be opened, is shorter than the header, or has wrong magic / unsupported version. On failure the playback is left inactive so a subsequent Load() can retry.
Stop
void Stop()Aborts playback. Safe to call when not active.
IsActive
bool IsActive() constIsFinished
bool IsFinished() constTrue when the read cursor has reached the end of the stream. Hosts can poll this to auto-stop or loop. Becomes true after the last frame's events have been injected by InjectFrame(). True once the stream ended for ANY reason — natural end-of-data OR an abort (truncated file, unknown tag). The old m_active gate made an aborted playback read as never-finished, and hosts looping on !IsFinished() hung forever.
FrameCount
uint64_t FrameCount() constEventCount
uint64_t EventCount() constCurrentFrame
uint64_t CurrentFrame() constInjectFrame
void InjectFrame(InputManager& mgr)Replays every event up to and including the next FrameMarker into the given InputManager. Each call advances exactly one recorded frame — matched 1:1 with InputManager::Update(). When the stream is finished becomes a no-op (so a stuck playback won't crash the game loop).