Commit 4d9deea6 authored by Jacob DeWitt's avatar Jacob DeWitt Committed by Commit Bot

Update WebXR Gamepad y axis comments

Now that WebXR spec issue 664 has been resolved with the decision to
follow the Gamepad spec convention of using -1 for up and 1 for down for
the y axis values, remove/update related TODO comments to reflect this.

Bug: 966060
Change-Id: I3694631c35d3ad2e0990c132f2936f8ae1db1ee7
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1717576
Commit-Queue: Jacob DeWitt <jacde@chromium.org>
Reviewed-by: default avatarAlexander Cooper <alcooper@chromium.org>
Reviewed-by: default avatarKlaus Weidner <klausw@chromium.org>
Cr-Commit-Position: refs/heads/master@{#681119}
parent 6f416979
...@@ -47,7 +47,6 @@ device::Gamepad CreateGamepad(const device::GvrGamepadData& data) { ...@@ -47,7 +47,6 @@ device::Gamepad CreateGamepad(const device::GvrGamepadData& data) {
// [0.0, 1.0], with (0, 0) corresponding to the top-left of the touchpad. // [0.0, 1.0], with (0, 0) corresponding to the top-left of the touchpad.
// Normalize the values to use X axis range -1 (left) to 1 (right) and Y // Normalize the values to use X axis range -1 (left) to 1 (right) and Y
// axis range -1 (top) to 1 (bottom). // axis range -1 (top) to 1 (bottom).
// TODO(https://crbug.com/966060): Revisit this if the convention changes.
gamepad.axes[0] = (data.touch_pos.x() * 2.0) - 1.0; gamepad.axes[0] = (data.touch_pos.x() * 2.0) - 1.0;
gamepad.axes[1] = (data.touch_pos.y() * 2.0) - 1.0; gamepad.axes[1] = (data.touch_pos.y() * 2.0) - 1.0;
} else { } else {
......
...@@ -291,8 +291,7 @@ base::Optional<Gamepad> OculusGamepadHelper::CreateGamepad(ovrSession session, ...@@ -291,8 +291,7 @@ base::Optional<Gamepad> OculusGamepadHelper::CreateGamepad(ovrSession session,
OculusGamepadBuilder touch(input_touch, hand); OculusGamepadBuilder touch(input_touch, hand);
// TODO(https://crbug.com/966060): Determine if inverting the y value here is // Invert the y axis because -1 is up in the Gamepad API, but down in Oculus.
// necessary.
touch.AddAxis(input_touch.Thumbstick[hand].x); touch.AddAxis(input_touch.Thumbstick[hand].x);
touch.AddAxis(-input_touch.Thumbstick[hand].y); touch.AddAxis(-input_touch.Thumbstick[hand].y);
......
...@@ -60,8 +60,7 @@ std::map<vr::EVRButtonId, GamepadBuilder::ButtonData> GetAxesButtons( ...@@ -60,8 +60,7 @@ std::map<vr::EVRButtonId, GamepadBuilder::ButtonData> GetAxesButtons(
GamepadBuilder::ButtonData button_data; GamepadBuilder::ButtonData button_data;
// TODO(https://crbug.com/966060): Determine if inverting the y value here // Invert the y axis because -1 is up in the Gamepad API but down in OpenVR.
// is necessary.
double x_axis = controller_state.rAxis[j].x; double x_axis = controller_state.rAxis[j].x;
double y_axis = -controller_state.rAxis[j].y; double y_axis = -controller_state.rAxis[j].y;
......
...@@ -331,9 +331,7 @@ bool TestHelper::GetControllerState(unsigned int index, ...@@ -331,9 +331,7 @@ bool TestHelper::GetControllerState(unsigned int index,
controller_state->ulButtonTouched = controller_state->ulButtonTouched =
TranslateButtonMask(controller_data.buttons_touched); TranslateButtonMask(controller_data.buttons_touched);
for (unsigned int i = 0; i < device::kMaxNumAxes; ++i) { for (unsigned int i = 0; i < device::kMaxNumAxes; ++i) {
// Invert the y axis because gamepad and the rest of Chrome follows the // Invert the y axis because -1 is up in the Gamepad API, but down in WMR.
// convention that -1 is up, but WMR reports -1 as down.
// TODO(https://crbug.com/966060): Revisit this if the convention changes.
controller_state->rAxis[i].x = controller_data.axis_data[i].x; controller_state->rAxis[i].x = controller_data.axis_data[i].x;
controller_state->rAxis[i].y = -controller_data.axis_data[i].y; controller_state->rAxis[i].y = -controller_data.axis_data[i].y;
} }
......
...@@ -286,8 +286,7 @@ std::unordered_map<ButtonName, GamepadBuilder::ButtonData> ParseButtonState( ...@@ -286,8 +286,7 @@ std::unordered_map<ButtonName, GamepadBuilder::ButtonData> ParseButtonState(
data.touched = data.pressed; data.touched = data.pressed;
data.value = data.pressed ? 1.0 : 0.0; data.value = data.pressed ? 1.0 : 0.0;
// TODO(https://crbug.com/966060): Determine if inverting the y value here is // Invert the y axis because -1 is up in the Gamepad API, but down in WMR.
// necessary.
data.has_both_axes = true; data.has_both_axes = true;
data.x_axis = source_state->ThumbstickX(); data.x_axis = source_state->ThumbstickX();
data.y_axis = -source_state->ThumbstickY(); data.y_axis = -source_state->ThumbstickY();
...@@ -303,8 +302,7 @@ std::unordered_map<ButtonName, GamepadBuilder::ButtonData> ParseButtonState( ...@@ -303,8 +302,7 @@ std::unordered_map<ButtonName, GamepadBuilder::ButtonData> ParseButtonState(
// The Touchpad does have Axes, but if it's not touched, they are 0. // The Touchpad does have Axes, but if it's not touched, they are 0.
data.has_both_axes = true; data.has_both_axes = true;
if (data.touched) { if (data.touched) {
// TODO(https://crbug.com/966060): Determine if inverting the y value here // Invert the y axis because -1 is up in the Gamepad API, but down in WMR.
// is necessary.
data.x_axis = source_state->TouchpadX(); data.x_axis = source_state->TouchpadX();
data.y_axis = -source_state->TouchpadY(); data.y_axis = -source_state->TouchpadY();
} else { } else {
......
...@@ -68,9 +68,7 @@ double MockWMRInputSourceState::ThumbstickX() const { ...@@ -68,9 +68,7 @@ double MockWMRInputSourceState::ThumbstickX() const {
return val; return val;
} }
// Invert the y axis because gamepad and the rest of Chrome follows the // Invert the y axis because -1 is up in the Gamepad API, but down in WMR.
// convention that -1 is up, but WMR reports -1 as down.
// TODO(https://crbug.com/966060): Revisit this if the convention changes.
double MockWMRInputSourceState::ThumbstickY() const { double MockWMRInputSourceState::ThumbstickY() const {
double val = data_.axis_data[XrAxisOffsetFromId(XrButtonId::kAxisPrimary)].y; double val = data_.axis_data[XrAxisOffsetFromId(XrButtonId::kAxisPrimary)].y;
// Should be in [-1, 1] for joysticks. // Should be in [-1, 1] for joysticks.
...@@ -88,9 +86,7 @@ double MockWMRInputSourceState::TouchpadX() const { ...@@ -88,9 +86,7 @@ double MockWMRInputSourceState::TouchpadX() const {
return val; return val;
} }
// Invert the y axis because gamepad and the rest of Chrome follows the // Invert the y axis because -1 is up in the Gamepad API, but down in WMR.
// convention that -1 is up, but WMR reports -1 as down.
// TODO(https://crbug.com/966060): Revisit this if the convention changes.
double MockWMRInputSourceState::TouchpadY() const { double MockWMRInputSourceState::TouchpadY() const {
double val = double val =
data_.axis_data[XrAxisOffsetFromId(XrButtonId::kAxisSecondary)].y; data_.axis_data[XrAxisOffsetFromId(XrButtonId::kAxisSecondary)].y;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment