Commit 67b51ee0 authored by Matt Reynolds's avatar Matt Reynolds Committed by Commit Bot

[gamepad] Support new Xbox Wireless Controller FW

Microsoft is expected to update the firmware for Xbox
Wireless Controller (045e:02fd) to modify which field is
populated with the Xbox button state. This CL modifies the
gamepad standard mapping functions for this device on Linux
and macOS to combine the state from the old and new fields
into a single button in the remapped gamepad.

BUG=1003984

Change-Id: I7d55a7d611d88930fb3efe7a8073fb4c3db19cb7
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1804599Reviewed-by: default avatarOvidio de Jesús Ruiz-Henríquez <odejesush@chromium.org>
Commit-Queue: Matt Reynolds <mattreynolds@chromium.org>
Cr-Commit-Position: refs/heads/master@{#696940}
parent 8a2434e3
...@@ -101,7 +101,19 @@ void MapperXboxOneS2016Firmware(const Gamepad& input, Gamepad* mapped) { ...@@ -101,7 +101,19 @@ void MapperXboxOneS2016Firmware(const Gamepad& input, Gamepad* mapped) {
mapped->buttons[BUTTON_INDEX_DPAD_LEFT] = AxisNegativeAsButton(input.axes[6]); mapped->buttons[BUTTON_INDEX_DPAD_LEFT] = AxisNegativeAsButton(input.axes[6]);
mapped->buttons[BUTTON_INDEX_DPAD_RIGHT] = mapped->buttons[BUTTON_INDEX_DPAD_RIGHT] =
AxisPositiveAsButton(input.axes[6]); AxisPositiveAsButton(input.axes[6]);
mapped->buttons[BUTTON_INDEX_META] = input.buttons[15];
// Xbox Wireless Controller (045e:02fd) received a firmware update in 2019
// that changed which field is populated with the Xbox button state. Check
// both fields and combine the results.
auto& xbox_old = input.buttons[15];
auto& xbox_new = input.buttons[12];
mapped->buttons[BUTTON_INDEX_META].pressed =
(xbox_old.pressed || xbox_new.pressed);
mapped->buttons[BUTTON_INDEX_META].touched =
(xbox_old.touched || xbox_new.touched);
mapped->buttons[BUTTON_INDEX_META].value =
std::max(xbox_old.value, xbox_new.value);
mapped->axes[AXIS_INDEX_RIGHT_STICK_Y] = input.axes[3]; mapped->axes[AXIS_INDEX_RIGHT_STICK_Y] = input.axes[3];
mapped->buttons_length = BUTTON_INDEX_COUNT; mapped->buttons_length = BUTTON_INDEX_COUNT;
......
...@@ -83,7 +83,19 @@ void MapperXboxOneS2016Firmware(const Gamepad& input, Gamepad* mapped) { ...@@ -83,7 +83,19 @@ void MapperXboxOneS2016Firmware(const Gamepad& input, Gamepad* mapped) {
mapped->buttons[BUTTON_INDEX_START] = input.buttons[11]; mapped->buttons[BUTTON_INDEX_START] = input.buttons[11];
mapped->buttons[BUTTON_INDEX_LEFT_THUMBSTICK] = input.buttons[13]; mapped->buttons[BUTTON_INDEX_LEFT_THUMBSTICK] = input.buttons[13];
mapped->buttons[BUTTON_INDEX_RIGHT_THUMBSTICK] = input.buttons[14]; mapped->buttons[BUTTON_INDEX_RIGHT_THUMBSTICK] = input.buttons[14];
mapped->buttons[BUTTON_INDEX_META] = input.buttons[15];
// Xbox Wireless Controller (045e:02fd) received a firmware update in 2019
// that changed which field is populated with the Xbox button state. Check
// both fields and combine the results.
auto& xbox_old = input.buttons[15];
auto& xbox_new = input.buttons[12];
mapped->buttons[BUTTON_INDEX_META].pressed =
(xbox_old.pressed || xbox_new.pressed);
mapped->buttons[BUTTON_INDEX_META].touched =
(xbox_old.touched || xbox_new.touched);
mapped->buttons[BUTTON_INDEX_META].value =
std::max(xbox_old.value, xbox_new.value);
mapped->axes[AXIS_INDEX_RIGHT_STICK_Y] = input.axes[5]; mapped->axes[AXIS_INDEX_RIGHT_STICK_Y] = input.axes[5];
DpadFromAxis(mapped, input.axes[9]); DpadFromAxis(mapped, input.axes[9]);
......
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