|
Flint Engine
Modular C++20 2D game engine powered by SDL3
|
Namespace encapsulating all input polling and gamepad management. More...
Functions | |
| FLINT_API InputSnapshot | pollCurrentState () |
| Build a snapshot of the current state of all input devices. | |
| FLINT_API std::set< SDL_Keycode > | pollKeyboardState () |
| Return the set of keyboard keys that are currently held down. | |
| FLINT_API void | detectController () |
| Detect and open the first available gamepad. | |
| FLINT_API void | updateInputSource (const IWindow &window) |
| Update isControllerActive based on recent device activity. | |
| FLINT_API void | rumble (float lowFrequencyStrength, float highFrequencyStrength, Uint32 durationMs) |
| Trigger a rumble effect on the active gamepad. | |
| FLINT_API void | resetKeyboardState () |
| Reset SDL's internal keyboard state, clearing any stuck keys. | |
| FLINT_API void | shutdown () |
| Shut down the input system and release all resources. | |
| FLINT_API void | requestKeyboardRestore () |
| Schedule a one-shot keyboard state restore. | |
| FLINT_API bool | consumeKeyboardRestoreRequest () |
| Consume and return any pending keyboard-restore request. | |
Namespace encapsulating all input polling and gamepad management.
Call detectController() once at startup and updateInputSource() each frame to keep isControllerActive in sync with recent hardware activity.
| FLINT_API bool Flint::InputManager::consumeKeyboardRestoreRequest | ( | ) |
Consume and return any pending keyboard-restore request.
Returns true once for each prior call to requestKeyboardRestore(), then resets the internal flag so subsequent calls return false until a new request is made.
| FLINT_API void Flint::InputManager::detectController | ( | ) |
Detect and open the first available gamepad.
Enumerates attached controllers and opens the first one found, storing the handle in g_gamepad and setting isControllerActive to true. Safe to call when a controller is already open; the existing handle is reused.
| FLINT_API InputSnapshot Flint::InputManager::pollCurrentState | ( | ) |
Build a snapshot of the current state of all input devices.
Queries SDL directly for keyboard state and, if g_gamepad is non-null, for gamepad buttons and axes. Each call is independent of prior calls.
| FLINT_API std::set< SDL_Keycode > Flint::InputManager::pollKeyboardState | ( | ) |
Return the set of keyboard keys that are currently held down.
Convenience wrapper that ignores gamepad state.
| FLINT_API void Flint::InputManager::requestKeyboardRestore | ( | ) |
Schedule a one-shot keyboard state restore.
Sets an internal flag that is consumed by consumeKeyboardRestoreRequest(). Intended for use when an external event (e.g. focus change) requires a keyboard state refresh on the next frame. Thread-safe.
| FLINT_API void Flint::InputManager::resetKeyboardState | ( | ) |
Reset SDL's internal keyboard state, clearing any stuck keys.
Call after focus changes or synthetic input injection to ensure the next poll reflects actual hardware state.
| FLINT_API void Flint::InputManager::rumble | ( | float | lowFrequencyStrength, |
| float | highFrequencyStrength, | ||
| Uint32 | durationMs ) |
Trigger a rumble effect on the active gamepad.
Clamps both strength parameters to [0, 1], converts to the 16-bit range expected by SDL, and invokes the SDL rumble API. No-op if g_gamepad is nullptr.
| lowFrequencyStrength | Intensity of the low-frequency motor in [0, 1]. |
| highFrequencyStrength | Intensity of the high-frequency motor in [0, 1]. |
| durationMs | Duration in milliseconds. |
| FLINT_API void Flint::InputManager::shutdown | ( | ) |
Shut down the input system and release all resources.
Closes the active gamepad (if any) and clears g_gamepad. Gamepad operations become no-ops until detectController() is called again.
| FLINT_API void Flint::InputManager::updateInputSource | ( | const IWindow & | window | ) |
Update isControllerActive based on recent device activity.
Inspects keyboard, mouse, and gamepad activity this frame:
Does nothing if window is not currently open.
| window | The window whose open state gates input processing. |