Game
Wiki page
Input Management
How to handle keyboard and mouse input using the InputManager.
Overview
The InputManager provides a unified interface for polling keyboard and mouse state. You can access it via the global Engine instance.
auto& engine = Public::Engine::getInstance();
Public::Input::InputManager& inputManager = engine.GetInputManager();Keyboard Input
Checking Key States
IsKeyDown(keyCode): Returns true if the key is currently held down.GetKeyDown(keyCode): Returns true only on the frame the key was pressed.
using namespace Public::Input;
if (inputManager.IsKeyDown(Key::Code::W)) {
// Move forward
}
if (inputManager.GetKeyDown(Key::Code::Space)) {
// Jump (trigger once)
}Mouse Input
Mouse State
You can retrieve the current mouse position and delta (movement since last frame).
MouseState mouse = inputManager.GetMouseState();
float yaw = mouse.deltaX * sensitivity;
float pitch = mouse.deltaY * sensitivity;Cursor Control
The InputManager allows you to lock and hide the cursor, which is essential for first-person camera controls.
inputManager.LockCursor(); // Locks to center and hides
inputManager.UnlockCursor(); // Restores normal behavior