InputManager
Class handling all GLUT interaction events (mouse and keyboard) and starting the label editor. More...
#include "Core/Input/InputManager.h"
Public Types
| Name | |
|---|---|
| enum | KeyState { UP, JUST_UP, DOWN, JUST_DOWN} |
Public Functions
| Name | |
|---|---|
| void | addInputController(InputController * controller) |
| bool | areModifiersActive(const Modifiers mods) |
| void | beginFrame()<br>Updates mouse position and buttons. |
| void | bindGlobalAction(const char * action, EKeyState state, KeyCallback fn) |
| Modifiers | createModifiers(ModifiersList & list)<br>If you change order of modifiers, change it also in InputManager::areModifiersActive function. |
| void | endFrame()<br>Updates the stored statuses of the keys in the keyMap array (JUST_UP -> UP, JUST_DOWN -> DOWN). |
| glm::vec2 | getMouseDelta() |
| glm::vec2 | getMousePos() |
| void | init() |
| bool | isActionTriggered(const char * name, EKeyState state) |
| bool | isAxisActive(const char * name) |
| bool | isInputActive(const WPtr< InputController > & input)<br>Check if the specified input controller is active. |
| bool | isKeyJustPressed(const Keys::Code code) |
| bool | isKeyJustUp(const Keys::Code code) |
| bool | isKeyPressed(const Keys::Code code) |
| bool | isMouseClicked() |
| bool | isMouseDown() |
| void | keyDown(int keyPressed)<br>Helper function for handling pressed keys. |
| void | keyUp(int keyReleased)<br>Helper function for handling released keys. |
| void | setActiveInput(const WPtr< InputController > & input)<br>Set active input controller (for focused window). |
| void | setInputAction(const char * action, Keys::Code code, ModifiersList mods =ModifiersList()) |
| void | setInputAxis(const char * action, float scale, Keys::Code code, ModifiersList mods =ModifiersList()) |
| void | setPressed(const Keys::Code code)<br>Sets an entry in the keyMap to justPressed (JUST_DOWN) |
| void | setUnpressed(const Keys::Code code) |
| void | triggerAction(const char * action, EKeyState state) |
Public Attributes
| Name | |
|---|---|
| bool | m_ignoreImGuiEvents |
| std::map< Keys::Code, KeyState > | m_keyMap <br>States of all keys, modifiers, and mouse buttons - enum value KeyState. |
| float | m_mouseWheelOffset <br>Immediate mouse scroll change. |
| float | m_mouseX |
| float | m_mouseXDelta |
| float | m_mouseXDragDelta |
| float | m_mouseXPrev |
| float | m_mouseY <br>Current mouse cursor position in screen coordinates (0 is corner of the monitor) |
| float | m_mouseYDelta <br>Change of the cursor position across last two frames. |
| float | m_mouseYDragDelta <br>Same as mouse delta but only non-zero during some mouse press. |
| float | m_mouseYPrev <br>Previous frame's cursor position. |
Detailed Description
class InputManager;Class handling all GLUT interaction events (mouse and keyboard) and starting the label editor.
This class stores state of all keys and mouse buttons in a map keyMap - used for controlling all interaction. It also updates the stored statuses of the keys from JUST pressed/released to pressed/release. The update() is called regularly from the end of main.cpp: logicUpdate()
Public Types Documentation
enum KeyState
| Enumerator | Value | Description |
|---|---|---|
| UP | ||
| JUST_UP | ||
| DOWN | ||
| JUST_DOWN |
Public Functions Documentation
function addInputController
static inline void addInputController(
InputController * controller
)function areModifiersActive
static bool areModifiersActive(
const Modifiers mods
)function beginFrame
static void beginFrame()Updates mouse position and buttons.
function bindGlobalAction
static void bindGlobalAction(
const char * action,
EKeyState state,
KeyCallback fn
)function createModifiers
static Modifiers createModifiers(
ModifiersList & list
)If you change order of modifiers, change it also in InputManager::areModifiersActive function.
function endFrame
static void endFrame()Updates the stored statuses of the keys in the keyMap array (JUST_UP -> UP, JUST_DOWN -> DOWN).
Processes events.
function getMouseDelta
static inline glm::vec2 getMouseDelta()function getMousePos
static inline glm::vec2 getMousePos()function init
static void init()function isActionTriggered
static bool isActionTriggered(
const char * name,
EKeyState state
)function isAxisActive
static bool isAxisActive(
const char * name
)function isInputActive
static bool isInputActive(
const WPtr< InputController > & input
)Check if the specified input controller is active.
Window input controller will be active when the window is focused.
function isKeyJustPressed
static inline bool isKeyJustPressed(
const Keys::Code code
)function isKeyJustUp
static inline bool isKeyJustUp(
const Keys::Code code
)function isKeyPressed
static inline bool isKeyPressed(
const Keys::Code code
)function isMouseClicked
static bool isMouseClicked()Return: Whether any of the mouse buttons was clicked
function isMouseDown
static bool isMouseDown()Return: Whether any of the mouse buttons is pressed
function keyDown
static void keyDown(
int keyPressed
)Helper function for handling pressed keys.
Parameters:
- keyPressed The key pressed.
function keyUp
static void keyUp(
int keyReleased
)Helper function for handling released keys.
Parameters:
- keyReleased The key released.
function setActiveInput
static void setActiveInput(
const WPtr< InputController > & input
)Set active input controller (for focused window).
function setInputAction
static void setInputAction(
const char * action,
Keys::Code code,
ModifiersList mods =ModifiersList()
)function setInputAxis
static void setInputAxis(
const char * action,
float scale,
Keys::Code code,
ModifiersList mods =ModifiersList()
)function setPressed
static inline void setPressed(
const Keys::Code code
)Sets an entry in the keyMap to justPressed (JUST_DOWN)
Parameters:
- code The enum code of the key.
function setUnpressed
static inline void setUnpressed(
const Keys::Code code
)function triggerAction
static void triggerAction(
const char * action,
EKeyState state
)Public Attributes Documentation
variable m_ignoreImGuiEvents
static bool m_ignoreImGuiEvents = false;variable m_keyMap
static std::map< Keys::Code, KeyState > m_keyMap;States of all keys, modifiers, and mouse buttons - enum value KeyState.
Todo: passed to all handlers, but probably not used
changed in update()
variable m_mouseWheelOffset
static float m_mouseWheelOffset = 0;Immediate mouse scroll change.
variable m_mouseX
static float m_mouseX = 0;variable m_mouseXDelta
static float m_mouseXDelta = 0;variable m_mouseXDragDelta
static float m_mouseXDragDelta = 0;variable m_mouseXPrev
static float m_mouseXPrev = 0;variable m_mouseY
static float m_mouseY = 0;Current mouse cursor position in screen coordinates (0 is corner of the monitor)
variable m_mouseYDelta
static float m_mouseYDelta = 0;Change of the cursor position across last two frames.
variable m_mouseYDragDelta
static float m_mouseYDragDelta = 0;Same as mouse delta but only non-zero during some mouse press.
variable m_mouseYPrev
static float m_mouseYPrev = 0;Previous frame's cursor position.
Updated on 2026-09-11 at 21:24:25 +0000