Capycore Engine  0.1.0
A simple and lightweight game engine written in C++ based on the Unity API architecture.
Loading...
Searching...
No Matches
input_system.h
Go to the documentation of this file.
1#pragma once
2
6
7#include <map>
8
17 public:
18 [[nodiscard]] bool is_key_held(KeyCode key) const override;
19 [[nodiscard]] KeyCode get_pressed_key() const override;
20 [[nodiscard]] bool is_key_pressed(KeyCode key) const override;
21 [[nodiscard]] bool is_key_released(KeyCode key) const override;
22 [[nodiscard]] bool any_key_held() const override;
23 [[nodiscard]] bool any_key_pressed() const override;
24 [[nodiscard]] bool any_key_released() const override;
25
26 [[nodiscard]] bool is_mouse_held(MouseButton button) const override;
27 [[nodiscard]] bool is_mouse_pressed(MouseButton button) const override;
28 [[nodiscard]] bool is_mouse_released(MouseButton button) const override;
29 [[nodiscard]] bool any_mouse_held() const override;
30 [[nodiscard]] bool any_mouse_pressed() const override;
31 [[nodiscard]] bool any_mouse_released() const override;
32
33 [[nodiscard]] const Point& mouse_position() const override;
34 [[nodiscard]] std::pair<float, float> mouse_delta() const override;
35 [[nodiscard]] bool mouse_moved() const override;
36 [[nodiscard]] std::pair<float, float> mouse_scroll() const override;
37 [[nodiscard]] std::pair<float, float> mouse_scroll_delta() const override;
38 [[nodiscard]] MouseDirection mouse_scroll_direction() const override;
39
40 void reset_state() override;
41 void register_events() override;
42 void update() override;
43
44 protected:
51 std::map<KeyCode, KeyState> key_states_;
52
62};
Interface for querying low-level keyboard input.
Definition i_input_provider.h:20
SDL-backed implementation of the input provider interface.
Definition input_system.h:16
void reset_state() override
Clears all input states (useful when changing scenes or focus).
bool is_mouse_held(MouseButton button) const override
Returns whether the specified mouse button is currently held down.
bool mouse_moved() const override
Returns true if the mouse moved during the current frame.
std::map< KeyCode, KeyState > key_states_
Per-key state cache for frame-level input tracking.
Definition input_system.h:51
std::pair< float, float > mouse_delta() const override
Returns the change in mouse position since the last frame (deltaX, deltaY).
MouseDirection mouse_scroll_direction() const override
Returns the last detected scroll direction as an integer enum.
bool is_key_held(KeyCode key) const override
Returns whether the specified key is currently held down.
std::pair< float, float > mouse_scroll() const override
Returns the accumulated scroll offset along X and Y axes.
const Point & mouse_position() const override
Returns the current mouse cursor position (X, Y) in window coordinates.
bool any_key_pressed() const override
Returns true if any key was pressed this frame.
MouseState mouse_state_
Mouse state cache for frame-level input tracking.
Definition input_system.h:61
bool any_mouse_released() const override
Returns true on the frame any mouse button transitions to released.
bool is_mouse_released(MouseButton button) const override
Returns true on the frame the specified mouse button transitions to released.
bool any_key_released() const override
Returns true on the frame any key transitions to released.
bool is_mouse_pressed(MouseButton button) const override
Returns true on the frame the specified mouse button transitions to pressed.
bool is_key_pressed(KeyCode key) const override
Returns true on the frame the specified key transitions to pressed.
void update() override
Polls the underlying system for input updates.
bool any_key_held() const override
Returns true if any key is currently held down.
bool is_key_released(KeyCode key) const override
Returns true on the frame the specified key transitions to released.
void register_events() override
Registers necessary event listeners with the underlying system.
std::pair< float, float > mouse_scroll_delta() const override
Returns the scroll delta since the last frame (deltaX, deltaY).
KeyCode get_pressed_key() const override
Returns the first key pressed this frame.
bool any_mouse_pressed() const override
Returns true if any mouse button was pressed this frame.
bool any_mouse_held() const override
Returns true if any mouse button is currently held down.
Represents a point in 2D space.
Definition point.h:6
KeyCode
Definition key_code.h:5
MouseButton
Definition mouse_button.h:5
MouseDirection
Represents the primary directions of mouse wheel movement.
Definition mouse_state.h:14
Aggregates all mouse-related state information.
Definition mouse_state.h:61