Gamepad: Align closer to spec and implement missing slots (#31385)

* Implement missing gamepad slots, align to spec more

- Fixes TODO's from initial gamepad implementation
- Adds some missing spec steps

* Only handle gamepad events when pref is enabled

* Return empty list in getGamepads if document not active

* ./mach fmt

* Update getGamepads to return an array instead of GamepadList

* Add spec link for [[exposed]] slot

* Remove failing test expectations for not-fully-active

* A few fixes

- Change should_notify to has_gesture
- Add spec links and TODO to navigator
- Remove unneeded clone from GamepadList::list
- Move gamepadconnected event firing into has_gesture block

* Use queue_with_canceller for tasks and add expects

* Explicitly check for gamepad user gesture

* Move user gesture check into separate function

* Change contains_user_gesture to be a gamepad function

* mach fmt

* Change axis/button threshold constants to be private to module
This commit is contained in:
Daniel Adams 2024-03-12 08:32:30 -04:00 committed by GitHub
parent 31a50feb4a
commit 48fa77df67
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
8 changed files with 124 additions and 45 deletions

View file

@ -48,6 +48,14 @@ impl GamepadList {
pub fn remove_gamepad(&self, index: usize) {
self.list.borrow_mut().remove(index);
}
pub fn list(&self) -> Vec<Option<DomRoot<Gamepad>>> {
self.list
.borrow()
.iter()
.map(|gamepad| Some(DomRoot::from_ref(&**gamepad)))
.collect()
}
}
impl GamepadListMethods for GamepadList {