Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(3260)

Unified Diff: device/gamepad/gamepad_standard_mappings_linux.cc

Issue 2455653003: Add mapping for Xbox One S controller on Linux and Android (Closed)
Patch Set: Added trigger idle test and fixed a bug it uncovered Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « device/gamepad/android/junit/src/org/chromium/device/gamepad/GamepadMappingsTest.java ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: device/gamepad/gamepad_standard_mappings_linux.cc
diff --git a/device/gamepad/gamepad_standard_mappings_linux.cc b/device/gamepad/gamepad_standard_mappings_linux.cc
index 7755e1f936debddac6d0b81ec76826c16a226175..7f4ffdd529eb6363434024aac0fc911c5dffb63d 100644
--- a/device/gamepad/gamepad_standard_mappings_linux.cc
+++ b/device/gamepad/gamepad_standard_mappings_linux.cc
@@ -32,6 +32,27 @@ void MapperXInputStyleGamepad(const blink::WebGamepad& input,
mapped->axesLength = AXIS_INDEX_COUNT;
}
+void MapperXboxOneHidGamepad(const blink::WebGamepad& input,
+ blink::WebGamepad* mapped) {
+ *mapped = input;
+ mapped->buttons[BUTTON_INDEX_LEFT_TRIGGER] = AxisToButton(input.axes[2]);
+ mapped->buttons[BUTTON_INDEX_RIGHT_TRIGGER] = AxisToButton(input.axes[5]);
+ mapped->buttons[BUTTON_INDEX_BACK_SELECT] = input.buttons[6];
+ mapped->buttons[BUTTON_INDEX_START] = input.buttons[7];
+ mapped->buttons[BUTTON_INDEX_LEFT_THUMBSTICK] = input.buttons[8];
+ mapped->buttons[BUTTON_INDEX_RIGHT_THUMBSTICK] = input.buttons[9];
+ mapped->buttons[BUTTON_INDEX_DPAD_UP] = AxisNegativeAsButton(input.axes[7]);
+ mapped->buttons[BUTTON_INDEX_DPAD_DOWN] = AxisPositiveAsButton(input.axes[7]);
+ mapped->buttons[BUTTON_INDEX_DPAD_LEFT] = AxisNegativeAsButton(input.axes[6]);
+ mapped->buttons[BUTTON_INDEX_DPAD_RIGHT] =
+ AxisPositiveAsButton(input.axes[6]);
+ mapped->axes[AXIS_INDEX_RIGHT_STICK_X] = input.axes[3];
+ mapped->axes[AXIS_INDEX_RIGHT_STICK_Y] = input.axes[4];
+
+ mapped->buttonsLength = BUTTON_INDEX_COUNT - 1; /* no meta */
+ mapped->axesLength = AXIS_INDEX_COUNT;
+}
+
void MapperLakeviewResearch(const blink::WebGamepad& input,
blink::WebGamepad* mapped) {
*mapped = input;
@@ -299,6 +320,7 @@ struct MappingData {
{"0079", "0006", MapperDragonRiseGeneric}, // DragonRise Generic USB
{"045e", "028e", MapperXInputStyleGamepad}, // Xbox 360 Wired
{"045e", "028f", MapperXInputStyleGamepad}, // Xbox 360 Wireless
+ {"045e", "02e0", MapperXboxOneHidGamepad}, // Xbox One S (Bluetooth mode)
{"045e", "0719", MapperXInputStyleGamepad}, // Xbox 360 Wireless
{"046d", "c21d", MapperXInputStyleGamepad}, // Logitech F310
{"046d", "c21e", MapperXInputStyleGamepad}, // Logitech F510
« no previous file with comments | « device/gamepad/android/junit/src/org/chromium/device/gamepad/GamepadMappingsTest.java ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698