#include "device/gamepad/gamepad_standard_mappings.h"
#include <stddef.h>
#include <algorithm>
#include <iterator>
#include "device/gamepad/gamepad_id_list.h"
namespace device {
namespace {
const uint16_t kDualshockPatchedBcdHidMask = 0x8000;
const uint16_t kStadiaControllerOldFirmwareVersion = 0x0001;
enum StadiaGamepadButtons {
STADIA_GAMEPAD_BUTTON_EXTRA = BUTTON_INDEX_COUNT,
STADIA_GAMEPAD_BUTTON_EXTRA2,
STADIA_GAMEPAD_BUTTON_COUNT
};
enum XboxSeriesXGamepadButtons {
kSeriesXGamepadButtonShare = BUTTON_INDEX_COUNT,
kSeriesXGamepadButtonCount
};
void MapperXInputStyleGamepad(const Gamepad& input, Gamepad* 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[9];
mapped->buttons[BUTTON_INDEX_RIGHT_THUMBSTICK] = input.buttons[10];
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->buttons[BUTTON_INDEX_META] = input.buttons[8];
mapped->axes[AXIS_INDEX_RIGHT_STICK_X] = input.axes[3];
mapped->axes[AXIS_INDEX_RIGHT_STICK_Y] = input.axes[4];
mapped->buttons_length = BUTTON_INDEX_COUNT;
mapped->axes_length = AXIS_INDEX_COUNT;
}
void MapperXboxBluetooth(const Gamepad& input, Gamepad* mapped) {
*mapped = input;
mapped->buttons[BUTTON_INDEX_TERTIARY] = input.buttons[3];
mapped->buttons[BUTTON_INDEX_QUATERNARY] = input.buttons[4];
mapped->buttons[BUTTON_INDEX_LEFT_TRIGGER] = AxisToButton(input.axes[5]);
mapped->buttons[BUTTON_INDEX_RIGHT_TRIGGER] = AxisToButton(input.axes[4]);
mapped->buttons[BUTTON_INDEX_LEFT_SHOULDER] = input.buttons[6];
mapped->buttons[BUTTON_INDEX_RIGHT_SHOULDER] = input.buttons[7];
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[13];
mapped->buttons[BUTTON_INDEX_RIGHT_THUMBSTICK] = input.buttons[14];
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->buttons[BUTTON_INDEX_META] = input.buttons[12];
mapped->buttons_length = BUTTON_INDEX_COUNT;
mapped->axes_length = AXIS_INDEX_COUNT;
}
void MapperXboxSeriesXBluetooth(const Gamepad& input, Gamepad* mapped) {
MapperXboxBluetooth(input, mapped);
mapped->buttons[kSeriesXGamepadButtonShare] = input.buttons[15];
mapped->buttons_length = kSeriesXGamepadButtonCount;
}
void MapperXboxOneS(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[2];
mapped->buttons[BUTTON_INDEX_QUATERNARY] = input.buttons[3];
mapped->buttons[BUTTON_INDEX_LEFT_SHOULDER] = input.buttons[4];
mapped->buttons[BUTTON_INDEX_RIGHT_SHOULDER] = input.buttons[5];
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->buttons[BUTTON_INDEX_META] = input.buttons[10];
mapped->axes[AXIS_INDEX_RIGHT_STICK_X] = input.axes[3];
mapped->axes[AXIS_INDEX_RIGHT_STICK_Y] = input.axes[4];
mapped->buttons_length = BUTTON_INDEX_COUNT;
mapped->axes_length = AXIS_INDEX_COUNT;
}
void MapperXboxOneS2016Firmware(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[5]);
mapped->buttons[BUTTON_INDEX_RIGHT_TRIGGER] = AxisToButton(input.axes[4]);
mapped->buttons[BUTTON_INDEX_BACK_SELECT] = input.buttons[16];
mapped->buttons[BUTTON_INDEX_START] = input.buttons[11];
mapped->buttons[BUTTON_INDEX_LEFT_THUMBSTICK] = input.buttons[13];
mapped->buttons[BUTTON_INDEX_RIGHT_THUMBSTICK] = input.buttons[14];
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]);
auto& xbox_old = input.buttons[15];
auto& xbox_new = input.buttons[12];
mapped->buttons[BUTTON_INDEX_META].pressed =
(xbox_old.pressed || xbox_new.pressed);
mapped->buttons[BUTTON_INDEX_META].touched =
(xbox_old.touched || xbox_new.touched);
mapped->buttons[BUTTON_INDEX_META].value =
std::max(xbox_old.value, xbox_new.value);
mapped->axes[AXIS_INDEX_RIGHT_STICK_Y] = input.axes[3];
mapped->buttons_length = BUTTON_INDEX_COUNT;
mapped->axes_length = AXIS_INDEX_COUNT;
}
void MapperXboxElite2Bluetooth(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_BACK_SELECT] = input.buttons[16];
mapped->buttons[BUTTON_INDEX_START] = input.buttons[11];
mapped->buttons[BUTTON_INDEX_LEFT_THUMBSTICK] = input.buttons[13];
mapped->buttons[BUTTON_INDEX_RIGHT_THUMBSTICK] = input.buttons[14];
int axis_shift = mapped->axes_length > 8 ? 1 : 0;
mapped->buttons[BUTTON_INDEX_LEFT_TRIGGER] =
AxisToButton(input.axes[5 + axis_shift]);
mapped->buttons[BUTTON_INDEX_RIGHT_TRIGGER] =
AxisToButton(input.axes[4 + axis_shift]);
mapped->buttons[BUTTON_INDEX_DPAD_UP] =
AxisNegativeAsButton(input.axes[7 + axis_shift]);
mapped->buttons[BUTTON_INDEX_DPAD_DOWN] =
AxisPositiveAsButton(input.axes[7 + axis_shift]);
mapped->buttons[BUTTON_INDEX_DPAD_LEFT] =
AxisNegativeAsButton(input.axes[6 + axis_shift]);
mapped->buttons[BUTTON_INDEX_DPAD_RIGHT] =
AxisPositiveAsButton(input.axes[6 + axis_shift]);
mapped->buttons_length = BUTTON_INDEX_COUNT - 1;
mapped->axes_length = AXIS_INDEX_COUNT;
}
void MapperLakeviewResearch(const Gamepad& input, Gamepad* mapped) {
*mapped = input;
mapped->buttons[BUTTON_INDEX_PRIMARY] = input.buttons[2];
mapped->buttons[BUTTON_INDEX_TERTIARY] = input.buttons[3];
mapped->buttons[BUTTON_INDEX_QUATERNARY] = input.buttons[0];
mapped->buttons[BUTTON_INDEX_LEFT_SHOULDER] = input.buttons[6];
mapped->buttons[BUTTON_INDEX_RIGHT_SHOULDER] = input.buttons[7];
mapped->buttons[BUTTON_INDEX_LEFT_TRIGGER] = input.buttons[4];
mapped->buttons[BUTTON_INDEX_RIGHT_TRIGGER] = input.buttons[5];
mapped->buttons[BUTTON_INDEX_BACK_SELECT] = input.buttons[9];
mapped->buttons[BUTTON_INDEX_START] = input.buttons[8];
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_length = BUTTON_INDEX_COUNT - 1;
mapped->axes_length = AXIS_INDEX_COUNT;
}
void MapperDualshock3SixAxis(const Gamepad& input, Gamepad* mapped) {
*mapped = input;
mapped->buttons[BUTTON_INDEX_PRIMARY] = input.buttons[14];
mapped->buttons[BUTTON_INDEX_SECONDARY] = input.buttons[13];
mapped->buttons[BUTTON_INDEX_TERTIARY] = input.buttons[15];
mapped->buttons[BUTTON_INDEX_QUATERNARY] = input.buttons[12];
mapped->buttons[BUTTON_INDEX_LEFT_SHOULDER] = input.buttons[10];
mapped->buttons[BUTTON_INDEX_RIGHT_SHOULDER] = input.buttons[11];
mapped->buttons[BUTTON_INDEX_LEFT_TRIGGER] = AxisToButton(input.axes[12]);
mapped->buttons[BUTTON_INDEX_RIGHT_TRIGGER] = AxisToButton(input.axes[13]);
mapped->buttons[BUTTON_INDEX_BACK_SELECT] = input.buttons[0];
mapped->buttons[BUTTON_INDEX_START] = input.buttons[3];
mapped->buttons[BUTTON_INDEX_LEFT_THUMBSTICK] = input.buttons[1];
mapped->buttons[BUTTON_INDEX_RIGHT_THUMBSTICK] = input.buttons[2];
mapped->buttons[BUTTON_INDEX_DPAD_UP] = AxisToButton(input.axes[8]);
mapped->buttons[BUTTON_INDEX_DPAD_DOWN] = AxisToButton(input.axes[10]);
mapped->buttons[BUTTON_INDEX_DPAD_LEFT] = input.buttons[7];
mapped->buttons[BUTTON_INDEX_DPAD_RIGHT] = AxisToButton(input.axes[9]);
mapped->buttons[BUTTON_INDEX_META] = input.buttons[16];
mapped->buttons_length = BUTTON_INDEX_COUNT;
mapped->axes_length = AXIS_INDEX_COUNT;
}
void MapperDualshock3SixAxisNew(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[2];
mapped->buttons[BUTTON_INDEX_LEFT_SHOULDER] = input.buttons[4];
mapped->buttons[BUTTON_INDEX_RIGHT_SHOULDER] = input.buttons[5];
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[8];
mapped->buttons[BUTTON_INDEX_START] = input.buttons[9];
mapped->buttons[BUTTON_INDEX_LEFT_THUMBSTICK] = input.buttons[11];
mapped->buttons[BUTTON_INDEX_RIGHT_THUMBSTICK] = input.buttons[12];
mapped->buttons[BUTTON_INDEX_DPAD_UP] = input.buttons[13];
mapped->buttons[BUTTON_INDEX_DPAD_DOWN] = input.buttons[14];
mapped->buttons[BUTTON_INDEX_DPAD_LEFT] = input.buttons[15];
mapped->buttons[BUTTON_INDEX_DPAD_RIGHT] = input.buttons[16];
mapped->buttons[BUTTON_INDEX_META] = input.buttons[10];
mapped->axes[AXIS_INDEX_RIGHT_STICK_X] = input.axes[3];
mapped->axes[AXIS_INDEX_RIGHT_STICK_Y] = input.axes[4];
mapped->buttons_length = BUTTON_INDEX_COUNT;
mapped->axes_length = AXIS_INDEX_COUNT;
}
void MapperDualshock4(const Gamepad& input, Gamepad* mapped) {
enum Dualshock4Buttons {
DUALSHOCK_BUTTON_TOUCHPAD = BUTTON_INDEX_COUNT,
DUALSHOCK_BUTTON_COUNT
};
*mapped = input;
mapped->buttons[BUTTON_INDEX_PRIMARY] = input.buttons[1];
mapped->buttons[BUTTON_INDEX_SECONDARY] = input.buttons[2];
mapped->buttons[BUTTON_INDEX_TERTIARY] = input.buttons[0];
mapped->buttons[BUTTON_INDEX_QUATERNARY] = input.buttons[3];
mapped->buttons[BUTTON_INDEX_LEFT_SHOULDER] = input.buttons[4];
mapped->buttons[BUTTON_INDEX_RIGHT_SHOULDER] = input.buttons[5];
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[8];
mapped->buttons[BUTTON_INDEX_START] = input.buttons[9];
mapped->buttons[BUTTON_INDEX_LEFT_THUMBSTICK] = input.buttons[10];
mapped->buttons[BUTTON_INDEX_RIGHT_THUMBSTICK] = input.buttons[11];
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->buttons[BUTTON_INDEX_META] = input.buttons[12];
mapped->buttons[DUALSHOCK_BUTTON_TOUCHPAD] = input.buttons[13];
mapped->axes[AXIS_INDEX_RIGHT_STICK_Y] = input.axes[5];
mapped->buttons_length = DUALSHOCK_BUTTON_COUNT;
mapped->axes_length = AXIS_INDEX_COUNT;
}
void MapperPs4Ps5(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[2];
mapped->buttons[BUTTON_INDEX_LEFT_SHOULDER] = input.buttons[4];
mapped->buttons[BUTTON_INDEX_RIGHT_SHOULDER] = input.buttons[5];
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[8];
mapped->buttons[BUTTON_INDEX_START] = input.buttons[9];
mapped->buttons[BUTTON_INDEX_LEFT_THUMBSTICK] = input.buttons[11];
mapped->buttons[BUTTON_INDEX_RIGHT_THUMBSTICK] = input.buttons[12];
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->buttons[BUTTON_INDEX_META] = input.buttons[10];
mapped->axes[AXIS_INDEX_RIGHT_STICK_X] = input.axes[3];
mapped->axes[AXIS_INDEX_RIGHT_STICK_Y] = input.axes[4];
mapped->buttons_length = BUTTON_INDEX_COUNT;
mapped->axes_length = AXIS_INDEX_COUNT;
}
void MapperDualSense(const Gamepad& input, Gamepad* mapped) {
enum DualSenseButtons {
DUAL_SENSE_BUTTON_TOUCHPAD = BUTTON_INDEX_COUNT,
DUAL_SENSE_BUTTON_COUNT
};
*mapped = input;
mapped->buttons[BUTTON_INDEX_PRIMARY] = input.buttons[1];
mapped->buttons[BUTTON_INDEX_SECONDARY] = input.buttons[2];
mapped->buttons[BUTTON_INDEX_TERTIARY] = input.buttons[0];
mapped->buttons[BUTTON_INDEX_QUATERNARY] = input.buttons[3];
mapped->buttons[BUTTON_INDEX_LEFT_SHOULDER] = input.buttons[4];
mapped->buttons[BUTTON_INDEX_RIGHT_SHOULDER] = input.buttons[5];
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[8];
mapped->buttons[BUTTON_INDEX_START] = input.buttons[9];
mapped->buttons[BUTTON_INDEX_LEFT_THUMBSTICK] = input.buttons[10];
mapped->buttons[BUTTON_INDEX_RIGHT_THUMBSTICK] = input.buttons[11];
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->buttons[BUTTON_INDEX_META] = input.buttons[12];
mapped->buttons[DUAL_SENSE_BUTTON_TOUCHPAD] = input.buttons[13];
mapped->axes[AXIS_INDEX_RIGHT_STICK_X] = input.axes[2];
mapped->axes[AXIS_INDEX_RIGHT_STICK_Y] = input.axes[5];
mapped->buttons_length = DUAL_SENSE_BUTTON_COUNT;
mapped->axes_length = AXIS_INDEX_COUNT;
}
void MapperIBuffalo(const Gamepad& input, Gamepad* mapped) {
*mapped = input;
mapped->buttons[BUTTON_INDEX_PRIMARY] = input.buttons[1];
mapped->buttons[BUTTON_INDEX_SECONDARY] = input.buttons[0];
mapped->buttons[BUTTON_INDEX_TERTIARY] = input.buttons[3];
mapped->buttons[BUTTON_INDEX_QUATERNARY] = input.buttons[2];
mapped->buttons[BUTTON_INDEX_BACK_SELECT] = input.buttons[6];
mapped->buttons[BUTTON_INDEX_START] = input.buttons[7];
mapped->buttons[BUTTON_INDEX_LEFT_TRIGGER] = input.buttons[4];
mapped->buttons[BUTTON_INDEX_RIGHT_TRIGGER] = input.buttons[5];
mapped->buttons[BUTTON_INDEX_DPAD_UP] = AxisNegativeAsButton(input.axes[1]);
mapped->buttons[BUTTON_INDEX_DPAD_DOWN] = AxisPositiveAsButton(input.axes[1]);
mapped->buttons[BUTTON_INDEX_DPAD_LEFT] = AxisNegativeAsButton(input.axes[0]);
mapped->buttons[BUTTON_INDEX_DPAD_RIGHT] =
AxisPositiveAsButton(input.axes[0]);
mapped->buttons_length = BUTTON_INDEX_COUNT - 1;
mapped->axes_length = 2;
}
void MapperXGEAR(const Gamepad& input, Gamepad* mapped) {
*mapped = input;
mapped->buttons[BUTTON_INDEX_PRIMARY] = input.buttons[2];
mapped->buttons[BUTTON_INDEX_SECONDARY] = input.buttons[1];
mapped->buttons[BUTTON_INDEX_TERTIARY] = input.buttons[3];
mapped->buttons[BUTTON_INDEX_QUATERNARY] = input.buttons[0];
mapped->buttons[BUTTON_INDEX_LEFT_SHOULDER] = input.buttons[6];
mapped->buttons[BUTTON_INDEX_RIGHT_SHOULDER] = input.buttons[7];
mapped->buttons[BUTTON_INDEX_LEFT_TRIGGER] = input.buttons[4];
mapped->buttons[BUTTON_INDEX_RIGHT_TRIGGER] = input.buttons[5];
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->axes[AXIS_INDEX_RIGHT_STICK_X] = input.axes[3];
mapped->axes[AXIS_INDEX_RIGHT_STICK_Y] = input.axes[2];
mapped->buttons_length = BUTTON_INDEX_COUNT - 1;
mapped->axes_length = AXIS_INDEX_COUNT;
}
void MapperDragonRiseGeneric(const Gamepad& input, Gamepad* mapped) {
*mapped = input;
mapped->buttons[BUTTON_INDEX_DPAD_UP] = AxisNegativeAsButton(input.axes[6]);
mapped->buttons[BUTTON_INDEX_DPAD_DOWN] = AxisPositiveAsButton(input.axes[6]);
mapped->buttons[BUTTON_INDEX_DPAD_LEFT] = AxisNegativeAsButton(input.axes[5]);
mapped->buttons[BUTTON_INDEX_DPAD_RIGHT] =
AxisPositiveAsButton(input.axes[5]);
mapped->axes[AXIS_INDEX_LEFT_STICK_X] = input.axes[0];
mapped->axes[AXIS_INDEX_LEFT_STICK_Y] = input.axes[1];
mapped->axes[AXIS_INDEX_RIGHT_STICK_X] = input.axes[3];
mapped->axes[AXIS_INDEX_RIGHT_STICK_Y] = input.axes[4];
mapped->buttons_length = BUTTON_INDEX_COUNT - 1;
mapped->axes_length = AXIS_INDEX_COUNT;
}
void MapperOnLiveWireless(const Gamepad& input, Gamepad* 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[9];
mapped->buttons[BUTTON_INDEX_RIGHT_THUMBSTICK] = input.buttons[10];
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->buttons[BUTTON_INDEX_META] = input.buttons[8];
mapped->axes[AXIS_INDEX_RIGHT_STICK_X] = input.axes[3];
mapped->axes[AXIS_INDEX_RIGHT_STICK_Y] = input.axes[4];
mapped->buttons_length = BUTTON_INDEX_COUNT;
mapped->axes_length = AXIS_INDEX_COUNT;
}
void MapperADT1(const Gamepad& input, Gamepad* mapped) {
*mapped = input;
mapped->buttons[BUTTON_INDEX_LEFT_TRIGGER] = AxisToButton(input.axes[5]);
mapped->buttons[BUTTON_INDEX_RIGHT_TRIGGER] = AxisToButton(input.axes[4]);
mapped->buttons[BUTTON_INDEX_BACK_SELECT] = NullButton();
mapped->buttons[BUTTON_INDEX_START] = NullButton();
mapped->buttons[BUTTON_INDEX_LEFT_THUMBSTICK] = input.buttons[7];
mapped->buttons[BUTTON_INDEX_RIGHT_THUMBSTICK] = input.buttons[8];
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->buttons[BUTTON_INDEX_META] = input.buttons[6];
mapped->buttons_length = BUTTON_INDEX_COUNT;
mapped->axes_length = AXIS_INDEX_COUNT;
}
void MapperNvShield(const Gamepad& input, Gamepad* mapped) {
*mapped = input;
mapped->buttons[BUTTON_INDEX_LEFT_TRIGGER] = AxisToButton(input.axes[5]);
mapped->buttons[BUTTON_INDEX_RIGHT_TRIGGER] = AxisToButton(input.axes[4]);
mapped->buttons[BUTTON_INDEX_BACK_SELECT] = NullButton();
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->buttons[BUTTON_INDEX_META] = input.buttons[6];
mapped->buttons_length = BUTTON_INDEX_COUNT;
mapped->axes_length = AXIS_INDEX_COUNT;
}
void MapperNvShield2017(const Gamepad& input, Gamepad* mapped) {
enum Shield2017Buttons {
SHIELD2017_BUTTON_PLAYPAUSE = BUTTON_INDEX_COUNT,
SHIELD2017_BUTTON_COUNT
};
*mapped = input;
mapped->buttons[BUTTON_INDEX_LEFT_TRIGGER] = AxisToButton(input.axes[5]);
mapped->buttons[BUTTON_INDEX_RIGHT_TRIGGER] = AxisToButton(input.axes[4]);
mapped->buttons[BUTTON_INDEX_BACK_SELECT] = input.buttons[14];
mapped->buttons[BUTTON_INDEX_START] = input.buttons[13];
mapped->buttons[BUTTON_INDEX_LEFT_THUMBSTICK] = input.buttons[7];
mapped->buttons[BUTTON_INDEX_RIGHT_THUMBSTICK] = input.buttons[8];
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->buttons[BUTTON_INDEX_META] = input.buttons[12];
mapped->buttons[SHIELD2017_BUTTON_PLAYPAUSE] = input.buttons[6];
mapped->buttons_length = SHIELD2017_BUTTON_COUNT;
mapped->axes_length = AXIS_INDEX_COUNT;
}
void MapperOUYA(const Gamepad& input, Gamepad* mapped) {
*mapped = input;
mapped->buttons[BUTTON_INDEX_PRIMARY] = input.buttons[0];
mapped->buttons[BUTTON_INDEX_SECONDARY] = input.buttons[3];
mapped->buttons[BUTTON_INDEX_TERTIARY] = input.buttons[1];
mapped->buttons[BUTTON_INDEX_QUATERNARY] = input.buttons[2];
mapped->buttons[BUTTON_INDEX_LEFT_SHOULDER] = input.buttons[4];
mapped->buttons[BUTTON_INDEX_RIGHT_SHOULDER] = input.buttons[5];
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] = NullButton();
mapped->buttons[BUTTON_INDEX_START] = NullButton();
mapped->buttons[BUTTON_INDEX_LEFT_THUMBSTICK] = input.buttons[6];
mapped->buttons[BUTTON_INDEX_RIGHT_THUMBSTICK] = input.buttons[7];
mapped->buttons[BUTTON_INDEX_DPAD_UP] = input.buttons[8];
mapped->buttons[BUTTON_INDEX_DPAD_DOWN] = input.buttons[9];
mapped->buttons[BUTTON_INDEX_DPAD_LEFT] = input.buttons[10];
mapped->buttons[BUTTON_INDEX_DPAD_RIGHT] = input.buttons[11];
mapped->buttons[BUTTON_INDEX_META] = input.buttons[15];
mapped->axes[AXIS_INDEX_RIGHT_STICK_X] = input.axes[3];
mapped->axes[AXIS_INDEX_RIGHT_STICK_Y] = input.axes[4];
mapped->buttons_length = BUTTON_INDEX_COUNT;
mapped->axes_length = AXIS_INDEX_COUNT;
}
void MapperRazerServal(const Gamepad& input, Gamepad* mapped) {
*mapped = input;
mapped->buttons[BUTTON_INDEX_LEFT_TRIGGER] = AxisToButton(input.axes[5]);
mapped->buttons[BUTTON_INDEX_RIGHT_TRIGGER] = AxisToButton(input.axes[4]);
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[9];
mapped->buttons[BUTTON_INDEX_RIGHT_THUMBSTICK] = input.buttons[10];
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->buttons_length = BUTTON_INDEX_COUNT - 1;
mapped->axes_length = AXIS_INDEX_COUNT;
}
void MapperMoga(const Gamepad& input, Gamepad* mapped) {
*mapped = input;
mapped->buttons[BUTTON_INDEX_LEFT_TRIGGER] = AxisToButton(input.axes[5]);
mapped->buttons[BUTTON_INDEX_RIGHT_TRIGGER] = AxisToButton(input.axes[4]);
mapped->buttons[BUTTON_INDEX_BACK_SELECT] = NullButton();
mapped->buttons[BUTTON_INDEX_START] = input.buttons[6];
mapped->buttons[BUTTON_INDEX_LEFT_THUMBSTICK] = input.buttons[7];
mapped->buttons[BUTTON_INDEX_RIGHT_THUMBSTICK] = input.buttons[8];
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->buttons_length = BUTTON_INDEX_COUNT - 1;
mapped->axes_length = AXIS_INDEX_COUNT;
}
void MapperSamsung_EI_GP20(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] = NullButton();
mapped->buttons[BUTTON_INDEX_RIGHT_SHOULDER] = NullButton();
mapped->buttons[BUTTON_INDEX_LEFT_TRIGGER] = input.buttons[6];
mapped->buttons[BUTTON_INDEX_RIGHT_TRIGGER] = input.buttons[7];
mapped->buttons[BUTTON_INDEX_BACK_SELECT] = input.buttons[10];
mapped->buttons[BUTTON_INDEX_START] = input.buttons[11];
mapped->buttons[BUTTON_INDEX_LEFT_THUMBSTICK] = NullButton();
mapped->buttons[BUTTON_INDEX_RIGHT_THUMBSTICK] = NullButton();
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_META] = input.buttons[15];
mapped->axes[AXIS_INDEX_LEFT_STICK_X] = input.axes[0];
mapped->axes[AXIS_INDEX_LEFT_STICK_Y] = input.axes[1];
mapped->axes[AXIS_INDEX_RIGHT_STICK_X] = input.axes[2];
mapped->axes[AXIS_INDEX_RIGHT_STICK_Y] = input.axes[3];
mapped->buttons_length = BUTTON_INDEX_COUNT;
mapped->axes_length = AXIS_INDEX_COUNT;
}
void MapperSteelSeriesZeemote(const Gamepad& input, Gamepad* mapped) {
*mapped = input;
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] = NullButton();
mapped->buttons[BUTTON_INDEX_RIGHT_TRIGGER] = NullButton();
mapped->buttons[BUTTON_INDEX_BACK_SELECT] = input.buttons[12];
mapped->buttons[BUTTON_INDEX_START] = input.buttons[11];
mapped->buttons[BUTTON_INDEX_LEFT_THUMBSTICK] = NullButton();
mapped->buttons[BUTTON_INDEX_RIGHT_THUMBSTICK] = NullButton();
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_META] = NullButton();
mapped->buttons_length = BUTTON_INDEX_META;
mapped->axes_length = AXIS_INDEX_COUNT;
}
void MapperSteelSeriesStratusXLUsb(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[2];
mapped->buttons[BUTTON_INDEX_QUATERNARY] = input.buttons[3];
mapped->buttons[BUTTON_INDEX_LEFT_SHOULDER] = input.buttons[4];
mapped->buttons[BUTTON_INDEX_RIGHT_SHOULDER] = input.buttons[5];
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[18];
mapped->buttons[BUTTON_INDEX_START] = input.buttons[9];
mapped->buttons[BUTTON_INDEX_LEFT_THUMBSTICK] = input.buttons[10];
mapped->buttons[BUTTON_INDEX_RIGHT_THUMBSTICK] = input.buttons[11];
mapped->buttons[BUTTON_INDEX_DPAD_UP] = input.buttons[12];
mapped->buttons[BUTTON_INDEX_DPAD_DOWN] = input.buttons[13];
mapped->buttons[BUTTON_INDEX_DPAD_LEFT] = input.buttons[14];
mapped->buttons[BUTTON_INDEX_DPAD_RIGHT] = input.buttons[15];
mapped->buttons[BUTTON_INDEX_META] = input.buttons[19];
mapped->axes[AXIS_INDEX_LEFT_STICK_X] = input.axes[0];
mapped->axes[AXIS_INDEX_LEFT_STICK_Y] = input.axes[1];
mapped->axes[AXIS_INDEX_RIGHT_STICK_X] = input.axes[2];
mapped->axes[AXIS_INDEX_RIGHT_STICK_Y] = input.axes[5];
mapped->buttons_length = BUTTON_INDEX_COUNT;
mapped->axes_length = AXIS_INDEX_COUNT;
}
void MapperSteelSeriesStratusBt(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[5]);
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[13];
mapped->buttons[BUTTON_INDEX_RIGHT_THUMBSTICK] = input.buttons[14];
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->buttons[BUTTON_INDEX_META] = NullButton();
mapped->axes[AXIS_INDEX_LEFT_STICK_X] = input.axes[0];
mapped->axes[AXIS_INDEX_LEFT_STICK_Y] = input.axes[1];
mapped->axes[AXIS_INDEX_RIGHT_STICK_X] = input.axes[2];
mapped->axes[AXIS_INDEX_RIGHT_STICK_Y] = input.axes[3];
mapped->buttons_length = BUTTON_INDEX_META;
mapped->axes_length = AXIS_INDEX_COUNT;
}
void MapperSteelSeriesStratusPlusBt(const Gamepad& input, Gamepad* mapped) {
MapperSteelSeriesStratusBt(input, mapped);
mapped->buttons[BUTTON_INDEX_META] = input.buttons[12];
mapped->buttons_length = BUTTON_INDEX_COUNT;
}
void MapperLogitechDInput(const Gamepad& input, Gamepad* mapped) {
*mapped = input;
mapped->buttons[BUTTON_INDEX_PRIMARY] = input.buttons[1];
mapped->buttons[BUTTON_INDEX_SECONDARY] = input.buttons[2];
mapped->buttons[BUTTON_INDEX_TERTIARY] = input.buttons[0];
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_length = BUTTON_INDEX_COUNT - 1;
mapped->axes_length = AXIS_INDEX_COUNT;
}
void MapperStadiaControllerOldFirmware(const Gamepad& input, Gamepad* mapped) {
*mapped = input;
mapped->buttons[BUTTON_INDEX_LEFT_TRIGGER] = AxisToButton(input.axes[5]);
mapped->buttons[BUTTON_INDEX_RIGHT_TRIGGER] = AxisToButton(input.axes[4]);
mapped->buttons[BUTTON_INDEX_BACK_SELECT] = input.buttons[6];
mapped->buttons[BUTTON_INDEX_START] = input.buttons[8];
mapped->buttons[BUTTON_INDEX_LEFT_THUMBSTICK] = input.buttons[9];
mapped->buttons[BUTTON_INDEX_RIGHT_THUMBSTICK] = input.buttons[10];
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->buttons[BUTTON_INDEX_META] = input.buttons[7];
mapped->buttons[STADIA_GAMEPAD_BUTTON_EXTRA] = input.buttons[11];
mapped->buttons[STADIA_GAMEPAD_BUTTON_EXTRA2] = input.buttons[12];
mapped->buttons_length = STADIA_GAMEPAD_BUTTON_COUNT;
mapped->axes_length = AXIS_INDEX_COUNT;
}
void MapperStadiaController(const Gamepad& input, Gamepad* mapped) {
*mapped = input;
mapped->buttons[BUTTON_INDEX_LEFT_TRIGGER] = AxisToButton(input.axes[5]);
mapped->buttons[BUTTON_INDEX_RIGHT_TRIGGER] = AxisToButton(input.axes[4]);
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[9];
mapped->buttons[BUTTON_INDEX_RIGHT_THUMBSTICK] = input.buttons[10];
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->buttons[BUTTON_INDEX_META] = input.buttons[8];
mapped->buttons[STADIA_GAMEPAD_BUTTON_EXTRA] = input.buttons[11];
mapped->buttons[STADIA_GAMEPAD_BUTTON_EXTRA2] = input.buttons[12];
mapped->buttons_length = STADIA_GAMEPAD_BUTTON_COUNT;
mapped->axes_length = AXIS_INDEX_COUNT;
}
void MapperXSkills(const Gamepad& input, Gamepad* mapped) {
enum GamecubeButtons {
GAMECUBE_BUTTON_LEFT_TRIGGER_CLICK = BUTTON_INDEX_COUNT,
GAMECUBE_BUTTON_RIGHT_TRIGGER_CLICK,
GAMECUBE_BUTTON_COUNT
};
*mapped = input;
mapped->buttons[BUTTON_INDEX_PRIMARY] = input.buttons[0];
mapped->buttons[BUTTON_INDEX_SECONDARY] = input.buttons[2];
mapped->buttons[BUTTON_INDEX_TERTIARY] = input.buttons[1];
mapped->buttons[BUTTON_INDEX_QUATERNARY] = input.buttons[3];
mapped->buttons[BUTTON_INDEX_LEFT_SHOULDER] = NullButton();
mapped->buttons[BUTTON_INDEX_RIGHT_SHOULDER] = input.buttons[6];
mapped->buttons[BUTTON_INDEX_LEFT_TRIGGER] = AxisToButton(input.axes[4]);
mapped->buttons[BUTTON_INDEX_RIGHT_TRIGGER] = AxisToButton(input.axes[3]);
mapped->buttons[BUTTON_INDEX_BACK_SELECT] = NullButton();
mapped->buttons[BUTTON_INDEX_START] = input.buttons[7];
mapped->buttons[BUTTON_INDEX_LEFT_THUMBSTICK] = NullButton();
mapped->buttons[BUTTON_INDEX_RIGHT_THUMBSTICK] = NullButton();
mapped->buttons[BUTTON_INDEX_DPAD_UP] = input.buttons[11];
mapped->buttons[BUTTON_INDEX_DPAD_DOWN] = input.buttons[10];
mapped->buttons[BUTTON_INDEX_DPAD_LEFT] = input.buttons[8];
mapped->buttons[BUTTON_INDEX_DPAD_RIGHT] = input.buttons[9];
mapped->buttons[BUTTON_INDEX_META] = NullButton();
mapped->buttons[GAMECUBE_BUTTON_LEFT_TRIGGER_CLICK] = input.buttons[4];
mapped->buttons[GAMECUBE_BUTTON_RIGHT_TRIGGER_CLICK] = input.buttons[5];
mapped->axes[AXIS_INDEX_LEFT_STICK_X] = input.axes[0];
mapped->axes[AXIS_INDEX_LEFT_STICK_Y] = input.axes[1];
mapped->axes[AXIS_INDEX_RIGHT_STICK_X] = input.axes[5];
mapped->axes[AXIS_INDEX_RIGHT_STICK_Y] = input.axes[2];
mapped->buttons_length = GAMECUBE_BUTTON_COUNT;
mapped->axes_length = AXIS_INDEX_COUNT;
}
void MapperBoomN64Psx(const Gamepad& input, Gamepad* mapped) {
*mapped = input;
mapped->buttons[BUTTON_INDEX_PRIMARY] = input.buttons[2];
mapped->buttons[BUTTON_INDEX_SECONDARY] = input.buttons[1];
mapped->buttons[BUTTON_INDEX_TERTIARY] = input.buttons[3];
mapped->buttons[BUTTON_INDEX_QUATERNARY] = input.buttons[0];
mapped->buttons[BUTTON_INDEX_LEFT_SHOULDER] = input.buttons[6];
mapped->buttons[BUTTON_INDEX_RIGHT_SHOULDER] = input.buttons[7];
mapped->buttons[BUTTON_INDEX_LEFT_TRIGGER] = input.buttons[4];
mapped->buttons[BUTTON_INDEX_RIGHT_TRIGGER] = input.buttons[5];
mapped->buttons[BUTTON_INDEX_BACK_SELECT] = input.buttons[8];
mapped->buttons[BUTTON_INDEX_START] = input.buttons[11];
mapped->buttons[BUTTON_INDEX_LEFT_THUMBSTICK] = input.buttons[9];
mapped->buttons[BUTTON_INDEX_RIGHT_THUMBSTICK] = input.buttons[10];
mapped->buttons[BUTTON_INDEX_DPAD_UP] = input.buttons[12];
mapped->buttons[BUTTON_INDEX_DPAD_DOWN] = input.buttons[14];
mapped->buttons[BUTTON_INDEX_DPAD_LEFT] = input.buttons[15];
mapped->buttons[BUTTON_INDEX_DPAD_RIGHT] = input.buttons[13];
mapped->buttons[BUTTON_INDEX_META] = NullButton();
mapped->axes[AXIS_INDEX_LEFT_STICK_X] = input.axes[0];
mapped->axes[AXIS_INDEX_LEFT_STICK_Y] = -input.axes[1];
mapped->axes[AXIS_INDEX_RIGHT_STICK_X] = input.axes[2];
mapped->axes[AXIS_INDEX_RIGHT_STICK_Y] = -input.axes[3];
mapped->buttons_length = BUTTON_INDEX_COUNT - 1;
mapped->axes_length = AXIS_INDEX_COUNT;
}
void MapperSnakebyteIDroidCon(const Gamepad& input, Gamepad* mapped) {
*mapped = input;
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_BACK_SELECT] = input.buttons[10];
mapped->buttons[BUTTON_INDEX_START] = input.buttons[11];
mapped->buttons[BUTTON_INDEX_LEFT_THUMBSTICK] = input.buttons[2];
mapped->buttons[BUTTON_INDEX_RIGHT_THUMBSTICK] = input.buttons[5];
mapped->buttons[BUTTON_INDEX_META] = NullButton();
if ((input.axes_used & 0b1000000) == 0) {
mapped->buttons[BUTTON_INDEX_LEFT_TRIGGER] = input.buttons[8];
mapped->buttons[BUTTON_INDEX_RIGHT_TRIGGER] = input.buttons[9];
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]);
} else {
mapped->buttons[BUTTON_INDEX_LEFT_TRIGGER] =
AxisPositiveAsButton(input.axes[2]);
mapped->buttons[BUTTON_INDEX_RIGHT_TRIGGER] =
AxisNegativeAsButton(input.axes[2]);
mapped->buttons[BUTTON_INDEX_DPAD_UP] = AxisNegativeAsButton(input.axes[6]);
mapped->buttons[BUTTON_INDEX_DPAD_DOWN] =
AxisPositiveAsButton(input.axes[6]);
mapped->buttons[BUTTON_INDEX_DPAD_LEFT] =
AxisNegativeAsButton(input.axes[5]);
mapped->buttons[BUTTON_INDEX_DPAD_RIGHT] =
AxisPositiveAsButton(input.axes[5]);
mapped->axes[AXIS_INDEX_RIGHT_STICK_X] = input.axes[3];
mapped->axes[AXIS_INDEX_RIGHT_STICK_Y] = input.axes[4];
}
mapped->buttons_length = BUTTON_INDEX_COUNT - 1;
mapped->axes_length = AXIS_INDEX_COUNT;
}
void MapperHoripadSwitch(const Gamepad& input, Gamepad* mapped) {
*mapped = input;
mapped->buttons[BUTTON_INDEX_PRIMARY] = input.buttons[1];
mapped->buttons[BUTTON_INDEX_SECONDARY] = input.buttons[2];
mapped->buttons[BUTTON_INDEX_TERTIARY] = input.buttons[0];
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_META] = input.buttons[12];
mapped->buttons[SWITCH_PRO_BUTTON_CAPTURE] = input.buttons[13];
mapped->buttons_length = SWITCH_PRO_BUTTON_COUNT;
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];
}
void MapperDjiFpv(const Gamepad& input, Gamepad* mapped) {
enum DjiFpvAxis {
kDjiFpvAxisGimbalDial = AXIS_INDEX_COUNT,
kDjiFpvAxisFlightModeSwitch,
kDjiFpvAxisC2Switch,
kDjiFpvAxisCount,
};
double flight_mode_axis;
if (input.buttons[6].pressed)
flight_mode_axis = -1.0;
else if (input.buttons[7].pressed)
flight_mode_axis = 1.0;
else
flight_mode_axis = 0.0;
double c2_axis;
if (input.buttons[4].pressed)
c2_axis = 0.0;
else if (input.buttons[5].pressed)
c2_axis = -1.0;
else
c2_axis = 1.0;
*mapped = input;
mapped->buttons[BUTTON_INDEX_PRIMARY] = NullButton();
mapped->buttons[BUTTON_INDEX_SECONDARY] = NullButton();
mapped->buttons[BUTTON_INDEX_TERTIARY] = NullButton();
mapped->buttons[BUTTON_INDEX_QUATERNARY] = NullButton();
mapped->buttons[BUTTON_INDEX_LEFT_SHOULDER] =
input.buttons[2];
mapped->buttons[BUTTON_INDEX_RIGHT_SHOULDER] =
input.buttons[3];
mapped->buttons[BUTTON_INDEX_LEFT_TRIGGER] = NullButton();
mapped->buttons[BUTTON_INDEX_RIGHT_TRIGGER] = input.buttons[1];
mapped->buttons[BUTTON_INDEX_BACK_SELECT] = input.buttons[0];
mapped->axes[AXIS_INDEX_LEFT_STICK_X] = input.axes[3];
mapped->axes[AXIS_INDEX_LEFT_STICK_Y] = -input.axes[2];
mapped->axes[AXIS_INDEX_RIGHT_STICK_X] = input.axes[0];
mapped->axes[AXIS_INDEX_RIGHT_STICK_Y] = -input.axes[1];
mapped->axes[kDjiFpvAxisGimbalDial] = input.axes[4];
mapped->axes[kDjiFpvAxisFlightModeSwitch] = flight_mode_axis;
mapped->axes[kDjiFpvAxisC2Switch] = c2_axis;
mapped->buttons_length = 9;
mapped->axes_length = kDjiFpvAxisCount;
}
void MapperAcer(const Gamepad& input, Gamepad* mapped) {
*mapped = input;
mapped->buttons_length = BUTTON_INDEX_COUNT - 1;
mapped->axes_length = AXIS_INDEX_COUNT;
}
void MapperAcerAppMode(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] = input.buttons[8];
mapped->buttons[BUTTON_INDEX_RIGHT_TRIGGER] = input.buttons[9];
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[13];
mapped->buttons[BUTTON_INDEX_RIGHT_THUMBSTICK] = input.buttons[14];
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->buttons_length = BUTTON_INDEX_COUNT - 1;
mapped->axes_length = AXIS_INDEX_COUNT;
}
constexpr struct MappingData {
GamepadId gamepad_id;
GamepadStandardMappingFunction function;
} kAvailableMappings[] = {
{GamepadId::kPowerALicPro, MapperSwitchPro},
{GamepadId::kDragonRiseProduct0006, MapperDragonRiseGeneric},
{GamepadId::kHoriProduct00c1, MapperHoripadSwitch},
{GamepadId::kMicrosoftProduct02e0, MapperXboxOneS},
{GamepadId::kMicrosoftProduct02fd, MapperXboxOneS2016Firmware},
{GamepadId::kMicrosoftProduct0b05, MapperXboxElite2Bluetooth},
{GamepadId::kMicrosoftProduct0b13, MapperXboxSeriesXBluetooth},
{GamepadId::kMicrosoftProduct0b20, MapperXboxBluetooth},
{GamepadId::kMicrosoftProduct0b21, MapperXboxBluetooth},
{GamepadId::kMicrosoftProduct0b22, MapperXboxBluetooth},
{GamepadId::kLogitechProductc216, MapperLogitechDInput},
{GamepadId::kLogitechProductc218, MapperLogitechDInput},
{GamepadId::kLogitechProductc219, MapperLogitechDInput},
{GamepadId::kSamsungElectronicsProducta000, MapperSamsung_EI_GP20},
{GamepadId::kAcerProduct1304, MapperAcer},
{GamepadId::kAcerProduct1305, MapperAcer},
{GamepadId::kAcerProduct1316, MapperAcerAppMode},
{GamepadId::kAcerProduct1317, MapperAcerAppMode},
{GamepadId::kSonyProduct0268, MapperDualshock3SixAxis},
{GamepadId::kSonyProduct05c4, MapperDualshock4},
{GamepadId::kSonyProduct09cc, MapperDualshock4},
{GamepadId::kSonyProduct0ba0, MapperDualshock4},
{GamepadId::kSonyProduct0ce6, MapperDualSense},
{GamepadId::kSonyProduct0df2, MapperDualSense},
{GamepadId::kSonyProduct0e5f, MapperDualSense},
{GamepadId::kNintendoProduct2006, MapperSwitchJoyCon},
{GamepadId::kNintendoProduct2007, MapperSwitchJoyCon},
{GamepadId::kNintendoProduct2009, MapperSwitchPro},
{GamepadId::kNintendoProduct200e, MapperSwitchPro},
{GamepadId::kPadixProduct2060, MapperIBuffalo},
{GamepadId::kLakeviewResearchProduct0005, MapperLakeviewResearch},
{GamepadId::kLakeviewResearchProduct8866, MapperLakeviewResearch},
{GamepadId::kNvidiaProduct7210, MapperNvShield},
{GamepadId::kNvidiaProduct7214, MapperNvShield2017},
{GamepadId::kAsusTekProduct4500, MapperADT1},
{GamepadId::kPlayComProduct0005, MapperXSkills},
{GamepadId::kGreenAsiaProduct0003, MapperXGEAR},
{GamepadId::kSteelSeriesProduct1412, MapperSteelSeriesZeemote},
{GamepadId::kSteelSeriesProduct1418, MapperSteelSeriesStratusXLUsb},
{GamepadId::kSteelSeriesBtProduct1419, MapperSteelSeriesStratusBt},
{GamepadId::kSteelSeriesBtProduct1431, MapperSteelSeriesStratusBt},
{GamepadId::kSteelSeriesBtProduct1434, MapperSteelSeriesStratusPlusBt},
{GamepadId::kRazer1532Product0900, MapperRazerServal},
{GamepadId::kGoogleProduct2c40, MapperADT1},
{GamepadId::kGoogleProduct9400, MapperStadiaController},
{GamepadId::kBdaProduct6271, MapperMoga},
{GamepadId::kBdaProduct89e5, MapperMoga},
{GamepadId::kOnLiveProduct1008, MapperOnLiveWireless},
{GamepadId::kOnLiveProduct100a, MapperOnLiveWireless},
{GamepadId::kOuyaProduct0001, MapperOUYA},
{GamepadId::kDjiProduct1020, MapperDjiFpv},
{GamepadId::kScufProduct7725, MapperDualshock4},
{GamepadId::kPrototypeVendorProduct0667, MapperBoomN64Psx},
{GamepadId::kPrototypeVendorProduct9401, MapperStadiaControllerOldFirmware},
{GamepadId::kBroadcomProduct8502, MapperSnakebyteIDroidCon},
{GamepadId::kElecomProduct200f, MapperElecomWiredDirectInput},
{GamepadId::kElecomProduct2010, MapperElecomWirelessDirectInput},
};
}
GamepadStandardMappingFunction GetGamepadStandardMappingFunction(
std::string_view product_name,
const uint16_t vendor_id,
const uint16_t product_id,
const uint16_t hid_specification_version,
const uint16_t version_number,
GamepadBusType bus_type) {
GamepadId gamepad_id =
GamepadIdList::Get().GetGamepadId(product_name, vendor_id, product_id);
const auto* find_it = std::ranges::find(kAvailableMappings, gamepad_id,
&MappingData::gamepad_id);
GamepadStandardMappingFunction mapper =
(find_it == std::end(kAvailableMappings)) ? nullptr : find_it->function;
if (mapper == MapperDualshock4 &&
(hid_specification_version & kDualshockPatchedBcdHidMask)) {
mapper = MapperPs4Ps5;
} else if (mapper == MapperDualshock3SixAxis &&
(hid_specification_version & kDualshockPatchedBcdHidMask)) {
mapper = MapperDualshock3SixAxisNew;
} else if (mapper == MapperDualSense &&
(hid_specification_version & kDualshockPatchedBcdHidMask)) {
mapper = MapperPs4Ps5;
}
if (gamepad_id == GamepadId::kNintendoProduct200e &&
mapper == MapperSwitchPro && bus_type != GAMEPAD_BUS_USB) {
mapper = MapperSwitchComposite;
}
if (gamepad_id == GamepadId::kGoogleProduct9400 &&
mapper == MapperStadiaController &&
version_number == kStadiaControllerOldFirmwareVersion) {
mapper = MapperStadiaControllerOldFirmware;
}
if (mapper == nullptr) {
XInputType xtype =
GamepadIdList::Get().GetXInputType(vendor_id, product_id);
if (xtype == kXInputTypeXbox360 || xtype == kXInputTypeXboxOne)
mapper = MapperXInputStyleGamepad;
}
return mapper;
}
}