Correctly map macOS Bluetooth joystick buttons for Series X Controller
New support was just added for the Xbox Series X Controller on macOS over Bluetooth however that patch failed to properly map the joystick click buttons. This patch fixes that issue simply by mapping them to the proper buttons. Bug: 1170887 Change-Id: I2ea338df8a650dea92187183e71b9f126d1e4159 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2650905 Reviewed-by: Matt Reynolds <mattreynolds@chromium.org> Commit-Queue: James Hollyer <jameshollyer@chromium.org> Cr-Commit-Position: refs/heads/master@{#859663}
This commit is contained in:

committed by
Chromium LUCI CQ

parent
08a94c84cf
commit
f64f7eb9f8
@@ -35,6 +35,7 @@ const uint16_t kPowerUsageNumber = 0x30;
|
||||
const uint16_t kSearchUsageNumber = 0x0221;
|
||||
const uint16_t kHomeUsageNumber = 0x0223;
|
||||
const uint16_t kBackUsageNumber = 0x0224;
|
||||
const uint16_t kRecordUsageNumber = 0xb2;
|
||||
|
||||
const int kRumbleMagnitudeMax = 10000;
|
||||
|
||||
@@ -52,6 +53,7 @@ struct SpecialUsages {
|
||||
// Back.
|
||||
{kConsumerUsagePage, kHomeUsageNumber},
|
||||
{kConsumerUsagePage, kBackUsageNumber},
|
||||
{kConsumerUsagePage, kRecordUsageNumber},
|
||||
};
|
||||
const size_t kSpecialUsagesLen = base::size(kSpecialUsages);
|
||||
|
||||
|
@@ -68,6 +68,12 @@ enum CanonicalButtonIndex {
|
||||
BUTTON_INDEX_COUNT
|
||||
};
|
||||
|
||||
// Xbox Series X has an extra share button.
|
||||
enum XboxSeriesXButtons {
|
||||
XBOX_SERIES_X_BUTTON_SHARE = CanonicalButtonIndex::BUTTON_INDEX_COUNT,
|
||||
XBOX_SERIES_X_BUTTON_COUNT
|
||||
};
|
||||
|
||||
// A Java counterpart will be generated for this enum.
|
||||
// GENERATED_JAVA_ENUM_PACKAGE: org.chromium.device.gamepad
|
||||
// GENERATED_JAVA_PREFIX_TO_STRIP: AXIS_INDEX_
|
||||
|
@@ -122,14 +122,15 @@ void MapperXboxSeriesX(const Gamepad& input, Gamepad* mapped) {
|
||||
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->buttons[BUTTON_INDEX_LEFT_THUMBSTICK] = input.buttons[13];
|
||||
mapped->buttons[BUTTON_INDEX_RIGHT_THUMBSTICK] = input.buttons[14];
|
||||
mapped->buttons[BUTTON_INDEX_META] = input.buttons[12];
|
||||
mapped->buttons[XBOX_SERIES_X_BUTTON_SHARE] = input.buttons[15];
|
||||
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->buttons_length = XBOX_SERIES_X_BUTTON_COUNT;
|
||||
mapped->axes_length = AXIS_INDEX_COUNT;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user