Commit 5955d1c4 authored by Harry Cutts's avatar Harry Cutts Committed by Commit Bot

[gamepad] Add mappings for ELECOM pads in "D" mode

This CL adds mappings for the JC-U4013SBK (the wired version) and
JC-U4113SBK (wireless) when they're in "D" (DirectInput) mode.
(https://crrev.com/c/2252469 adds XInput support for the JC-U4113SBK,
and XInput support for the JC-U4013SBK is still to come.)

Bug: chromium:1097173, chromium:1096754, b:159466838, b:159368181
Test: Connect gamepads in "D" mode, load gamepadviewer.com, and check
that pressing buttons and moving axes is correctly reflected on-screen.

Change-Id: I30dae3bd586b5b4ceeccb0a4ae3c02bb8a91447a
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2259012
Commit-Queue: Harry Cutts <hcutts@chromium.org>
Reviewed-by: default avatarMatt Reynolds <mattreynolds@chromium.org>
Cr-Commit-Position: refs/heads/master@{#781466}
parent ae4d6809
......@@ -142,6 +142,7 @@ constexpr struct GamepadInfo {
// Elecom Co., Ltd
{0x056e, 0x2003, kXInputTypeNone},
{0x056e, 0x2004, kXInputTypeXbox360},
{0x056e, 0x200f, kXInputTypeNone},
{0x056e, 0x2010, kXInputTypeNone},
{0x056e, 0x2013, kXInputTypeXbox360},
// Nintendo Co., Ltd
......
......@@ -40,6 +40,8 @@ enum class GamepadId : uint32_t {
kBroadcomProduct8502 = 0x0a5c8502,
kDragonRiseProduct0006 = 0x00790006,
kDragonRiseProduct0011 = 0x00790011,
kElecomProduct200f = 0x056e200f,
kElecomProduct2010 = 0x056e2010,
kGoogleProduct2c40 = 0x18d12c40,
kGoogleProduct9400 = 0x18d19400,
kGreenAsiaProduct0003 = 0x0e8f0003,
......
......@@ -820,6 +820,33 @@ void MapperHoripadSwitch(const Gamepad& input, Gamepad* mapped) {
mapped->axes_length = AXIS_INDEX_COUNT;
}
void MapperElecomWiredDirectInput(const Gamepad& input, Gamepad* mapped) {
*mapped = input;
mapped->buttons[BUTTON_INDEX_PRIMARY] = input.buttons[2];
mapped->buttons[BUTTON_INDEX_SECONDARY] = input.buttons[3];
mapped->buttons[BUTTON_INDEX_TERTIARY] = input.buttons[0];
mapped->buttons[BUTTON_INDEX_QUATERNARY] = input.buttons[1];
mapped->buttons[BUTTON_INDEX_DPAD_UP] = AxisNegativeAsButton(input.axes[5]);
mapped->buttons[BUTTON_INDEX_DPAD_DOWN] = AxisPositiveAsButton(input.axes[5]);
mapped->buttons[BUTTON_INDEX_DPAD_LEFT] = AxisNegativeAsButton(input.axes[4]);
mapped->buttons[BUTTON_INDEX_DPAD_RIGHT] =
AxisPositiveAsButton(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[12];
mapped->buttons_length = BUTTON_INDEX_COUNT;
mapped->axes_length = AXIS_INDEX_COUNT;
}
void MapperElecomWirelessDirectInput(const Gamepad& input, Gamepad* mapped) {
MapperElecomWiredDirectInput(input, mapped);
mapped->axes[AXIS_INDEX_RIGHT_STICK_X] = input.axes[3];
mapped->axes[AXIS_INDEX_RIGHT_STICK_Y] = input.axes[2];
}
constexpr struct MappingData {
GamepadId gamepad_id;
GamepadStandardMappingFunction function;
......@@ -906,6 +933,10 @@ constexpr struct MappingData {
{GamepadId::kPrototypeVendorProduct9401, MapperStadiaControllerOldFirmware},
// Snakebyte iDroid:con
{GamepadId::kBroadcomProduct8502, MapperSnakebyteIDroidCon},
// Elecom JC-U4013SBK (DirectInput mode)
{GamepadId::kElecomProduct200f, MapperElecomWiredDirectInput},
// Elecom JC-U4113SBK (DirectInput mode)
{GamepadId::kElecomProduct2010, MapperElecomWirelessDirectInput},
};
} // namespace
......
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