blob: ea41db972d8d6401987c9d989c2d7c5b325f8936 [file] [log] [blame]
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include <stddef.h>
#include "base/macros.h"
#include "device/gamepad/gamepad_standard_mappings.h"
namespace device {
namespace {
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 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[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->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; /* no meta */
mapped->axes_length = AXIS_INDEX_COUNT;
}
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[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] = NullButton();
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->axes[AXIS_INDEX_RIGHT_STICK_Y] = input.axes[3];
mapped->buttons_length = BUTTON_INDEX_COUNT - 1; /* no meta */
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; // no Meta on this device
mapped->axes_length = AXIS_INDEX_COUNT;
}
void MapperPlaystationSixAxis(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 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 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; /* no meta */
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; // no Meta on this device
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; // no Meta on this device
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 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; /* no meta */
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; /* no meta */
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 MapperSteelSeries(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;
}
struct MappingData {
const char* const vendor_id;
const char* const product_id;
GamepadStandardMappingFunction function;
} AvailableMappings[] = {
// http://www.linux-usb.org/usb.ids
{"0079", "0006", MapperDragonRiseGeneric}, // DragonRise Generic USB
{"045e", "028e", MapperXInputStyleGamepad}, // Xbox 360 Wired
{"045e", "028f", MapperXInputStyleGamepad}, // Xbox 360 Wireless
{"045e", "02a1", MapperXInputStyleGamepad}, // Xbox 360 Wireless
{"045e", "0291", MapperXInputStyleGamepad}, // Xbox 360 Wireless
{"045e", "02d1", MapperXInputStyleGamepad}, // Xbox One Wired
{"045e", "02dd", MapperXInputStyleGamepad}, // Xbox One Wired (2015 FW)
{"045e", "02e0", MapperXboxOneS2016Firmware}, // Xbox One S (Bluetooth)
{"045e", "02e3", MapperXInputStyleGamepad}, // Xbox One Elite Wired
{"045e", "02ea", MapperXInputStyleGamepad}, // Xbox One S (USB)
{"045e", "02fd", MapperXboxOneS}, // Xbox One S (Bluetooth)
{"045e", "0719", MapperXInputStyleGamepad}, // Xbox 360 Wireless
{"046d", "c21d", MapperXInputStyleGamepad}, // Logitech F310
{"046d", "c21e", MapperXInputStyleGamepad}, // Logitech F510
{"046d", "c21f", MapperXInputStyleGamepad}, // Logitech F710
{"04e8", "a000", MapperSamsung_EI_GP20}, // Samsung Gamepad EI-GP20
{"054c", "0268", MapperPlaystationSixAxis}, // Playstation SIXAXIS
{"054c", "05c4", MapperDualshock4}, // Playstation Dualshock 4
{"054c", "09cc", MapperDualshock4}, // Dualshock 4 (PS4 Slim)
{"0583", "2060", MapperIBuffalo}, // iBuffalo Classic
{"0925", "0005", MapperLakeviewResearch}, // SmartJoy PLUS Adapter
{"0925", "8866", MapperLakeviewResearch}, // WiseGroup MP-8866
{"0955", "7210", MapperNvShield}, // Nvidia Shield gamepad
{"0b05", "4500", MapperADT1}, // Nexus Player Controller
{"0e8f", "0003", MapperXGEAR}, // XFXforce XGEAR PS2 Controller
{"1038", "1412", MapperSteelSeries}, // Zeemote: SteelSeries FREE
{"1532", "0900", MapperRazerServal}, // Razer Serval Controller
{"18d1", "2c40", MapperADT1}, // ADT-1 Controller
{"20d6", "6271", MapperMoga}, // Moga Pro Controller (HID mode)
{"20d6", "89e5", MapperMoga}, // Moga 2 HID
{"2378", "1008", MapperOnLiveWireless}, // OnLive Controller (Bluetooth)
{"2378", "100a", MapperOnLiveWireless}, // OnLive Controller (Wired)
{"2836", "0001", MapperOUYA}, // OUYA Controller
};
} // namespace
GamepadStandardMappingFunction GetGamepadStandardMappingFunction(
const base::StringPiece& vendor_id,
const base::StringPiece& product_id) {
for (size_t i = 0; i < arraysize(AvailableMappings); ++i) {
MappingData& item = AvailableMappings[i];
if (vendor_id == item.vendor_id && product_id == item.product_id)
return item.function;
}
return NULL;
}
} // namespace device