Class Input
Input handling system for keyboard, mouse, and viewport state.More...
#include <Input.h>
Classes
| Type | Name |
|---|---|
| struct | InputState Combined input state snapshot. |
| struct | KeyState Keyboard state snapshot. |
| struct | MouseState Mouse state snapshot. |
| struct | RandomState Global random value state for random algorithms. |
Public Types
| Type | Name |
|---|---|
| enum int | MouseButtons Mouse button identifiers. |
| enum | SpecialKeys Special modifier keys (Shift, Ctrl, Alt). |
Public Functions
| Type | Name |
|---|---|
| void | UpdateState (GLFWwindow * window) const Updates input state snapshot from GLFW. |
Public Static Functions
| Type | Name |
|---|---|
| float | GetDeltaMouseX () Returns mouse X delta since last frame. |
| float | GetDeltaMouseY () Returns mouse Y delta since last frame. |
| const InputState | GetInputState () Returns current input state snapshot. |
| float | GetMousePosX () Returns current mouse X position. |
| float | GetMousePosY () Returns current mouse Y position. |
| const RandomState | GetRandomState () |
| float | GetScrollX () Returns horizontal scroll delta. |
| float | GetScrollY () Returns vertical scroll delta. |
| bool | IsKeyClicked () Checks if any key was just pressed (transition from up to down). |
| bool | IsKeyLeft () Checks if key was just released (transition from down to up). |
| bool | IsKeyPressed () Checks if any key is currently held down. |
| bool | IsKeyPressed (SpecialKeys spe_key) Checks if a specific special key is pressed. |
| bool | IsMouseClicked () Checks if any mouse button was just clicked. |
| bool | IsMouseLeft () Checks if mouse button was just released. |
| bool | IsMousePressed () Checks if any mouse button is currently held down. |
| bool | IsMousePressed (MouseButtons button) Checks if specific mouse button is pressed. |
| bool | IsMouseScrolled () Checks if mouse scroll changed this frame. |
| constexpr int | NormalKeyFromChar (char key) Converts character to normal key index. |
| KeyState | ParseKeyState (const std::string & hotkey) Parses a hotkey string into KeyState . |
Detailed Description
Input captures both user and system input state each frame, providing a consistent interface for querying input changes. It supports: * Keyboard: Individual keys + special modifiers (Shift, Ctrl, Alt) * Mouse: Buttons (LMB, RMB, MMB), position, delta, scroll * Random: Global random state for algorithms
State Management: * input_state: Current frame state * input_state_b: Previous frame state * Delta detection via state comparison
Common Patterns: * IsKeyPressed(): Key held down this frame * IsKeyClicked(): Key just pressed (transition) * IsMousePressed(button): Mouse button held * GetDeltaMouseX/Y(): Mouse movement since last frame
Public Types Documentation
enum MouseButtons
Mouse button identifiers.
enum Input::MouseButtons {
NONE,
LMB = 1,
RMB,
MMB
};
enum SpecialKeys
Special modifier keys (Shift, Ctrl, Alt).
enum Input::SpecialKeys {
NONE = 0,
SHIFT = 1 << 0,
CTRL = 1 << 1,
ALT = 1 << 2
};
Public Functions Documentation
function UpdateState
Updates input state snapshot from GLFW.
void Input::UpdateState (
GLFWwindow * window
) const
Captures current keyboard, mouse, and window state from GLFW. Swaps current → previous for delta detection.
Parameters:
windowGLFW window handle for input polling
Note:
Must be called once per frame before input queries
Public Static Functions Documentation
function GetDeltaMouseX
Returns mouse X delta since last frame.
static float Input::GetDeltaMouseX ()
Returns:
Delta X in pixels
function GetDeltaMouseY
Returns mouse Y delta since last frame.
static float Input::GetDeltaMouseY ()
Returns:
Delta Y in pixels
function GetInputState
Returns current input state snapshot.
static inline const InputState Input::GetInputState ()
Returns:
Current InputState
Note:
Provides read-only access to input state for queries
function GetMousePosX
Returns current mouse X position.
static float Input::GetMousePosX ()
Returns:
Mouse X in screen space
function GetMousePosY
Returns current mouse Y position.
static float Input::GetMousePosY ()
Returns:
Mouse Y in screen space
function GetRandomState
static inline const RandomState Input::GetRandomState ()
function GetScrollX
Returns horizontal scroll delta.
static float Input::GetScrollX ()
Returns:
Scroll X delta
function GetScrollY
Returns vertical scroll delta.
static float Input::GetScrollY ()
Returns:
Scroll Y delta
function IsKeyClicked
Checks if any key was just pressed (transition from up to down).
static bool Input::IsKeyClicked ()
Returns:
true if key clicked this frame
function IsKeyLeft
Checks if key was just released (transition from down to up).
static bool Input::IsKeyLeft ()
Returns:
true if key released this frame
function IsKeyPressed [1/2]
Checks if any key is currently held down.
static bool Input::IsKeyPressed ()
Returns:
true if key pressed
function IsKeyPressed [2/2]
Checks if a specific special key is pressed.
static bool Input::IsKeyPressed (
SpecialKeys spe_key
)
Parameters:
spe_keySpecial key to check (Shift, Ctrl, Alt)
Returns:
true if special key is pressed
function IsMouseClicked
Checks if any mouse button was just clicked.
static bool Input::IsMouseClicked ()
Returns:
true if mouse button clicked this frame
function IsMouseLeft
Checks if mouse button was just released.
static bool Input::IsMouseLeft ()
Returns:
true if button released this frame
function IsMousePressed [1/2]
Checks if any mouse button is currently held down.
static bool Input::IsMousePressed ()
Returns:
true if mouse button pressed
function IsMousePressed [2/2]
Checks if specific mouse button is pressed.
static bool Input::IsMousePressed (
MouseButtons button
)
Parameters:
buttonMouse button to check (LMB, RMB, MMB)
Returns:
true if button is pressed
function IsMouseScrolled
Checks if mouse scroll changed this frame.
static bool Input::IsMouseScrolled ()
Returns:
true if scroll delta is non-zero
function NormalKeyFromChar
Converts character to normal key index.
static inline constexpr int Input::NormalKeyFromChar (
char key
)
Maps 'a'-'z' (case-insensitive) to 1-26.
Parameters:
keyCharacter to convert
Returns:
Key index (1-36)
function ParseKeyState
Parses a hotkey string into KeyState .
static KeyState Input::ParseKeyState (
const std::string & hotkey
)
Supports format: "Ctrl+S", "Alt+F4", "Shift+A", etc.
Parameters:
hotkeyHotkey string to parse
Returns:
KeyState representing the hotkey
The documentation for this class was generated from the following file src/editor/Input.h