/* * Copyright (c) 2024, Tim Flynn * * SPDX-License-Identifier: BSD-2-Clause */ #pragma once #include #include #include #include #include #include #include #include #include #include namespace Web::WebDriver { enum class InputSourceType { None, Key, Pointer, Wheel, }; // https://w3c.github.io/webdriver/#dfn-null-input-source struct NullInputSource { }; // https://w3c.github.io/webdriver/#dfn-key-input-source struct KeyInputSource { HashTable pressed; bool alt { false }; bool ctrl { false }; bool meta { false }; bool shift { false }; }; // https://w3c.github.io/webdriver/#dfn-pointer-input-source struct PointerInputSource { enum class Subtype { Mouse, Pen, Touch, }; PointerInputSource(InputState const&, Subtype); Subtype subtype { Subtype::Mouse }; u32 pointer_id { 0 }; UIEvents::MouseButton pressed { UIEvents::MouseButton::None }; CSSPixelPoint position; }; // https://w3c.github.io/webdriver/#dfn-wheel-input-source struct WheelInputSource { }; // https://w3c.github.io/webdriver/#dfn-input-source using InputSource = Variant; // https://w3c.github.io/webdriver/#dfn-global-key-state struct GlobalKeyState { UIEvents::KeyModifier modifiers() const; HashTable pressed; bool alt_key { false }; bool ctrl_key { false }; bool meta_key { false }; bool shift_key { false }; }; Optional input_source_type_from_string(StringView); Optional pointer_input_source_subtype_from_string(StringView); InputSource create_input_source(InputState const&, InputSourceType, Optional); void add_input_source(InputState&, String id, InputSource); void remove_input_source(InputState&, StringView id); Optional get_input_source(InputState&, StringView id); ErrorOr get_or_create_input_source(InputState&, InputSourceType, StringView id, Optional); GlobalKeyState get_global_key_state(InputState const&); }