From 938fd8c12fc2489303e12538d3e3585bd771141f Mon Sep 17 00:00:00 2001 From: Daniel Adams <70986246+msub2@users.noreply.github.com> Date: Mon, 9 Sep 2024 11:07:56 +0000 Subject: [PATCH] webxr: Update XRInputSource gamepad index to be -1 (#33369) * Update XRInputSource gamepad index to be -1 Signed-off-by: Daniel Adams * Update test expectations Signed-off-by: Daniel Adams --------- Signed-off-by: Daniel Adams --- components/script/dom/gamepad.rs | 6 +++++- components/script/dom/globalscope.rs | 3 ++- components/script/dom/xrinputsource.rs | 1 + .../xrInputSource_gamepad_disconnect.https.html.ini | 5 +++-- .../xrInputSource_gamepad_disconnect.https.html.ini | 5 +++-- 5 files changed, 14 insertions(+), 6 deletions(-) diff --git a/components/script/dom/gamepad.rs b/components/script/dom/gamepad.rs index 725a9bbf99b..953132e3f02 100644 --- a/components/script/dom/gamepad.rs +++ b/components/script/dom/gamepad.rs @@ -96,6 +96,7 @@ impl Gamepad { axis_bounds: (f64, f64), button_bounds: (f64, f64), supported_haptic_effects: GamepadSupportedHapticEffects, + xr: bool, ) -> DomRoot { Self::new_with_proto( global, @@ -105,6 +106,7 @@ impl Gamepad { axis_bounds, button_bounds, supported_haptic_effects, + xr, ) } @@ -121,15 +123,17 @@ impl Gamepad { axis_bounds: (f64, f64), button_bounds: (f64, f64), supported_haptic_effects: GamepadSupportedHapticEffects, + xr: bool, ) -> DomRoot { let button_list = GamepadButtonList::init_buttons(global); let vibration_actuator = GamepadHapticActuator::new(global, gamepad_id, supported_haptic_effects); + let index = if xr { -1 } else { 0 }; let gamepad = reflect_dom_object_with_proto( Box::new(Gamepad::new_inherited( gamepad_id, id, - 0, + index, true, 0., mapping_type, diff --git a/components/script/dom/globalscope.rs b/components/script/dom/globalscope.rs index 43ad1764c49..2caf00da4cf 100644 --- a/components/script/dom/globalscope.rs +++ b/components/script/dom/globalscope.rs @@ -3236,7 +3236,8 @@ impl GlobalScope { "standard".into(), axis_bounds, button_bounds, - supported_haptic_effects + supported_haptic_effects, + false ); navigator.set_gamepad(selected_index as usize, &gamepad); } diff --git a/components/script/dom/xrinputsource.rs b/components/script/dom/xrinputsource.rs index 699c861ab11..8db4fb5dae3 100644 --- a/components/script/dom/xrinputsource.rs +++ b/components/script/dom/xrinputsource.rs @@ -55,6 +55,7 @@ impl XRInputSource { supports_dual_rumble: false, supports_trigger_rumble: false, }, + true, ); XRInputSource { reflector: Reflector::new(), diff --git a/tests/wpt/meta-legacy-layout/webxr/gamepads-module/xrInputSource_gamepad_disconnect.https.html.ini b/tests/wpt/meta-legacy-layout/webxr/gamepads-module/xrInputSource_gamepad_disconnect.https.html.ini index aba9da4c7db..f6ca9de7957 100644 --- a/tests/wpt/meta-legacy-layout/webxr/gamepads-module/xrInputSource_gamepad_disconnect.https.html.ini +++ b/tests/wpt/meta-legacy-layout/webxr/gamepads-module/xrInputSource_gamepad_disconnect.https.html.ini @@ -1,7 +1,8 @@ [xrInputSource_gamepad_disconnect.https.html] + expected: ERROR [WebXR InputSource's gamepad gets disconnected when the input source is removed - webgl2] - expected: FAIL + expected: NOTRUN [WebXR InputSource's gamepad gets disconnected when the input source is removed - webgl] - expected: FAIL + expected: TIMEOUT diff --git a/tests/wpt/meta/webxr/gamepads-module/xrInputSource_gamepad_disconnect.https.html.ini b/tests/wpt/meta/webxr/gamepads-module/xrInputSource_gamepad_disconnect.https.html.ini index aba9da4c7db..f6ca9de7957 100644 --- a/tests/wpt/meta/webxr/gamepads-module/xrInputSource_gamepad_disconnect.https.html.ini +++ b/tests/wpt/meta/webxr/gamepads-module/xrInputSource_gamepad_disconnect.https.html.ini @@ -1,7 +1,8 @@ [xrInputSource_gamepad_disconnect.https.html] + expected: ERROR [WebXR InputSource's gamepad gets disconnected when the input source is removed - webgl2] - expected: FAIL + expected: NOTRUN [WebXR InputSource's gamepad gets disconnected when the input source is removed - webgl] - expected: FAIL + expected: TIMEOUT