source: webkit/trunk/Source/WebCore/testing/WebFakeXRInputController.idl

Last change on this file was 292780, checked in by [email protected], 3 years ago

[WebXR] Implement the WebXRFrame methods for getting joints' poses and radii
https://bugs.webkit.org/show_bug.cgi?id=238968

Patch by Ada Chan <[email protected]> on 2022-04-12
Reviewed by Dean Jackson.

Source/WebCore:

Tests: http/wpt/webxr/xrFrame_fillJointRadii.html

http/wpt/webxr/xrFrame_fillJointRadii_missing_joint_pose.html
http/wpt/webxr/xrFrame_fillPoses.html
http/wpt/webxr/xrFrame_fillPoses_missing_joint_pose.html
http/wpt/webxr/xrFrame_getJointPose.html
http/wpt/webxr/xrFrame_getJointPose_missing_joint_pose.html
http/wpt/webxr/xrHand.html

  • Implement the methods in WebXRFrame for getting joints' poses and radii.
  • Add a new InputSourceHandJoint struct to represent joint data, and add

a vector of InputSourceHandJoint in PlatformXR::Device::FrameData::InputSource
to represent the joints data.

  • Implement logic for managing a vector of WebXRJointSpaces in WebXRHand and

updating it with new hand joints data from PlatformXR::Device::FrameData::InputSource.

  • DerivedSources-input.xcfilelist:
  • DerivedSources-output.xcfilelist:
  • DerivedSources.make:
  • Modules/webxr/WebXRFrame+HandInput.idl:
  • Modules/webxr/WebXRFrame.cpp:

(WebCore::WebXRFrame::populatePose):
There are valid cases when the WebXRSpace's effective origin can be null,
for example, a joint pose from a hand that has other missing joint poses.
Just return null and not throw an exception in that case.
(WebCore::WebXRFrame::getJointPose):
Populate the joint's pose, and create a WebXRJointPose with the pose's
transform and the joint's radius.
(WebCore::WebXRFrame::fillJointRadii):
Validate the inputs and fill in the radii array. Fill in with NaN
if the hand has missing joint poses.
(WebCore::WebXRFrame::fillPoses):
Validate the inputs and fill in the transforms array. Fill in with NaN
if the hand has missing joint poses.

  • Modules/webxr/WebXRFrame.h:
  • Modules/webxr/WebXRHand.cpp:

(WebCore::WebXRHand::WebXRHand):
Initialize the m_joints array.
(WebCore::WebXRHand::get):
(WebCore::WebXRHand::Iterator::next):
(WebCore::WebXRHand::session):
(WebCore::WebXRHand::updateFromInputSource):
Update m_joints array based on the latest hands data from InputSource.

  • Modules/webxr/WebXRHand.h:

(WebCore::WebXRHand::size):
(WebCore::WebXRHand::hasMissingPoses const):

  • Modules/webxr/WebXRInputSource.cpp:

(WebCore::WebXRInputSource::update):

  • Modules/webxr/WebXRJointPose.cpp:

(WebCore::WebXRJointPose::create):
(WebCore::WebXRJointPose::WebXRJointPose):
Handle joint radius.

  • Modules/webxr/WebXRJointPose.h:
  • Modules/webxr/WebXRJointPose.idl:
  • Modules/webxr/WebXRJointSpace.cpp:

(WebCore::WebXRJointSpace::create):
(WebCore::WebXRJointSpace::WebXRJointSpace):
Handle joint name and the actual pose data. Keep a weak ptr to the WebXRHand.
(WebCore::WebXRJointSpace::updateFromJoint):
(WebCore::WebXRJointSpace::handHasMissingPoses const):
(WebCore::WebXRJointSpace::session const):
(WebCore::WebXRJointSpace::nativeOrigin const):
Return null pose transforms if there are missing joint poses.

  • Modules/webxr/WebXRJointSpace.h:

(WebCore::WebXRJointSpace::jointName const):
(WebCore::WebXRJointSpace::radius const):

  • Modules/webxr/WebXRJointSpace.idl:
  • Modules/webxr/WebXRSession.cpp:

(WebCore::WebXRSession::isHandTrackingEnabled const):

  • Modules/webxr/WebXRSession.h:
  • WebCore.xcodeproj/project.pbxproj:
  • platform/xr/PlatformXR.h:

(PlatformXR::Device::FrameData::InputSourceHandJoint::encode const):
(PlatformXR::Device::FrameData::InputSourceHandJoint::decode):
(PlatformXR::Device::FrameData::InputSource::encode const):
(PlatformXR::Device::FrameData::InputSource::decode):

  • testing/FakeXRInputSourceInit.h:
  • testing/FakeXRInputSourceInit.idl:

Allow test InputSource to be created with an array of joints.

  • testing/FakeXRJointStateInit.h: Copied from Source/WebCore/Modules/webxr/WebXRJointPose.idl.
  • testing/FakeXRJointStateInit.idl: Copied from Source/WebCore/Modules/webxr/WebXRJointPose.idl.

Define init dictionary for joint data.

  • testing/WebFakeXRInputController.cpp:

(WebCore::WebFakeXRInputController::WebFakeXRInputController):
(WebCore::WebFakeXRInputController::getFrameData):
(WebCore::WebFakeXRInputController::updateHandJoints):
Update m_handJoints based on joint init dictionaries.

  • testing/WebFakeXRInputController.h:
  • testing/WebFakeXRInputController.idl:
  • testing/WebXRTest.cpp:

(WebCore::parseFeatures):
(WebCore::WebXRTest::simulateDeviceConnection):
Allow test device to specify a list of enabled features that don't need
further explicit consent.

  • testing/WebXRTest.h:
  • testing/WebXRTest.idl:

Source/WebKit:

  • Shared/XR/XRDeviceProxy.cpp:

(WebKit::XRDeviceProxy::initializeTrackingAndRendering):
Initialize input sources on session start.

LayoutTests:

Add more constants for a valid joint value and device init dictionary
that represents a device with hand tracking support enabled.

Add new tests for testing hand input related methods in XRFrame.

  • http/wpt/webxr/resources/webxr_test_constants_single_view.js:
  • http/wpt/webxr/xrFrame_fillJointRadii-expected.txt: Added.
  • http/wpt/webxr/xrFrame_fillJointRadii.html: Added.
  • http/wpt/webxr/xrFrame_fillJointRadii_missing_joint_pose-expected.txt: Added.
  • http/wpt/webxr/xrFrame_fillJointRadii_missing_joint_pose.html: Added.
  • http/wpt/webxr/xrFrame_fillPoses-expected.txt: Added.
  • http/wpt/webxr/xrFrame_fillPoses.html: Added.
  • http/wpt/webxr/xrFrame_fillPoses_missing_joint_pose-expected.txt: Added.
  • http/wpt/webxr/xrFrame_fillPoses_missing_joint_pose.html: Added.
  • http/wpt/webxr/xrFrame_getJointPose-expected.txt: Added.
  • http/wpt/webxr/xrFrame_getJointPose.html: Added.
  • http/wpt/webxr/xrFrame_getJointPose_missing_joint_pose-expected.txt: Added.
  • http/wpt/webxr/xrFrame_getJointPose_missing_joint_pose.html: Added.
  • http/wpt/webxr/xrHand-expected.txt: Added.
  • http/wpt/webxr/xrHand.html: Added.
  • http/wpt/webxr/xrHandInput_gc.html:
  • platform/win/TestExpectations: Skip other folders with WebXR tests
  • Property svn:eol-style set to LF
File size: 3.7 KB
Line 
1/*
2 * Copyright (C) 2020 Igalia S.L. All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions
6 * are met:
7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 *
13 * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
14 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
15 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
17 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
18 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
19 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
20 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
21 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
22 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
23 * THE POSSIBILITY OF SUCH DAMAGE.
24 */
25
26[
27 Conditional=WEBXR,
28 EnabledBySetting=WebXREnabled,
29 InterfaceName=FakeXRInputController,
30 LegacyNoInterfaceObject
31] interface WebFakeXRInputController {
32 // Indicates that the handedness of the device has changed.
33 undefined setHandedness(XRHandedness handedness);
34
35 // Indicates that the target ray mode of the device has changed.
36 undefined setTargetRayMode(XRTargetRayMode targetRayMode);
37
38 // Indicates that the list of profiles representing the device has changed.
39 undefined setProfiles(sequence<DOMString> profiles);
40
41 // Sets or clears the position of the controller. If not set, the controller is assumed to
42 // not be tracked.
43 undefined setGripOrigin(FakeXRRigidTransformInit gripOrigin, optional boolean emulatedPosition = false);
44 undefined clearGripOrigin();
45
46 // Sets the pointer origin for the controller.
47 undefined setPointerOrigin(FakeXRRigidTransformInit pointerOrigin, optional boolean emulatedPosition = false);
48
49 // Temporarily disconnect the input device
50 undefined disconnect();
51
52 // Reconnect a disconnected input device
53 undefined reconnect();
54
55 // Start a selection for the current frame with the primary input
56 // If a gamepad is supported, should update the state of the primary button accordingly.
57 undefined startSelection();
58
59 // End selection for the current frame with the primary input
60 // If a gamepad is supported, should update the state of the primary button accordingly.
61 undefined endSelection();
62
63 // Simulates a start/endSelection for the current frame with the primary input
64 // If a gamepad is supported, should update the state of the primary button accordingly.
65 undefined simulateSelect();
66
67 // Updates the set of supported buttons, including any initial state.
68 // Note that this method should not be generally used to update the state of the
69 // buttons, as the UA may treat this as re-creating the Gamepad.
70 // Note that if any FakeXRButtonType is repeated the behavior is undefined.
71 undefined setSupportedButtons(sequence<FakeXRButtonStateInit> supportedButtons);
72
73 // Used to update the state of a button currently supported by the input source
74 // Will not add support for that button if it is not currently supported.
75 undefined updateButtonState(FakeXRButtonStateInit buttonState);
76
77 [Conditional=WEBXR_HANDS] undefined updateHandJoints(sequence<FakeXRJointStateInit> handJoints);
78};
Note: See TracBrowser for help on using the repository browser.