/* * Copyright (c) 2025, Jelle Raaijmakers * * SPDX-License-Identifier: BSD-2-Clause */ #pragma once #include #include #include #include #include namespace Web::Gamepad { class NavigatorGamepadPartial { public: WebIDL::ExceptionOr>> get_gamepads(); size_t select_an_unused_gamepad_index(Badge); void handle_gamepad_connected(SDL_JoystickID sdl_joystick_id); void handle_gamepad_updated(Badge, SDL_JoystickID sdl_joystick_id); void handle_gamepad_disconnected(Badge, SDL_JoystickID sdl_joystick_id); bool has_gamepad_gesture() const { return m_has_gamepad_gesture; } void set_has_gamepad_gesture(Badge, bool); GC::RootVector> gamepads(Badge) const; protected: void visit_edges(GC::Cell::Visitor& visitor); void check_for_connected_gamepads(); private: virtual ~NavigatorGamepadPartial() = default; friend class HTML::Navigator; // https://w3c.github.io/gamepad/#dfn-hasgamepadgesture // A flag indicating that a gamepad user gesture has been observed bool m_has_gamepad_gesture { false }; // https://w3c.github.io/gamepad/#dfn-gamepads // Each Gamepad present at the index specified by its index attribute, or null for unassigned indices. Vector> m_gamepads; // Non-standard attribute to know which gamepads are available to the system. This is used to prevent duplicate // connections for the same gamepad ID (e.g. if the navigator object is initialized and checks for connected gamepads // and also receives an SDL gamepad connected event) Vector m_available_gamepads; }; }