Files
aevolution/include/evo/client/input.hpp
T
dingoandClaude Opus 5.5 d2f603b582
Foundation / checks (checks) (push) Successful in 5s
Foundation / checks (client) (push) Successful in 5s
Foundation / checks (ecs) (push) Successful in 4s
Foundation / checks (network) (push) Successful in 4s
Foundation / checks (postgres) (push) Successful in 4s
Foundation / checks (tsan) (push) Successful in 5s
Foundation / checks (deploy) (push) Successful in 4m25s
Foundation / postgres-tools (push) Successful in 1m12s
Foundation / server-image (push) Successful in 4m20s
Foundation / image (push) Successful in 4m54s
feat: durable liquid regions (bundle 14, schema 58), cellular-v9 and session v13
ADR-0178. Bundle 14 (rules 12 on owner format 10) is admitted by schema 58
through parser-local normalization to bundle 13, with an exact fenced 13 -> 14
upgrade whose only input, the liquid rules, recovery reads from the target.
Schema 58 also widens the canonical action input: byte 13 bit 0 is brake.

evo-world-clone gains the cellular-v9 opening: cellular-v8 followed by the liquid
upgrade from --tuning FILE (region size must match) and an optional
--current-seed; resumable and idempotent at bundle 14.

Session v13 adds the owner's velocity, heading and the region's current
configuration to its perception, each deposit's world velocity, and a brake on
cellular actions; older sessions keep their layouts. A rules-12 server lists every
pool and the nearest 256 moving bubbles. The client speaks v13, brakes on Space
(rebindable; older controls files take the default), draws currents as drifting
streaks and carries bubbles along their velocities between perceptions.

Tests: protocol v13 round trips and refusals, action-input brake, controls files,
and a PostgreSQL cellular-v9 provisioning test whose player is born, swims and
brakes through the live host. Full local PostgreSQL qualification, the Linux debug
suite and the Windows client suite pass. Refreshes the DEV session window.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-21 18:08:59 -04:00

73 lines
2.3 KiB
C++

#pragma once
#include "evo/client/camera.hpp"
#include <array>
#include <cstdint>
#include <expected>
#include <optional>
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<ScreenPoint> 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<void, InputError> key(Key key, bool down, bool repeat = false);
[[nodiscard]] std::expected<void, InputError> pointer(ScreenPoint point);
[[nodiscard]] std::expected<void, InputError> wheel(double steps);
// Records a world click while input is admitted and not captured; otherwise ignored.
[[nodiscard]] std::expected<void, InputError> click(ScreenPoint point);
[[nodiscard]] Navigation take_navigation() noexcept;
[[nodiscard]] std::expected<Intention, InputError> sample(std::uint64_t tick);
private:
void clear() noexcept;
std::array<bool, 9> keys_{};
bool admitted_{false}, captured_{false};
ScreenPoint pointer_{};
double wheel_{};
std::optional<ScreenPoint> click_;
std::uint64_t sequence_{};
std::optional<std::uint64_t> tick_;
};
} // namespace evo::client