#pragma once #include "evo/client/camera.hpp" #include #include #include #include namespace evo::client { // `brake` (rules 12) opposes the cell's velocity relative to the liquid while held. enum class Key : std::uint8_t { left, right, up, down, pan_left, pan_right, pan_up, pan_down, brake }; enum class InputError : std::uint8_t { invalid_key, invalid_pointer, invalid_wheel, stale_tick, exhausted }; struct Intention { std::uint64_t sequence{}, tick{}; std::int16_t move_x{}, move_y{}; // Signed unit vector *1000, local XY (+Y up). bool brake{}; // Rules 12: held brake. }; struct Navigation { int x{}, y{}; double wheel{}; ScreenPoint pointer{}; // One primary click on the world (press and release, not taken by the UI), consumed // once. Used for presentation selection only; never an authoritative command. std::optional click; }; // Main-thread value state; no event queue or authoritative position. class InputState { public: // Host-owned sequence seed, for local streams/tests; not a session resume grant. explicit InputState(std::uint64_t last_sequence = 0) : sequence_{last_sequence} {} void admit(bool enabled) noexcept; void capture(bool captured) noexcept; [[nodiscard]] bool captured() const noexcept { return captured_; } [[nodiscard]] bool enabled() const noexcept { return admitted_ && !captured_; } [[nodiscard]] std::expected key(Key key, bool down, bool repeat = false); [[nodiscard]] std::expected pointer(ScreenPoint point); [[nodiscard]] std::expected wheel(double steps); // Records a world click while input is admitted and not captured; otherwise ignored. [[nodiscard]] std::expected click(ScreenPoint point); [[nodiscard]] Navigation take_navigation() noexcept; [[nodiscard]] std::expected sample(std::uint64_t tick); private: void clear() noexcept; std::array keys_{}; bool admitted_{false}, captured_{false}; ScreenPoint pointer_{}; double wheel_{}; std::optional click_; std::uint64_t sequence_{}; std::optional tick_; }; } // namespace evo::client