Implement non-XR Gamepad discovery and input (#31200)

* Create embedder event to send to constellation

* Handle gamepad message in constellation, send to script thread

* Handle GamepadEvent in script thread and dispatch event to document

* Add missing Clones, fix event

* Add gamepad task source

* Adjust GamepadIndex type, remove unused imports

* Add internal getter for gamepads list

* Update gamepad new methods

* Handle gamepad connect and disconnect events

* Proto will be none, no need for HandleObject

* Initialize buttons and axes to standard mapping

* Adjust update type index types

* Update GamepadButton update function

* Adjust Gamepad mapping comments to match spec, add update logic

* Amend comment

* Update button and axis inputs on Updated event

* Add GilRs as gamepad backend in servoshell

* Add spec links, queue gamepad updates on task source

* ./mach fmt

* Fix comment length

* Split out button init, update spec comments

* Move gamepad event handling from document to global

* Map and normalize axes/button values

* Use std::time for gamepad timestamp

* Adjust gamepad handling in event loop

* Move button press/touch check into map+normalize function

- Small change but is more in line with spec

* ./mach fmt

* Update comment spec links and warning messages

* Doc comments -> regular comments

* Add window event handlers for gamepad connect/disconnect

* Adjust gamepad disconnect behavior

* Add missing TODO's, adjust gamepad/gamepadbutton list methods and formatting

* Update button handling from gilrs, add comments

* Enable gamepad pref during WPT tests and update expectations

* Update WPT expectations in meta-legacy-layout
This commit is contained in:
Daniel Adams 2024-02-17 08:42:31 -10:00 committed by GitHub
parent 1cc546c4fc
commit c999d4546c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
27 changed files with 695 additions and 208 deletions

View file

@ -10,6 +10,7 @@ use crate::dom::bindings::cell::DomRefCell;
use crate::task::TaskCanceller;
use crate::task_source::dom_manipulation::DOMManipulationTaskSource;
use crate::task_source::file_reading::FileReadingTaskSource;
use crate::task_source::gamepad::GamepadTaskSource;
use crate::task_source::history_traversal::HistoryTraversalTaskSource;
use crate::task_source::media_element::MediaElementTaskSource;
use crate::task_source::networking::NetworkingTaskSource;
@ -42,6 +43,8 @@ pub struct TaskManager {
#[ignore_malloc_size_of = "task sources are hard"]
file_reading_task_source: FileReadingTaskSource,
#[ignore_malloc_size_of = "task sources are hard"]
gamepad_task_source: GamepadTaskSource,
#[ignore_malloc_size_of = "task sources are hard"]
history_traversal_task_source: HistoryTraversalTaskSource,
#[ignore_malloc_size_of = "task sources are hard"]
media_element_task_source: MediaElementTaskSource,
@ -65,6 +68,7 @@ impl TaskManager {
pub fn new(
dom_manipulation_task_source: DOMManipulationTaskSource,
file_reading_task_source: FileReadingTaskSource,
gamepad_task_source: GamepadTaskSource,
history_traversal_task_source: HistoryTraversalTaskSource,
media_element_task_source: MediaElementTaskSource,
networking_task_source: NetworkingTaskSource,
@ -78,6 +82,7 @@ impl TaskManager {
TaskManager {
dom_manipulation_task_source,
file_reading_task_source,
gamepad_task_source,
history_traversal_task_source,
media_element_task_source,
networking_task_source,
@ -99,6 +104,14 @@ impl TaskManager {
DOMManipulation
);
task_source_functions!(
self,
gamepad_task_source_with_canceller,
gamepad_task_source,
GamepadTaskSource,
Gamepad
);
task_source_functions!(
self,
media_element_task_source_with_canceller,