#pragma once #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include namespace vamp_zero { struct score_draw_cache; struct ui_state { vamp_zero::app_state app{}; std::string ap_ssid{}; std::string zero_ip{}; std::uint16_t port{8080}; }; class zero_ui { public: zero_ui(boost::asio::any_io_executor executor, luma::application_config config, std::function command_handler = {}); auto run() -> std::expected; auto stop() -> void; auto publish(vamp_zero::ui_state state) -> std::expected; auto snapshot() const -> vamp_zero::ui_state; private: auto handle_touch(luma::touch_event const &event) -> std::bool_t; auto send_touch_command(vamp_protocol::page_command command) -> void; auto arm_pending_tap() -> void; auto cancel_pending_tap_locked() -> void; auto make_root(vamp_zero::ui_state const &state) -> std::expected, modulus::error>; boost::asio::any_io_executor executor_; boost::asio::steady_timer tap_timer_; luma::application application_; std::function command_handler_{}; std::shared_ptr score_cache_{}; mutable std::mutex mutex_{}; vamp_zero::ui_state state_{}; mutable std::mutex touch_mutex_{}; std::optional active_touch_id_{}; std::chrono::steady_clock::time_point touch_down_time_{}; std::chrono::steady_clock::time_point last_tap_time_{}; std::bool_t hold_sent_{}; std::bool_t pending_tap_{}; }; auto make_ui_state(vamp_zero::config const &config, vamp_zero::app_state app) -> vamp_zero::ui_state; }