| OLD | NEW |
| (Empty) |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include <stddef.h> | |
| 6 | |
| 7 #include "base/macros.h" | |
| 8 #include "content/browser/gamepad/gamepad_standard_mappings.h" | |
| 9 | |
| 10 namespace content { | |
| 11 | |
| 12 namespace { | |
| 13 | |
| 14 void MapperXInputStyleGamepad(const blink::WebGamepad& input, | |
| 15 blink::WebGamepad* mapped) { | |
| 16 *mapped = input; | |
| 17 mapped->buttons[BUTTON_INDEX_LEFT_TRIGGER] = AxisToButton(input.axes[2]); | |
| 18 mapped->buttons[BUTTON_INDEX_RIGHT_TRIGGER] = AxisToButton(input.axes[5]); | |
| 19 mapped->buttons[BUTTON_INDEX_BACK_SELECT] = input.buttons[6]; | |
| 20 mapped->buttons[BUTTON_INDEX_START] = input.buttons[7]; | |
| 21 mapped->buttons[BUTTON_INDEX_LEFT_THUMBSTICK] = input.buttons[9]; | |
| 22 mapped->buttons[BUTTON_INDEX_RIGHT_THUMBSTICK] = input.buttons[10]; | |
| 23 mapped->buttons[BUTTON_INDEX_DPAD_UP] = AxisNegativeAsButton(input.axes[7]); | |
| 24 mapped->buttons[BUTTON_INDEX_DPAD_DOWN] = AxisPositiveAsButton(input.axes[7]); | |
| 25 mapped->buttons[BUTTON_INDEX_DPAD_LEFT] = AxisNegativeAsButton(input.axes[6]); | |
| 26 mapped->buttons[BUTTON_INDEX_DPAD_RIGHT] = | |
| 27 AxisPositiveAsButton(input.axes[6]); | |
| 28 mapped->buttons[BUTTON_INDEX_META] = input.buttons[8]; | |
| 29 mapped->axes[AXIS_INDEX_RIGHT_STICK_X] = input.axes[3]; | |
| 30 mapped->axes[AXIS_INDEX_RIGHT_STICK_Y] = input.axes[4]; | |
| 31 mapped->buttonsLength = BUTTON_INDEX_COUNT; | |
| 32 mapped->axesLength = AXIS_INDEX_COUNT; | |
| 33 } | |
| 34 | |
| 35 void MapperLakeviewResearch(const blink::WebGamepad& input, | |
| 36 blink::WebGamepad* mapped) { | |
| 37 *mapped = input; | |
| 38 mapped->buttons[BUTTON_INDEX_PRIMARY] = input.buttons[2]; | |
| 39 mapped->buttons[BUTTON_INDEX_TERTIARY] = input.buttons[3]; | |
| 40 mapped->buttons[BUTTON_INDEX_QUATERNARY] = input.buttons[0]; | |
| 41 mapped->buttons[BUTTON_INDEX_LEFT_SHOULDER] = input.buttons[6]; | |
| 42 mapped->buttons[BUTTON_INDEX_RIGHT_SHOULDER] = input.buttons[7]; | |
| 43 mapped->buttons[BUTTON_INDEX_LEFT_TRIGGER] = input.buttons[4]; | |
| 44 mapped->buttons[BUTTON_INDEX_RIGHT_TRIGGER] = input.buttons[5]; | |
| 45 mapped->buttons[BUTTON_INDEX_BACK_SELECT] = input.buttons[9]; | |
| 46 mapped->buttons[BUTTON_INDEX_START] = input.buttons[8]; | |
| 47 mapped->buttons[BUTTON_INDEX_DPAD_UP] = AxisNegativeAsButton(input.axes[5]); | |
| 48 mapped->buttons[BUTTON_INDEX_DPAD_DOWN] = AxisPositiveAsButton(input.axes[5]); | |
| 49 mapped->buttons[BUTTON_INDEX_DPAD_LEFT] = AxisNegativeAsButton(input.axes[4]); | |
| 50 mapped->buttons[BUTTON_INDEX_DPAD_RIGHT] = | |
| 51 AxisPositiveAsButton(input.axes[4]); | |
| 52 mapped->buttonsLength = BUTTON_INDEX_COUNT - 1; // no Meta on this device | |
| 53 mapped->axesLength = AXIS_INDEX_COUNT; | |
| 54 } | |
| 55 | |
| 56 void MapperPlaystationSixAxis(const blink::WebGamepad& input, | |
| 57 blink::WebGamepad* mapped) { | |
| 58 *mapped = input; | |
| 59 mapped->buttons[BUTTON_INDEX_PRIMARY] = input.buttons[14]; | |
| 60 mapped->buttons[BUTTON_INDEX_SECONDARY] = input.buttons[13]; | |
| 61 mapped->buttons[BUTTON_INDEX_TERTIARY] = input.buttons[15]; | |
| 62 mapped->buttons[BUTTON_INDEX_QUATERNARY] = input.buttons[12]; | |
| 63 mapped->buttons[BUTTON_INDEX_LEFT_SHOULDER] = input.buttons[10]; | |
| 64 mapped->buttons[BUTTON_INDEX_RIGHT_SHOULDER] = input.buttons[11]; | |
| 65 mapped->buttons[BUTTON_INDEX_LEFT_TRIGGER] = AxisToButton(input.axes[12]); | |
| 66 mapped->buttons[BUTTON_INDEX_RIGHT_TRIGGER] = AxisToButton(input.axes[13]); | |
| 67 mapped->buttons[BUTTON_INDEX_BACK_SELECT] = input.buttons[0]; | |
| 68 mapped->buttons[BUTTON_INDEX_START] = input.buttons[3]; | |
| 69 mapped->buttons[BUTTON_INDEX_LEFT_THUMBSTICK] = input.buttons[1]; | |
| 70 mapped->buttons[BUTTON_INDEX_RIGHT_THUMBSTICK] = input.buttons[2]; | |
| 71 mapped->buttons[BUTTON_INDEX_DPAD_UP] = AxisToButton(input.axes[8]); | |
| 72 mapped->buttons[BUTTON_INDEX_DPAD_DOWN] = AxisToButton(input.axes[10]); | |
| 73 mapped->buttons[BUTTON_INDEX_DPAD_LEFT] = input.buttons[7]; | |
| 74 mapped->buttons[BUTTON_INDEX_DPAD_RIGHT] = AxisToButton(input.axes[9]); | |
| 75 mapped->buttons[BUTTON_INDEX_META] = input.buttons[16]; | |
| 76 | |
| 77 mapped->buttonsLength = BUTTON_INDEX_COUNT; | |
| 78 mapped->axesLength = AXIS_INDEX_COUNT; | |
| 79 } | |
| 80 | |
| 81 void MapperDualshock4(const blink::WebGamepad& input, | |
| 82 blink::WebGamepad* mapped) { | |
| 83 enum Dualshock4Buttons { | |
| 84 DUALSHOCK_BUTTON_TOUCHPAD = BUTTON_INDEX_COUNT, | |
| 85 DUALSHOCK_BUTTON_COUNT | |
| 86 }; | |
| 87 | |
| 88 *mapped = input; | |
| 89 mapped->buttons[BUTTON_INDEX_PRIMARY] = input.buttons[1]; | |
| 90 mapped->buttons[BUTTON_INDEX_SECONDARY] = input.buttons[2]; | |
| 91 mapped->buttons[BUTTON_INDEX_TERTIARY] = input.buttons[0]; | |
| 92 mapped->buttons[BUTTON_INDEX_QUATERNARY] = input.buttons[3]; | |
| 93 mapped->buttons[BUTTON_INDEX_LEFT_SHOULDER] = input.buttons[4]; | |
| 94 mapped->buttons[BUTTON_INDEX_RIGHT_SHOULDER] = input.buttons[5]; | |
| 95 mapped->buttons[BUTTON_INDEX_LEFT_TRIGGER] = AxisToButton(input.axes[3]); | |
| 96 mapped->buttons[BUTTON_INDEX_RIGHT_TRIGGER] = AxisToButton(input.axes[4]); | |
| 97 mapped->buttons[BUTTON_INDEX_BACK_SELECT] = input.buttons[8]; | |
| 98 mapped->buttons[BUTTON_INDEX_START] = input.buttons[9]; | |
| 99 mapped->buttons[BUTTON_INDEX_LEFT_THUMBSTICK] = input.buttons[10]; | |
| 100 mapped->buttons[BUTTON_INDEX_RIGHT_THUMBSTICK] = input.buttons[11]; | |
| 101 mapped->buttons[BUTTON_INDEX_DPAD_UP] = AxisNegativeAsButton(input.axes[7]); | |
| 102 mapped->buttons[BUTTON_INDEX_DPAD_DOWN] = AxisPositiveAsButton(input.axes[7]); | |
| 103 mapped->buttons[BUTTON_INDEX_DPAD_LEFT] = AxisNegativeAsButton(input.axes[6]); | |
| 104 mapped->buttons[BUTTON_INDEX_DPAD_RIGHT] = | |
| 105 AxisPositiveAsButton(input.axes[6]); | |
| 106 mapped->buttons[BUTTON_INDEX_META] = input.buttons[12]; | |
| 107 mapped->buttons[DUALSHOCK_BUTTON_TOUCHPAD] = input.buttons[13]; | |
| 108 mapped->axes[AXIS_INDEX_RIGHT_STICK_Y] = input.axes[5]; | |
| 109 | |
| 110 mapped->buttonsLength = DUALSHOCK_BUTTON_COUNT; | |
| 111 mapped->axesLength = AXIS_INDEX_COUNT; | |
| 112 } | |
| 113 | |
| 114 void MapperIBuffalo(const blink::WebGamepad& input, blink::WebGamepad* mapped) { | |
| 115 *mapped = input; | |
| 116 mapped->buttons[BUTTON_INDEX_PRIMARY] = input.buttons[1]; | |
| 117 mapped->buttons[BUTTON_INDEX_SECONDARY] = input.buttons[0]; | |
| 118 mapped->buttons[BUTTON_INDEX_TERTIARY] = input.buttons[3]; | |
| 119 mapped->buttons[BUTTON_INDEX_QUATERNARY] = input.buttons[2]; | |
| 120 mapped->buttons[BUTTON_INDEX_BACK_SELECT] = input.buttons[6]; | |
| 121 mapped->buttons[BUTTON_INDEX_START] = input.buttons[7]; | |
| 122 mapped->buttons[BUTTON_INDEX_LEFT_TRIGGER] = input.buttons[4]; | |
| 123 mapped->buttons[BUTTON_INDEX_RIGHT_TRIGGER] = input.buttons[5]; | |
| 124 mapped->buttons[BUTTON_INDEX_DPAD_UP] = AxisNegativeAsButton(input.axes[1]); | |
| 125 mapped->buttons[BUTTON_INDEX_DPAD_DOWN] = AxisPositiveAsButton(input.axes[1]); | |
| 126 mapped->buttons[BUTTON_INDEX_DPAD_LEFT] = AxisNegativeAsButton(input.axes[0]); | |
| 127 mapped->buttons[BUTTON_INDEX_DPAD_RIGHT] = | |
| 128 AxisPositiveAsButton(input.axes[0]); | |
| 129 mapped->buttonsLength = BUTTON_INDEX_COUNT - 1; /* no meta */ | |
| 130 mapped->axesLength = 2; | |
| 131 } | |
| 132 | |
| 133 | |
| 134 void MapperXGEAR(const blink::WebGamepad& input, blink::WebGamepad* mapped) { | |
| 135 *mapped = input; | |
| 136 mapped->buttons[BUTTON_INDEX_PRIMARY] = input.buttons[2]; | |
| 137 mapped->buttons[BUTTON_INDEX_SECONDARY] = input.buttons[1]; | |
| 138 mapped->buttons[BUTTON_INDEX_TERTIARY] = input.buttons[3]; | |
| 139 mapped->buttons[BUTTON_INDEX_QUATERNARY] = input.buttons[0]; | |
| 140 mapped->buttons[BUTTON_INDEX_LEFT_SHOULDER] = input.buttons[6]; | |
| 141 mapped->buttons[BUTTON_INDEX_RIGHT_SHOULDER] = input.buttons[7]; | |
| 142 mapped->buttons[BUTTON_INDEX_LEFT_TRIGGER] = input.buttons[4]; | |
| 143 mapped->buttons[BUTTON_INDEX_RIGHT_TRIGGER] = input.buttons[5]; | |
| 144 mapped->buttons[BUTTON_INDEX_DPAD_UP] = AxisNegativeAsButton(input.axes[5]); | |
| 145 mapped->buttons[BUTTON_INDEX_DPAD_DOWN] = AxisPositiveAsButton(input.axes[5]); | |
| 146 mapped->buttons[BUTTON_INDEX_DPAD_LEFT] = AxisNegativeAsButton(input.axes[4]); | |
| 147 mapped->buttons[BUTTON_INDEX_DPAD_RIGHT] = | |
| 148 AxisPositiveAsButton(input.axes[4]); | |
| 149 mapped->axes[AXIS_INDEX_RIGHT_STICK_X] = input.axes[3]; | |
| 150 mapped->axes[AXIS_INDEX_RIGHT_STICK_Y] = input.axes[2]; | |
| 151 mapped->buttonsLength = BUTTON_INDEX_COUNT - 1; // no Meta on this device | |
| 152 mapped->axesLength = AXIS_INDEX_COUNT; | |
| 153 } | |
| 154 | |
| 155 void MapperDragonRiseGeneric(const blink::WebGamepad& input, | |
| 156 blink::WebGamepad* mapped) { | |
| 157 *mapped = input; | |
| 158 mapped->buttons[BUTTON_INDEX_DPAD_UP] = AxisNegativeAsButton(input.axes[6]); | |
| 159 mapped->buttons[BUTTON_INDEX_DPAD_DOWN] = AxisPositiveAsButton(input.axes[6]); | |
| 160 mapped->buttons[BUTTON_INDEX_DPAD_LEFT] = AxisNegativeAsButton(input.axes[5]); | |
| 161 mapped->buttons[BUTTON_INDEX_DPAD_RIGHT] = | |
| 162 AxisPositiveAsButton(input.axes[5]); | |
| 163 mapped->axes[AXIS_INDEX_LEFT_STICK_X] = input.axes[0]; | |
| 164 mapped->axes[AXIS_INDEX_LEFT_STICK_Y] = input.axes[1]; | |
| 165 mapped->axes[AXIS_INDEX_RIGHT_STICK_X] = input.axes[3]; | |
| 166 mapped->axes[AXIS_INDEX_RIGHT_STICK_Y] = input.axes[4]; | |
| 167 mapped->buttonsLength = BUTTON_INDEX_COUNT - 1; // no Meta on this device | |
| 168 mapped->axesLength = AXIS_INDEX_COUNT; | |
| 169 } | |
| 170 | |
| 171 void MapperOnLiveWireless(const blink::WebGamepad& input, | |
| 172 blink::WebGamepad* mapped) { | |
| 173 *mapped = input; | |
| 174 mapped->buttons[BUTTON_INDEX_LEFT_TRIGGER] = AxisToButton(input.axes[2]); | |
| 175 mapped->buttons[BUTTON_INDEX_RIGHT_TRIGGER] = AxisToButton(input.axes[5]); | |
| 176 mapped->buttons[BUTTON_INDEX_BACK_SELECT] = input.buttons[6]; | |
| 177 mapped->buttons[BUTTON_INDEX_START] = input.buttons[7]; | |
| 178 mapped->buttons[BUTTON_INDEX_LEFT_THUMBSTICK] = input.buttons[9]; | |
| 179 mapped->buttons[BUTTON_INDEX_RIGHT_THUMBSTICK] = input.buttons[10]; | |
| 180 mapped->buttons[BUTTON_INDEX_DPAD_UP] = AxisNegativeAsButton(input.axes[7]); | |
| 181 mapped->buttons[BUTTON_INDEX_DPAD_DOWN] = AxisPositiveAsButton(input.axes[7]); | |
| 182 mapped->buttons[BUTTON_INDEX_DPAD_LEFT] = AxisNegativeAsButton(input.axes[6]); | |
| 183 mapped->buttons[BUTTON_INDEX_DPAD_RIGHT] = | |
| 184 AxisPositiveAsButton(input.axes[6]); | |
| 185 mapped->buttons[BUTTON_INDEX_META] = input.buttons[8]; | |
| 186 mapped->axes[AXIS_INDEX_RIGHT_STICK_X] = input.axes[3]; | |
| 187 mapped->axes[AXIS_INDEX_RIGHT_STICK_Y] = input.axes[4]; | |
| 188 | |
| 189 mapped->buttonsLength = BUTTON_INDEX_COUNT; | |
| 190 mapped->axesLength = AXIS_INDEX_COUNT; | |
| 191 } | |
| 192 | |
| 193 void MapperADT1(const blink::WebGamepad& input, blink::WebGamepad* mapped) { | |
| 194 *mapped = input; | |
| 195 mapped->buttons[BUTTON_INDEX_LEFT_TRIGGER] = AxisToButton(input.axes[5]); | |
| 196 mapped->buttons[BUTTON_INDEX_RIGHT_TRIGGER] = AxisToButton(input.axes[4]); | |
| 197 mapped->buttons[BUTTON_INDEX_BACK_SELECT] = NullButton(); | |
| 198 mapped->buttons[BUTTON_INDEX_START] = NullButton(); | |
| 199 mapped->buttons[BUTTON_INDEX_LEFT_THUMBSTICK] = input.buttons[7]; | |
| 200 mapped->buttons[BUTTON_INDEX_RIGHT_THUMBSTICK] = input.buttons[8]; | |
| 201 mapped->buttons[BUTTON_INDEX_DPAD_UP] = AxisNegativeAsButton(input.axes[7]); | |
| 202 mapped->buttons[BUTTON_INDEX_DPAD_DOWN] = AxisPositiveAsButton(input.axes[7]); | |
| 203 mapped->buttons[BUTTON_INDEX_DPAD_LEFT] = AxisNegativeAsButton(input.axes[6]); | |
| 204 mapped->buttons[BUTTON_INDEX_DPAD_RIGHT] = | |
| 205 AxisPositiveAsButton(input.axes[6]); | |
| 206 mapped->buttons[BUTTON_INDEX_META] = input.buttons[6]; | |
| 207 | |
| 208 mapped->buttonsLength = BUTTON_INDEX_COUNT; | |
| 209 mapped->axesLength = AXIS_INDEX_COUNT; | |
| 210 } | |
| 211 | |
| 212 void MapperNvShield(const blink::WebGamepad& input, blink::WebGamepad* mapped) { | |
| 213 *mapped = input; | |
| 214 mapped->buttons[BUTTON_INDEX_LEFT_TRIGGER] = AxisToButton(input.axes[5]); | |
| 215 mapped->buttons[BUTTON_INDEX_RIGHT_TRIGGER] = AxisToButton(input.axes[4]); | |
| 216 mapped->buttons[BUTTON_INDEX_BACK_SELECT] = NullButton(); | |
| 217 mapped->buttons[BUTTON_INDEX_START] = input.buttons[7]; | |
| 218 mapped->buttons[BUTTON_INDEX_LEFT_THUMBSTICK] = input.buttons[8]; | |
| 219 mapped->buttons[BUTTON_INDEX_RIGHT_THUMBSTICK] = input.buttons[9]; | |
| 220 mapped->buttons[BUTTON_INDEX_DPAD_UP] = AxisNegativeAsButton(input.axes[7]); | |
| 221 mapped->buttons[BUTTON_INDEX_DPAD_DOWN] = AxisPositiveAsButton(input.axes[7]); | |
| 222 mapped->buttons[BUTTON_INDEX_DPAD_LEFT] = AxisNegativeAsButton(input.axes[6]); | |
| 223 mapped->buttons[BUTTON_INDEX_DPAD_RIGHT] = | |
| 224 AxisPositiveAsButton(input.axes[6]); | |
| 225 mapped->buttons[BUTTON_INDEX_META] = input.buttons[6]; | |
| 226 | |
| 227 mapped->buttonsLength = BUTTON_INDEX_COUNT; | |
| 228 mapped->axesLength = AXIS_INDEX_COUNT; | |
| 229 } | |
| 230 | |
| 231 void MapperOUYA(const blink::WebGamepad& input, blink::WebGamepad* mapped) { | |
| 232 *mapped = input; | |
| 233 mapped->buttons[BUTTON_INDEX_PRIMARY] = input.buttons[0]; | |
| 234 mapped->buttons[BUTTON_INDEX_SECONDARY] = input.buttons[3]; | |
| 235 mapped->buttons[BUTTON_INDEX_TERTIARY] = input.buttons[1]; | |
| 236 mapped->buttons[BUTTON_INDEX_QUATERNARY] = input.buttons[2]; | |
| 237 mapped->buttons[BUTTON_INDEX_LEFT_SHOULDER] = input.buttons[4]; | |
| 238 mapped->buttons[BUTTON_INDEX_RIGHT_SHOULDER] = input.buttons[5]; | |
| 239 mapped->buttons[BUTTON_INDEX_LEFT_TRIGGER] = AxisToButton(input.axes[2]); | |
| 240 mapped->buttons[BUTTON_INDEX_RIGHT_TRIGGER] = AxisToButton(input.axes[5]); | |
| 241 mapped->buttons[BUTTON_INDEX_BACK_SELECT] = NullButton(); | |
| 242 mapped->buttons[BUTTON_INDEX_START] = NullButton(); | |
| 243 mapped->buttons[BUTTON_INDEX_LEFT_THUMBSTICK] = input.buttons[6]; | |
| 244 mapped->buttons[BUTTON_INDEX_RIGHT_THUMBSTICK] = input.buttons[7]; | |
| 245 mapped->buttons[BUTTON_INDEX_DPAD_UP] = input.buttons[8]; | |
| 246 mapped->buttons[BUTTON_INDEX_DPAD_DOWN] = input.buttons[9]; | |
| 247 mapped->buttons[BUTTON_INDEX_DPAD_LEFT] = input.buttons[10]; | |
| 248 mapped->buttons[BUTTON_INDEX_DPAD_RIGHT] = input.buttons[11]; | |
| 249 mapped->buttons[BUTTON_INDEX_META] = input.buttons[15]; | |
| 250 mapped->axes[AXIS_INDEX_RIGHT_STICK_X] = input.axes[3]; | |
| 251 mapped->axes[AXIS_INDEX_RIGHT_STICK_Y] = input.axes[4]; | |
| 252 | |
| 253 mapped->buttonsLength = BUTTON_INDEX_COUNT; | |
| 254 mapped->axesLength = AXIS_INDEX_COUNT; | |
| 255 } | |
| 256 | |
| 257 void MapperRazerServal(const blink::WebGamepad& input, | |
| 258 blink::WebGamepad* mapped) { | |
| 259 *mapped = input; | |
| 260 mapped->buttons[BUTTON_INDEX_LEFT_TRIGGER] = AxisToButton(input.axes[5]); | |
| 261 mapped->buttons[BUTTON_INDEX_RIGHT_TRIGGER] = AxisToButton(input.axes[4]); | |
| 262 mapped->buttons[BUTTON_INDEX_BACK_SELECT] = input.buttons[6]; | |
| 263 mapped->buttons[BUTTON_INDEX_START] = input.buttons[7]; | |
| 264 mapped->buttons[BUTTON_INDEX_LEFT_THUMBSTICK] = input.buttons[9]; | |
| 265 mapped->buttons[BUTTON_INDEX_RIGHT_THUMBSTICK] = input.buttons[10]; | |
| 266 mapped->buttons[BUTTON_INDEX_DPAD_UP] = AxisNegativeAsButton(input.axes[7]); | |
| 267 mapped->buttons[BUTTON_INDEX_DPAD_DOWN] = AxisPositiveAsButton(input.axes[7]); | |
| 268 mapped->buttons[BUTTON_INDEX_DPAD_LEFT] = AxisNegativeAsButton(input.axes[6]); | |
| 269 mapped->buttons[BUTTON_INDEX_DPAD_RIGHT] = | |
| 270 AxisPositiveAsButton(input.axes[6]); | |
| 271 | |
| 272 mapped->buttonsLength = BUTTON_INDEX_COUNT - 1; /* no meta */ | |
| 273 mapped->axesLength = AXIS_INDEX_COUNT; | |
| 274 } | |
| 275 | |
| 276 void MapperMogaPro(const blink::WebGamepad& input, blink::WebGamepad* mapped) { | |
| 277 *mapped = input; | |
| 278 mapped->buttons[BUTTON_INDEX_LEFT_TRIGGER] = AxisToButton(input.axes[5]); | |
| 279 mapped->buttons[BUTTON_INDEX_RIGHT_TRIGGER] = AxisToButton(input.axes[4]); | |
| 280 mapped->buttons[BUTTON_INDEX_BACK_SELECT] = NullButton(); | |
| 281 mapped->buttons[BUTTON_INDEX_START] = input.buttons[6]; | |
| 282 mapped->buttons[BUTTON_INDEX_LEFT_THUMBSTICK] = input.buttons[7]; | |
| 283 mapped->buttons[BUTTON_INDEX_RIGHT_THUMBSTICK] = input.buttons[8]; | |
| 284 mapped->buttons[BUTTON_INDEX_DPAD_UP] = AxisNegativeAsButton(input.axes[7]); | |
| 285 mapped->buttons[BUTTON_INDEX_DPAD_DOWN] = AxisPositiveAsButton(input.axes[7]); | |
| 286 mapped->buttons[BUTTON_INDEX_DPAD_LEFT] = AxisNegativeAsButton(input.axes[6]); | |
| 287 mapped->buttons[BUTTON_INDEX_DPAD_RIGHT] = | |
| 288 AxisPositiveAsButton(input.axes[6]); | |
| 289 | |
| 290 mapped->buttonsLength = BUTTON_INDEX_COUNT - 1; /* no meta */ | |
| 291 mapped->axesLength = AXIS_INDEX_COUNT; | |
| 292 } | |
| 293 | |
| 294 struct MappingData { | |
| 295 const char* const vendor_id; | |
| 296 const char* const product_id; | |
| 297 GamepadStandardMappingFunction function; | |
| 298 } AvailableMappings[] = { | |
| 299 // http://www.linux-usb.org/usb.ids | |
| 300 {"0079", "0006", MapperDragonRiseGeneric}, // DragonRise Generic USB | |
| 301 {"045e", "028e", MapperXInputStyleGamepad}, // Xbox 360 Wired | |
| 302 {"045e", "028f", MapperXInputStyleGamepad}, // Xbox 360 Wireless | |
| 303 {"045e", "0719", MapperXInputStyleGamepad}, // Xbox 360 Wireless | |
| 304 {"046d", "c21d", MapperXInputStyleGamepad}, // Logitech F310 | |
| 305 {"046d", "c21e", MapperXInputStyleGamepad}, // Logitech F510 | |
| 306 {"046d", "c21f", MapperXInputStyleGamepad}, // Logitech F710 | |
| 307 {"054c", "0268", MapperPlaystationSixAxis}, // Playstation SIXAXIS | |
| 308 {"054c", "05c4", MapperDualshock4}, // Playstation Dualshock 4 | |
| 309 {"0583", "2060", MapperIBuffalo}, // iBuffalo Classic | |
| 310 {"0925", "0005", MapperLakeviewResearch}, // SmartJoy PLUS Adapter | |
| 311 {"0925", "8866", MapperLakeviewResearch}, // WiseGroup MP-8866 | |
| 312 {"0955", "7210", MapperNvShield}, // Nvidia Shield gamepad | |
| 313 {"0b05", "4500", MapperADT1}, // Nexus Player Controller | |
| 314 {"0e8f", "0003", MapperXGEAR}, // XFXforce XGEAR PS2 Controller | |
| 315 {"1532", "0900", MapperRazerServal}, // Razer Serval Controller | |
| 316 {"18d1", "2c40", MapperADT1}, // ADT-1 Controller | |
| 317 {"20d6", "6271", MapperMogaPro}, // Moga Pro Controller (HID mode) | |
| 318 {"2378", "1008", MapperOnLiveWireless}, // OnLive Controller (Bluetooth) | |
| 319 {"2378", "100a", MapperOnLiveWireless}, // OnLive Controller (Wired) | |
| 320 {"2836", "0001", MapperOUYA}, // OUYA Controller | |
| 321 }; | |
| 322 | |
| 323 } // namespace | |
| 324 | |
| 325 GamepadStandardMappingFunction GetGamepadStandardMappingFunction( | |
| 326 const base::StringPiece& vendor_id, | |
| 327 const base::StringPiece& product_id) { | |
| 328 for (size_t i = 0; i < arraysize(AvailableMappings); ++i) { | |
| 329 MappingData& item = AvailableMappings[i]; | |
| 330 if (vendor_id == item.vendor_id && product_id == item.product_id) | |
| 331 return item.function; | |
| 332 } | |
| 333 return NULL; | |
| 334 } | |
| 335 | |
| 336 } // namespace content | |
| OLD | NEW |