Commit 3f344472 authored by James Hollyer's avatar James Hollyer Committed by Chromium LUCI CQ

Support XBox Series X on macOS over Bluetooth

The new XBox Controller is out so we are adding support to the gamepad
API. The mappings match up to the XBox One Controller mappings so this
patch applies those mappings to this productID.

Bug: 1147578
Change-Id: I362294ac73dede831fbd3641eb84cc9f0f896fc5
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2580484Reviewed-by: default avatarMatt Reynolds <mattreynolds@chromium.org>
Commit-Queue: James Hollyer <jameshollyer@chromium.org>
Cr-Commit-Position: refs/heads/master@{#840271}
parent 44c615f4
......@@ -90,6 +90,7 @@ constexpr struct GamepadInfo {
{0x045e, 0x0b05, kXInputTypeNone},
{0x045e, 0x0b0a, kXInputTypeXboxOne},
{0x045e, 0x0b0c, kXInputTypeNone},
{0x045e, 0x0b13, kXInputTypeNone},
// Logitech, Inc.
{0x046d, 0xc208, kXInputTypeNone},
{0x046d, 0xc209, kXInputTypeNone},
......
......@@ -71,6 +71,7 @@ enum class GamepadId : uint32_t {
kMicrosoftProduct0b05 = 0x045e0b05,
kMicrosoftProduct0b0a = 0x045e0b0a,
kMicrosoftProduct0b0c = 0x045e0b0c,
kMicrosoftProduct0b13 = 0x045e0b13,
kNintendoProduct2006 = 0x057e2006,
kNintendoProduct2007 = 0x057e2007,
kNintendoProduct2009 = 0x057e2009,
......
......@@ -110,6 +110,29 @@ void MapperXboxOneS2016Firmware(const Gamepad& input, Gamepad* mapped) {
mapped->axes_length = AXIS_INDEX_COUNT;
}
void MapperXboxSeriesX(const Gamepad& input, Gamepad* mapped) {
*mapped = input;
mapped->buttons[BUTTON_INDEX_PRIMARY] = input.buttons[0];
mapped->buttons[BUTTON_INDEX_SECONDARY] = input.buttons[1];
mapped->buttons[BUTTON_INDEX_TERTIARY] = input.buttons[3];
mapped->buttons[BUTTON_INDEX_QUATERNARY] = input.buttons[4];
mapped->buttons[BUTTON_INDEX_LEFT_SHOULDER] = input.buttons[6];
mapped->buttons[BUTTON_INDEX_RIGHT_SHOULDER] = input.buttons[7];
mapped->buttons[BUTTON_INDEX_LEFT_TRIGGER] = AxisToButton(input.axes[3]);
mapped->buttons[BUTTON_INDEX_RIGHT_TRIGGER] = AxisToButton(input.axes[4]);
mapped->buttons[BUTTON_INDEX_BACK_SELECT] = input.buttons[10];
mapped->buttons[BUTTON_INDEX_START] = input.buttons[11];
mapped->buttons[BUTTON_INDEX_LEFT_THUMBSTICK] = input.buttons[8];
mapped->buttons[BUTTON_INDEX_RIGHT_THUMBSTICK] = input.buttons[9];
mapped->buttons[BUTTON_INDEX_META] = input.buttons[16];
mapped->axes[AXIS_INDEX_RIGHT_STICK_X] = input.axes[2];
mapped->axes[AXIS_INDEX_RIGHT_STICK_Y] = input.axes[5];
DpadFromAxis(mapped, input.axes[9]);
mapped->buttons_length = BUTTON_INDEX_COUNT;
mapped->axes_length = AXIS_INDEX_COUNT;
}
void MapperPlaystationSixAxis(const Gamepad& input, Gamepad* mapped) {
*mapped = input;
mapped->buttons[BUTTON_INDEX_PRIMARY] = input.buttons[14];
......@@ -694,6 +717,8 @@ constexpr struct MappingData {
{GamepadId::kMicrosoftProduct02ea, MapperXbox360Gamepad},
// Xbox One S (Bluetooth)
{GamepadId::kMicrosoftProduct02fd, MapperXboxOneS2016Firmware},
// Xbox Series X (Bluetooth)
{GamepadId::kMicrosoftProduct0b13, MapperXboxSeriesX},
// Xbox 360 Wireless
{GamepadId::kMicrosoftProduct0719, MapperXbox360Gamepad},
// Xbox One Elite 2 (USB)
......
......@@ -27,7 +27,8 @@ bool XboxHidController::IsXboxHid(GamepadId gamepad_id) {
// https://www.usb.org/document-library/device-class-definition-pid-10
return gamepad_id == GamepadId::kMicrosoftProduct02e0 ||
gamepad_id == GamepadId::kMicrosoftProduct02fd ||
gamepad_id == GamepadId::kMicrosoftProduct0b05;
gamepad_id == GamepadId::kMicrosoftProduct0b05 ||
gamepad_id == GamepadId::kMicrosoftProduct0b13;
}
void XboxHidController::DoShutdown() {
......
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