Skip to main content

InputSnapshot.ixx File

Immutable snapshot of input state at a specific point in time. More...

Included Headers

Namespaces Index

namespacehelios
namespaceinput

Input handling and management. More...

Classes Index

classInputSnapshot

Immutable snapshot capturing input state at a specific point in time. More...

Description

Immutable snapshot of input state at a specific point in time.

File Listing

The file content with the documentation metadata removed is:

1/**
2 * @file InputSnapshot.ixx
3 * @brief Immutable snapshot of input state at a specific point in time.
4 */
5module;
6
7
8export module helios.input.InputSnapshot;
9
10import helios.input.gamepad.GamepadState;
11
12export namespace helios::input {
13
14 /**
15 * @brief Immutable snapshot capturing input state at a specific point in time.
16 *
17 * @details InputSnapshot decouples input polling from input processing by capturing
18 * the complete input state at a single moment. This immutable design enables deterministic
19 * replay where snapshots can be recorded and replayed exactly, network synchronization by
20 * transmitting snapshots to remote clients, frame-consistent processing where all systems
21 * see identical input state, and multi-threaded safety as snapshots can be shared across
22 * threads without locking.
23 *
24 * The current implementation captures only gamepad input. Future versions may extend
25 * this to include keyboard, mouse, and other input devices.
26 *
27 * Typical usage:
28 * ```cpp
29 * // Capture input at start of frame
30 * auto snapshot = helios::input::InputSnapshot(
31 * inputManager.gamepadState(helios::input::types::Gamepad::ONE)
32 * );
33 *
34 * // Process input (potentially in parallel or deferred)
35 * inputHandler.handleInput(snapshot, player, commandBuffer, deltaTime);
36 * ```
37 *
38 * @note The snapshot is immutable after construction and reflects input state at
39 * construction time. Currently only supports a single gamepad; multi-input
40 * support is planned.
41 *
42 * @todo Extend to support multiple gamepads, keyboard, and mouse input.
43 * @todo Add timestamp to enable precise replay and network synchronization.
44 */
46
47 /**
48 * @brief Captured gamepad state.
49 *
50 * @details Stored as a const member to enforce immutability of the snapshot.
51 */
52 const helios::input::gamepad::GamepadState gamepadState_;
53
54 public:
55
56 /**
57 * @brief Constructs an InputSnapshot capturing the current gamepad state.
58 *
59 * @param gamepadState The gamepad state to capture. Copied into the snapshot.
60 *
61 * @note This operation is noexcept and cheap as GamepadState is a small struct.
62 * The snapshot remains valid even if the source state is modified or destroyed.
63 */
65 : gamepadState_(gamepadState) {
66 }
67
68 /**
69 * @brief Returns the captured gamepad state.
70 *
71 * @return Const reference to the captured GamepadState, valid for the lifetime
72 * of this InputSnapshot. The state is immutable and reflects input at
73 * the time of snapshot creation.
74 */
75 [[nodiscard]] const helios::input::gamepad::GamepadState& gamepadState() const noexcept {
76 return gamepadState_;
77 }
78 };
79
80}

Generated via doxygen2docusaurus 2.0.0 by Doxygen 1.15.0.