Commit e5d76c1d authored by Andrew Weintraub's avatar Andrew Weintraub Committed by Commit Bot

Add button mappings for Nintendo Switch Pro Controller.

Bug: 836235
Change-Id: Ieef527eb62e8d1184e91c77cfd60bc7fcf01bc56
Reviewed-on: https://chromium-review.googlesource.com/1025639Reviewed-by: default avatarRobert Kroeger <rjkroege@chromium.org>
Commit-Queue: Andrew Weintraub <asweintraub@google.com>
Cr-Commit-Position: refs/heads/master@{#553212}
parent d73e45fd
...@@ -151,6 +151,26 @@ bool DualShock4Mapper(uint16_t type, ...@@ -151,6 +151,26 @@ bool DualShock4Mapper(uint16_t type,
return DO_MAPPING; return DO_MAPPING;
} }
bool NintendoSwitchPro(uint16_t type,
uint16_t code,
GamepadEventType* mapped_type,
uint16_t* mapped_code) {
static const KeyMapType key_mapping = {
{BTN_A, WG_BUTTON_A}, {BTN_B, WG_BUTTON_B},
{BTN_C, WG_BUTTON_X}, {BTN_X, WG_BUTTON_Y},
{BTN_Y, WG_BUTTON_L1}, {BTN_Z, WG_BUTTON_R1},
{BTN_TL, WG_BUTTON_LT}, {BTN_TR, WG_BUTTON_RT},
{BTN_TL2, WG_BUTTON_SELECT}, {BTN_TR2, WG_BUTTON_START},
{BTN_SELECT, WG_BUTTON_THUMBL}, {BTN_START, WG_BUTTON_THUMBR},
{BTN_MODE, WG_BUTTON_MODE}};
static const AbsMapType abs_mapping = {
TO_ABS(ABS_X, WG_ABS_X), TO_ABS(ABS_Y, WG_ABS_Y),
TO_ABS(ABS_RX, WG_ABS_RX), TO_ABS(ABS_RY, WG_ABS_RY),
TO_BTN(ABS_HAT0X, kHAT_X), TO_BTN(ABS_HAT0Y, kHAT_Y)};
return DO_MAPPING;
}
bool NintendoSwitchLeft(uint16_t type, bool NintendoSwitchLeft(uint16_t type,
uint16_t code, uint16_t code,
GamepadEventType* mapped_type, GamepadEventType* mapped_type,
...@@ -459,6 +479,7 @@ static const struct MappingData { ...@@ -459,6 +479,7 @@ static const struct MappingData {
{0x054c, 0x0268, PlaystationSixAxisMapper}, // Playstation 3. {0x054c, 0x0268, PlaystationSixAxisMapper}, // Playstation 3.
{0x054c, 0x05c4, DualShock4Mapper}, // Dualshock 4. {0x054c, 0x05c4, DualShock4Mapper}, // Dualshock 4.
// Nintendo switch. // Nintendo switch.
{0x057e, 0x2009, NintendoSwitchPro}, // Nintendo switch pro.
{0x057e, 0x2006, NintendoSwitchLeft}, // Nintendo switch left. {0x057e, 0x2006, NintendoSwitchLeft}, // Nintendo switch left.
{0x057e, 0x2007, NintendoSwitchRight}, // Nintendo switch right. {0x057e, 0x2007, NintendoSwitchRight}, // Nintendo switch right.
// NES style gamepad. // NES style gamepad.
......
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