Class InputManager¶
Defined in File input_manager.h
Inheritance Relationships¶
Base Type¶
public Module<>
Class Documentation¶
-
class InputManager : public Module<>¶
Cross-platform input abstraction managing keyboard and mouse state.
Provides unified access to keyboard and mouse input across all platforms. Supports both event-driven handling (via input_dispatcher events) and polling (via is_key_pressed, etc.).
Public Functions
-
InputManager(ModuleStack &stack, entt::dispatcher &engine_dispatcher, entt::dispatcher &input_dispatcher)¶
Constructs the InputManager and initializes input state tracking.
- Parameters:
stack – Module system integration
engine_dispatcher – Engine-level events (e.g., SetMouseCursorEvent to Window)
input_dispatcher – Input events (KeyPressedEvent, MouseMovedEvent, etc.)
-
bool is_key_pressed(Key key) const¶
Checks if a key is currently down (Pressed or Repeat state).
Returns true for both initial press and held keys. For initial press only, use:
is_key_pressed(key) && !is_key_repeating(key)- Parameters:
key – Keyboard key or mouse button to check
- Returns:
true if key is currently down
-
bool is_key_released(Key key) const¶
Checks if a key is currently up (Released state).
- Parameters:
key – Keyboard key or mouse button to check
- Returns:
true if key is not currently down
-
bool is_key_repeating(Key key) const¶
Checks if a key is in Repeat state (held from previous frame).
Useful for distinguishing initial press from continued hold.
- Parameters:
key – Keyboard key or mouse button to check
- Returns:
true if key is being held down
-
inline glm::vec2 get_mouse_position() const¶
Gets the current mouse position in window coordinates.
- Returns:
Mouse position (x, y) with (0,0) at top-left
-
inline glm::vec2 get_mouse_scroll() const¶
Gets the most recent mouse scroll offset (not accumulated).
- Returns:
Scroll offset (x = horizontal, y = vertical)
-
void report_key_action(ReportKeyActionEvent event)¶
Reports a key state change from platform layer (Window implementations only).
Updates internal state and dispatches KeyPressedEvent/KeyReleasedEvent/KeyRepeatEvent.
- Parameters:
event – Contains key, state, and active modifiers
-
void report_axis_change(ReportAnalogAxisEvent event)¶
Reports analog axis change from platform layer (Window implementations only).
Updates cached values and dispatches MouseMovedEvent/MouseScrolledEvent.
- Parameters:
event – Contains axis (Mouse or MouseScroll) and value
-
void set_cursor_mode(CursorMode mode) const¶
Requests cursor mode change via SetMouseCursorEvent.
Modes: Normal (visible), Hidden (invisible but free), Locked (invisible and confined). When locked, mouse position is fixed at the window center.
- Parameters:
mode – Desired cursor mode
-
InputManager(ModuleStack &stack, entt::dispatcher &engine_dispatcher, entt::dispatcher &input_dispatcher)¶