From 710736042f9c6a6290edba3f63bc7e4330159154 Mon Sep 17 00:00:00 2001 From: Artem Bolgar Date: Mon, 24 Feb 2020 18:50:20 +0000 Subject: [PATCH] Bug 1615008 [wpt PR 21759] - Adding core support for WebXR squeezestart / squeeze / squeezeend events, a=testonly Automatic update from web-platform-tests Adding core support for WebXR squeezestart / squeeze / squeezeend events New WebXR spec has a new set of input events. This commit adds core support for those. Still must be hooked up to the actual HW-specific code (I've added code for Oculus Rift (S) as an example). Bug: 1051247,1019144 Change-Id: Iac0e66a39eff68c567af2234e583780af6dcaed2 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2051369 Reviewed-by: Daniel Cheng Reviewed-by: Mike West Reviewed-by: Kentaro Hara Reviewed-by: Daniel Vogelheim Reviewed-by: Klaus Weidner Reviewed-by: Alexander Cooper Commit-Queue: Alexander Cooper Cr-Commit-Position: refs/heads/master@{#743715} -- wpt-commits: 6c0160d3c0e99ffa3d3156b5f1b52d0c34b62b3f wpt-pr: 21759 --- .../tests/resources/chromium/webxr-test.js | 24 +++ .../webxr/events_session_squeeze.https.html | 137 ++++++++++++++++++ 2 files changed, 161 insertions(+) create mode 100644 testing/web-platform/tests/webxr/events_session_squeeze.https.html diff --git a/testing/web-platform/tests/resources/chromium/webxr-test.js b/testing/web-platform/tests/resources/chromium/webxr-test.js index fe4d8bbeff07..dee05d08ff8a 100644 --- a/testing/web-platform/tests/resources/chromium/webxr-test.js +++ b/testing/web-platform/tests/resources/chromium/webxr-test.js @@ -1012,6 +1012,9 @@ class MockXRInputSource { this.primary_input_clicked_ = fakeInputSourceInit.selectionClicked; } + this.primary_squeeze_pressed_ = false; + this.primary_squeeze_clicked_ = false; + this.mojo_from_input_ = null; if (fakeInputSourceInit.gripOrigin != null) { this.setGripOrigin(fakeInputSourceInit.gripOrigin); @@ -1163,6 +1166,20 @@ class MockXRInputSource { throw new Error("Unknown Button Type!"); } + // is this a 'squeeze' button? + if (buttonIndex === this.getButtonIndex('grip')) { + // squeeze + if (buttonState.pressed) { + this.primary_squeeze_pressed_ = true; + } else if (this.gamepad_.buttons[buttonIndex].pressed) { + this.primary_squeeze_clicked_ = true; + this.primary_squeeze_pressed_ = false; + } else { + this.primary_squeeze_clicked_ = false; + this.primary_squeeze_pressed_ = false; + } + } + this.gamepad_.buttons[buttonIndex].pressed = buttonState.pressed; this.gamepad_.buttons[buttonIndex].touched = buttonState.touched; this.gamepad_.buttons[buttonIndex].value = buttonState.pressedValue; @@ -1181,10 +1198,17 @@ class MockXRInputSource { input_state.primaryInputPressed = this.primary_input_pressed_; input_state.primaryInputClicked = this.primary_input_clicked_; + + input_state.primarySqueezePressed = this.primary_squeeze_pressed_; + input_state.primarySqueezeClicked = this.primary_squeeze_clicked_; // Setting the input source's "clicked" state should generate one "select" // event. Reset the input value to prevent it from continuously generating // events. this.primary_input_clicked_ = false; + // Setting the input source's "clicked" state should generate one "squeeze" + // event. Reset the input value to prevent it from continuously generating + // events. + this.primary_squeeze_clicked_ = false; input_state.mojoFromInput = this.mojo_from_input_; diff --git a/testing/web-platform/tests/webxr/events_session_squeeze.https.html b/testing/web-platform/tests/webxr/events_session_squeeze.https.html new file mode 100644 index 000000000000..59e4e3f72c5d --- /dev/null +++ b/testing/web-platform/tests/webxr/events_session_squeeze.https.html @@ -0,0 +1,137 @@ + + + + + + + +