| 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 MapperXbox360Gamepad(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[9]; | |
| 20 mapped->buttons[BUTTON_INDEX_START] = input.buttons[8]; | |
| 21 mapped->buttons[BUTTON_INDEX_LEFT_THUMBSTICK] = input.buttons[6]; | |
| 22 mapped->buttons[BUTTON_INDEX_RIGHT_THUMBSTICK] = input.buttons[7]; | |
| 23 mapped->buttons[BUTTON_INDEX_DPAD_UP] = input.buttons[11]; | |
| 24 mapped->buttons[BUTTON_INDEX_DPAD_DOWN] = input.buttons[12]; | |
| 25 mapped->buttons[BUTTON_INDEX_DPAD_LEFT] = input.buttons[13]; | |
| 26 mapped->buttons[BUTTON_INDEX_DPAD_RIGHT] = input.buttons[14]; | |
| 27 mapped->buttons[BUTTON_INDEX_META] = input.buttons[10]; | |
| 28 mapped->axes[AXIS_INDEX_RIGHT_STICK_X] = input.axes[3]; | |
| 29 mapped->axes[AXIS_INDEX_RIGHT_STICK_Y] = input.axes[4]; | |
| 30 mapped->buttonsLength = BUTTON_INDEX_COUNT; | |
| 31 mapped->axesLength = AXIS_INDEX_COUNT; | |
| 32 } | |
| 33 | |
| 34 void MapperPlaystationSixAxis(const blink::WebGamepad& input, | |
| 35 blink::WebGamepad* mapped) { | |
| 36 *mapped = input; | |
| 37 mapped->buttons[BUTTON_INDEX_PRIMARY] = input.buttons[14]; | |
| 38 mapped->buttons[BUTTON_INDEX_SECONDARY] = input.buttons[13]; | |
| 39 mapped->buttons[BUTTON_INDEX_TERTIARY] = input.buttons[15]; | |
| 40 mapped->buttons[BUTTON_INDEX_QUATERNARY] = input.buttons[12]; | |
| 41 mapped->buttons[BUTTON_INDEX_LEFT_SHOULDER] = input.buttons[10]; | |
| 42 mapped->buttons[BUTTON_INDEX_RIGHT_SHOULDER] = input.buttons[11]; | |
| 43 | |
| 44 mapped->buttons[BUTTON_INDEX_LEFT_TRIGGER] = | |
| 45 ButtonFromButtonAndAxis(input.buttons[8], input.axes[14]); | |
| 46 mapped->buttons[BUTTON_INDEX_RIGHT_TRIGGER] = | |
| 47 ButtonFromButtonAndAxis(input.buttons[9], input.axes[15]); | |
| 48 | |
| 49 mapped->buttons[BUTTON_INDEX_BACK_SELECT] = input.buttons[0]; | |
| 50 mapped->buttons[BUTTON_INDEX_START] = input.buttons[3]; | |
| 51 mapped->buttons[BUTTON_INDEX_LEFT_THUMBSTICK] = input.buttons[1]; | |
| 52 mapped->buttons[BUTTON_INDEX_RIGHT_THUMBSTICK] = input.buttons[2]; | |
| 53 | |
| 54 // The SixAxis Dpad is pressure sensitive. | |
| 55 mapped->buttons[BUTTON_INDEX_DPAD_UP] = | |
| 56 ButtonFromButtonAndAxis(input.buttons[4], input.axes[10]); | |
| 57 mapped->buttons[BUTTON_INDEX_DPAD_DOWN] = | |
| 58 ButtonFromButtonAndAxis(input.buttons[6], input.axes[12]); | |
| 59 mapped->buttons[BUTTON_INDEX_DPAD_LEFT] = | |
| 60 ButtonFromButtonAndAxis(input.buttons[7], input.axes[13]); | |
| 61 mapped->buttons[BUTTON_INDEX_DPAD_RIGHT] = | |
| 62 ButtonFromButtonAndAxis(input.buttons[5], input.axes[11]); | |
| 63 | |
| 64 mapped->buttons[BUTTON_INDEX_META] = input.buttons[16]; | |
| 65 mapped->axes[AXIS_INDEX_RIGHT_STICK_Y] = input.axes[5]; | |
| 66 | |
| 67 mapped->buttonsLength = BUTTON_INDEX_COUNT; | |
| 68 mapped->axesLength = AXIS_INDEX_COUNT; | |
| 69 } | |
| 70 | |
| 71 void MapperDualshock4(const blink::WebGamepad& input, | |
| 72 blink::WebGamepad* mapped) { | |
| 73 enum Dualshock4Buttons { | |
| 74 DUALSHOCK_BUTTON_TOUCHPAD = BUTTON_INDEX_COUNT, | |
| 75 DUALSHOCK_BUTTON_COUNT | |
| 76 }; | |
| 77 | |
| 78 *mapped = input; | |
| 79 mapped->buttons[BUTTON_INDEX_PRIMARY] = input.buttons[1]; | |
| 80 mapped->buttons[BUTTON_INDEX_SECONDARY] = input.buttons[2]; | |
| 81 mapped->buttons[BUTTON_INDEX_TERTIARY] = input.buttons[0]; | |
| 82 mapped->buttons[BUTTON_INDEX_QUATERNARY] = input.buttons[3]; | |
| 83 mapped->buttons[BUTTON_INDEX_LEFT_SHOULDER] = input.buttons[4]; | |
| 84 mapped->buttons[BUTTON_INDEX_RIGHT_SHOULDER] = input.buttons[5]; | |
| 85 mapped->buttons[BUTTON_INDEX_LEFT_TRIGGER] = AxisToButton(input.axes[3]); | |
| 86 mapped->buttons[BUTTON_INDEX_RIGHT_TRIGGER] = AxisToButton(input.axes[4]); | |
| 87 mapped->buttons[BUTTON_INDEX_BACK_SELECT] = input.buttons[8]; | |
| 88 mapped->buttons[BUTTON_INDEX_START] = input.buttons[9]; | |
| 89 mapped->buttons[BUTTON_INDEX_LEFT_THUMBSTICK] = input.buttons[10]; | |
| 90 mapped->buttons[BUTTON_INDEX_RIGHT_THUMBSTICK] = input.buttons[11]; | |
| 91 mapped->buttons[BUTTON_INDEX_META] = input.buttons[12]; | |
| 92 mapped->buttons[DUALSHOCK_BUTTON_TOUCHPAD] = input.buttons[13]; | |
| 93 mapped->axes[AXIS_INDEX_RIGHT_STICK_Y] = input.axes[5]; | |
| 94 DpadFromAxis(mapped, input.axes[9]); | |
| 95 | |
| 96 mapped->buttonsLength = DUALSHOCK_BUTTON_COUNT; | |
| 97 mapped->axesLength = AXIS_INDEX_COUNT; | |
| 98 } | |
| 99 | |
| 100 void MapperIBuffalo(const blink::WebGamepad& input, blink::WebGamepad* mapped) { | |
| 101 *mapped = input; | |
| 102 mapped->buttons[BUTTON_INDEX_PRIMARY] = input.buttons[1]; | |
| 103 mapped->buttons[BUTTON_INDEX_SECONDARY] = input.buttons[0]; | |
| 104 mapped->buttons[BUTTON_INDEX_TERTIARY] = input.buttons[3]; | |
| 105 mapped->buttons[BUTTON_INDEX_QUATERNARY] = input.buttons[2]; | |
| 106 mapped->buttons[BUTTON_INDEX_BACK_SELECT] = input.buttons[6]; | |
| 107 mapped->buttons[BUTTON_INDEX_START] = input.buttons[7]; | |
| 108 mapped->buttons[BUTTON_INDEX_LEFT_TRIGGER] = input.buttons[4]; | |
| 109 mapped->buttons[BUTTON_INDEX_RIGHT_TRIGGER] = input.buttons[5]; | |
| 110 mapped->buttons[BUTTON_INDEX_DPAD_UP] = AxisNegativeAsButton(input.axes[1]); | |
| 111 mapped->buttons[BUTTON_INDEX_DPAD_DOWN] = AxisPositiveAsButton(input.axes[1]); | |
| 112 mapped->buttons[BUTTON_INDEX_DPAD_LEFT] = AxisNegativeAsButton(input.axes[0]); | |
| 113 mapped->buttons[BUTTON_INDEX_DPAD_RIGHT] = | |
| 114 AxisPositiveAsButton(input.axes[0]); | |
| 115 mapped->buttonsLength = BUTTON_INDEX_COUNT - 1; /* no meta */ | |
| 116 mapped->axesLength = 2; | |
| 117 } | |
| 118 | |
| 119 void MapperDirectInputStyle(const blink::WebGamepad& input, | |
| 120 blink::WebGamepad* mapped) { | |
| 121 *mapped = input; | |
| 122 mapped->buttons[BUTTON_INDEX_PRIMARY] = input.buttons[1]; | |
| 123 mapped->buttons[BUTTON_INDEX_SECONDARY] = input.buttons[2]; | |
| 124 mapped->buttons[BUTTON_INDEX_TERTIARY] = input.buttons[0]; | |
| 125 mapped->axes[AXIS_INDEX_RIGHT_STICK_Y] = input.axes[5]; | |
| 126 DpadFromAxis(mapped, input.axes[9]); | |
| 127 mapped->buttonsLength = BUTTON_INDEX_COUNT - 1; /* no meta */ | |
| 128 mapped->axesLength = AXIS_INDEX_COUNT; | |
| 129 } | |
| 130 | |
| 131 void MapperMacallyIShock(const blink::WebGamepad& input, | |
| 132 blink::WebGamepad* mapped) { | |
| 133 enum IShockButtons { | |
| 134 ISHOCK_BUTTON_C = BUTTON_INDEX_COUNT, | |
| 135 ISHOCK_BUTTON_D, | |
| 136 ISHOCK_BUTTON_E, | |
| 137 ISHOCK_BUTTON_COUNT, | |
| 138 }; | |
| 139 | |
| 140 *mapped = input; | |
| 141 mapped->buttons[BUTTON_INDEX_PRIMARY] = input.buttons[6]; | |
| 142 mapped->buttons[BUTTON_INDEX_SECONDARY] = input.buttons[5]; | |
| 143 mapped->buttons[BUTTON_INDEX_TERTIARY] = input.buttons[7]; | |
| 144 mapped->buttons[BUTTON_INDEX_QUATERNARY] = input.buttons[4]; | |
| 145 mapped->buttons[BUTTON_INDEX_LEFT_SHOULDER] = input.buttons[14]; | |
| 146 mapped->buttons[BUTTON_INDEX_RIGHT_SHOULDER] = input.buttons[12]; | |
| 147 mapped->buttons[BUTTON_INDEX_LEFT_TRIGGER] = input.buttons[15]; | |
| 148 mapped->buttons[BUTTON_INDEX_RIGHT_TRIGGER] = input.buttons[13]; | |
| 149 mapped->buttons[BUTTON_INDEX_BACK_SELECT] = input.buttons[9]; | |
| 150 mapped->buttons[BUTTON_INDEX_START] = input.buttons[10]; | |
| 151 mapped->buttons[BUTTON_INDEX_LEFT_THUMBSTICK] = input.buttons[16]; | |
| 152 mapped->buttons[BUTTON_INDEX_RIGHT_THUMBSTICK] = input.buttons[17]; | |
| 153 mapped->buttons[BUTTON_INDEX_DPAD_UP] = input.buttons[0]; | |
| 154 mapped->buttons[BUTTON_INDEX_DPAD_DOWN] = input.buttons[1]; | |
| 155 mapped->buttons[BUTTON_INDEX_DPAD_LEFT] = input.buttons[2]; | |
| 156 mapped->buttons[BUTTON_INDEX_DPAD_RIGHT] = input.buttons[3]; | |
| 157 mapped->buttons[BUTTON_INDEX_META] = input.buttons[11]; | |
| 158 mapped->buttons[ISHOCK_BUTTON_C] = input.buttons[8]; | |
| 159 mapped->buttons[ISHOCK_BUTTON_D] = input.buttons[18]; | |
| 160 mapped->buttons[ISHOCK_BUTTON_E] = input.buttons[19]; | |
| 161 mapped->axes[AXIS_INDEX_LEFT_STICK_X] = input.axes[0]; | |
| 162 mapped->axes[AXIS_INDEX_LEFT_STICK_Y] = input.axes[1]; | |
| 163 mapped->axes[AXIS_INDEX_RIGHT_STICK_X] = -input.axes[5]; | |
| 164 mapped->axes[AXIS_INDEX_RIGHT_STICK_Y] = input.axes[6]; | |
| 165 | |
| 166 mapped->buttonsLength = ISHOCK_BUTTON_COUNT; | |
| 167 mapped->axesLength = AXIS_INDEX_COUNT; | |
| 168 } | |
| 169 | |
| 170 void MapperXGEAR(const blink::WebGamepad& input, blink::WebGamepad* mapped) { | |
| 171 *mapped = input; | |
| 172 mapped->buttons[BUTTON_INDEX_PRIMARY] = input.buttons[2]; | |
| 173 mapped->buttons[BUTTON_INDEX_TERTIARY] = input.buttons[3]; | |
| 174 mapped->buttons[BUTTON_INDEX_QUATERNARY] = input.buttons[0]; | |
| 175 mapped->buttons[BUTTON_INDEX_LEFT_SHOULDER] = input.buttons[6]; | |
| 176 mapped->buttons[BUTTON_INDEX_RIGHT_SHOULDER] = input.buttons[7]; | |
| 177 mapped->buttons[BUTTON_INDEX_LEFT_TRIGGER] = input.buttons[4]; | |
| 178 mapped->buttons[BUTTON_INDEX_RIGHT_TRIGGER] = input.buttons[5]; | |
| 179 DpadFromAxis(mapped, input.axes[9]); | |
| 180 mapped->axes[AXIS_INDEX_RIGHT_STICK_X] = input.axes[5]; | |
| 181 mapped->axes[AXIS_INDEX_RIGHT_STICK_Y] = input.axes[2]; | |
| 182 mapped->buttonsLength = BUTTON_INDEX_COUNT - 1; /* no meta */ | |
| 183 mapped->axesLength = AXIS_INDEX_COUNT; | |
| 184 } | |
| 185 | |
| 186 void MapperSmartJoyPLUS(const blink::WebGamepad& input, | |
| 187 blink::WebGamepad* mapped) { | |
| 188 *mapped = input; | |
| 189 mapped->buttons[BUTTON_INDEX_PRIMARY] = input.buttons[2]; | |
| 190 mapped->buttons[BUTTON_INDEX_TERTIARY] = input.buttons[3]; | |
| 191 mapped->buttons[BUTTON_INDEX_QUATERNARY] = input.buttons[0]; | |
| 192 mapped->buttons[BUTTON_INDEX_START] = input.buttons[8]; | |
| 193 mapped->buttons[BUTTON_INDEX_BACK_SELECT] = input.buttons[9]; | |
| 194 mapped->buttons[BUTTON_INDEX_LEFT_SHOULDER] = input.buttons[6]; | |
| 195 mapped->buttons[BUTTON_INDEX_RIGHT_SHOULDER] = input.buttons[7]; | |
| 196 mapped->buttons[BUTTON_INDEX_LEFT_TRIGGER] = input.buttons[4]; | |
| 197 mapped->buttons[BUTTON_INDEX_RIGHT_TRIGGER] = input.buttons[5]; | |
| 198 DpadFromAxis(mapped, input.axes[9]); | |
| 199 mapped->axes[AXIS_INDEX_RIGHT_STICK_Y] = input.axes[5]; | |
| 200 mapped->buttonsLength = BUTTON_INDEX_COUNT - 1; /* no meta */ | |
| 201 mapped->axesLength = AXIS_INDEX_COUNT; | |
| 202 } | |
| 203 | |
| 204 void MapperDragonRiseGeneric(const blink::WebGamepad& input, | |
| 205 blink::WebGamepad* mapped) { | |
| 206 *mapped = input; | |
| 207 DpadFromAxis(mapped, input.axes[9]); | |
| 208 mapped->axes[AXIS_INDEX_LEFT_STICK_X] = input.axes[0]; | |
| 209 mapped->axes[AXIS_INDEX_LEFT_STICK_Y] = input.axes[1]; | |
| 210 mapped->axes[AXIS_INDEX_RIGHT_STICK_X] = input.axes[2]; | |
| 211 mapped->axes[AXIS_INDEX_RIGHT_STICK_Y] = input.axes[5]; | |
| 212 mapped->buttonsLength = BUTTON_INDEX_COUNT - 1; /* no meta */ | |
| 213 mapped->axesLength = AXIS_INDEX_COUNT; | |
| 214 } | |
| 215 | |
| 216 void MapperOnLiveWireless(const blink::WebGamepad& input, | |
| 217 blink::WebGamepad* mapped) { | |
| 218 *mapped = input; | |
| 219 mapped->buttons[BUTTON_INDEX_PRIMARY] = input.buttons[0]; | |
| 220 mapped->buttons[BUTTON_INDEX_SECONDARY] = input.buttons[1]; | |
| 221 mapped->buttons[BUTTON_INDEX_TERTIARY] = input.buttons[3]; | |
| 222 mapped->buttons[BUTTON_INDEX_QUATERNARY] = input.buttons[4]; | |
| 223 mapped->buttons[BUTTON_INDEX_LEFT_SHOULDER] = input.buttons[6]; | |
| 224 mapped->buttons[BUTTON_INDEX_RIGHT_SHOULDER] = input.buttons[7]; | |
| 225 mapped->buttons[BUTTON_INDEX_LEFT_TRIGGER] = AxisToButton(input.axes[2]); | |
| 226 mapped->buttons[BUTTON_INDEX_RIGHT_TRIGGER] = AxisToButton(input.axes[5]); | |
| 227 mapped->buttons[BUTTON_INDEX_BACK_SELECT] = input.buttons[10]; | |
| 228 mapped->buttons[BUTTON_INDEX_START] = input.buttons[11]; | |
| 229 mapped->buttons[BUTTON_INDEX_LEFT_THUMBSTICK] = input.buttons[13]; | |
| 230 mapped->buttons[BUTTON_INDEX_RIGHT_THUMBSTICK] = input.buttons[14]; | |
| 231 mapped->buttons[BUTTON_INDEX_META] = input.buttons[12]; | |
| 232 mapped->axes[AXIS_INDEX_RIGHT_STICK_X] = input.axes[3]; | |
| 233 mapped->axes[AXIS_INDEX_RIGHT_STICK_Y] = input.axes[4]; | |
| 234 DpadFromAxis(mapped, input.axes[9]); | |
| 235 | |
| 236 mapped->buttonsLength = BUTTON_INDEX_COUNT; | |
| 237 mapped->axesLength = AXIS_INDEX_COUNT; | |
| 238 } | |
| 239 | |
| 240 void MapperADT1(const blink::WebGamepad& input, blink::WebGamepad* mapped) { | |
| 241 *mapped = input; | |
| 242 mapped->buttons[BUTTON_INDEX_PRIMARY] = input.buttons[0]; | |
| 243 mapped->buttons[BUTTON_INDEX_SECONDARY] = input.buttons[1]; | |
| 244 mapped->buttons[BUTTON_INDEX_TERTIARY] = input.buttons[3]; | |
| 245 mapped->buttons[BUTTON_INDEX_QUATERNARY] = input.buttons[4]; | |
| 246 mapped->buttons[BUTTON_INDEX_LEFT_SHOULDER] = input.buttons[6]; | |
| 247 mapped->buttons[BUTTON_INDEX_RIGHT_SHOULDER] = input.buttons[7]; | |
| 248 mapped->buttons[BUTTON_INDEX_LEFT_TRIGGER] = AxisToButton(input.axes[3]); | |
| 249 mapped->buttons[BUTTON_INDEX_RIGHT_TRIGGER] = AxisToButton(input.axes[4]); | |
| 250 mapped->buttons[BUTTON_INDEX_BACK_SELECT] = NullButton(); | |
| 251 mapped->buttons[BUTTON_INDEX_START] = NullButton(); | |
| 252 mapped->buttons[BUTTON_INDEX_LEFT_THUMBSTICK] = input.buttons[13]; | |
| 253 mapped->buttons[BUTTON_INDEX_RIGHT_THUMBSTICK] = input.buttons[14]; | |
| 254 mapped->buttons[BUTTON_INDEX_META] = input.buttons[12]; | |
| 255 mapped->axes[AXIS_INDEX_RIGHT_STICK_Y] = input.axes[5]; | |
| 256 DpadFromAxis(mapped, input.axes[9]); | |
| 257 | |
| 258 mapped->buttonsLength = BUTTON_INDEX_COUNT; | |
| 259 mapped->axesLength = AXIS_INDEX_COUNT; | |
| 260 } | |
| 261 | |
| 262 void MapperNvShield(const blink::WebGamepad& input, blink::WebGamepad* mapped) { | |
| 263 *mapped = input; | |
| 264 mapped->buttons[BUTTON_INDEX_PRIMARY] = input.buttons[0]; | |
| 265 mapped->buttons[BUTTON_INDEX_SECONDARY] = input.buttons[1]; | |
| 266 mapped->buttons[BUTTON_INDEX_TERTIARY] = input.buttons[3]; | |
| 267 mapped->buttons[BUTTON_INDEX_QUATERNARY] = input.buttons[4]; | |
| 268 mapped->buttons[BUTTON_INDEX_LEFT_SHOULDER] = input.buttons[6]; | |
| 269 mapped->buttons[BUTTON_INDEX_RIGHT_SHOULDER] = input.buttons[7]; | |
| 270 mapped->buttons[BUTTON_INDEX_LEFT_TRIGGER] = AxisToButton(input.axes[3]); | |
| 271 mapped->buttons[BUTTON_INDEX_RIGHT_TRIGGER] = AxisToButton(input.axes[4]); | |
| 272 mapped->buttons[BUTTON_INDEX_BACK_SELECT] = NullButton(); | |
| 273 mapped->buttons[BUTTON_INDEX_START] = input.buttons[11]; | |
| 274 mapped->buttons[BUTTON_INDEX_LEFT_THUMBSTICK] = input.buttons[13]; | |
| 275 mapped->buttons[BUTTON_INDEX_RIGHT_THUMBSTICK] = input.buttons[14]; | |
| 276 mapped->buttons[BUTTON_INDEX_META] = input.buttons[8]; | |
| 277 mapped->axes[AXIS_INDEX_RIGHT_STICK_Y] = input.axes[5]; | |
| 278 DpadFromAxis(mapped, input.axes[9]); | |
| 279 | |
| 280 mapped->buttonsLength = BUTTON_INDEX_COUNT; | |
| 281 mapped->axesLength = AXIS_INDEX_COUNT; | |
| 282 } | |
| 283 | |
| 284 void MapperOUYA(const blink::WebGamepad& input, blink::WebGamepad* mapped) { | |
| 285 *mapped = input; | |
| 286 mapped->buttons[BUTTON_INDEX_PRIMARY] = input.buttons[0]; | |
| 287 mapped->buttons[BUTTON_INDEX_SECONDARY] = input.buttons[3]; | |
| 288 mapped->buttons[BUTTON_INDEX_TERTIARY] = input.buttons[1]; | |
| 289 mapped->buttons[BUTTON_INDEX_QUATERNARY] = input.buttons[2]; | |
| 290 mapped->buttons[BUTTON_INDEX_LEFT_SHOULDER] = input.buttons[4]; | |
| 291 mapped->buttons[BUTTON_INDEX_RIGHT_SHOULDER] = input.buttons[5]; | |
| 292 mapped->buttons[BUTTON_INDEX_LEFT_TRIGGER] = AxisToButton(input.axes[2]); | |
| 293 mapped->buttons[BUTTON_INDEX_RIGHT_TRIGGER] = AxisToButton(input.axes[5]); | |
| 294 mapped->buttons[BUTTON_INDEX_BACK_SELECT] = NullButton(); | |
| 295 mapped->buttons[BUTTON_INDEX_START] = NullButton(); | |
| 296 mapped->buttons[BUTTON_INDEX_LEFT_THUMBSTICK] = input.buttons[6]; | |
| 297 mapped->buttons[BUTTON_INDEX_RIGHT_THUMBSTICK] = input.buttons[7]; | |
| 298 mapped->buttons[BUTTON_INDEX_DPAD_UP] = input.buttons[8]; | |
| 299 mapped->buttons[BUTTON_INDEX_DPAD_DOWN] = input.buttons[9]; | |
| 300 mapped->buttons[BUTTON_INDEX_DPAD_LEFT] = input.buttons[10]; | |
| 301 mapped->buttons[BUTTON_INDEX_DPAD_RIGHT] = input.buttons[11]; | |
| 302 mapped->buttons[BUTTON_INDEX_META] = input.buttons[15]; | |
| 303 mapped->axes[AXIS_INDEX_RIGHT_STICK_X] = input.axes[3]; | |
| 304 mapped->axes[AXIS_INDEX_RIGHT_STICK_Y] = input.axes[4]; | |
| 305 | |
| 306 mapped->buttonsLength = BUTTON_INDEX_COUNT; | |
| 307 mapped->axesLength = AXIS_INDEX_COUNT; | |
| 308 } | |
| 309 | |
| 310 void MapperRazerServal(const blink::WebGamepad& input, | |
| 311 blink::WebGamepad* mapped) { | |
| 312 *mapped = input; | |
| 313 mapped->buttons[BUTTON_INDEX_PRIMARY] = input.buttons[0]; | |
| 314 mapped->buttons[BUTTON_INDEX_SECONDARY] = input.buttons[1]; | |
| 315 mapped->buttons[BUTTON_INDEX_TERTIARY] = input.buttons[3]; | |
| 316 mapped->buttons[BUTTON_INDEX_QUATERNARY] = input.buttons[4]; | |
| 317 mapped->buttons[BUTTON_INDEX_LEFT_SHOULDER] = input.buttons[6]; | |
| 318 mapped->buttons[BUTTON_INDEX_RIGHT_SHOULDER] = input.buttons[7]; | |
| 319 mapped->buttons[BUTTON_INDEX_LEFT_TRIGGER] = AxisToButton(input.axes[3]); | |
| 320 mapped->buttons[BUTTON_INDEX_RIGHT_TRIGGER] = AxisToButton(input.axes[4]); | |
| 321 mapped->buttons[BUTTON_INDEX_BACK_SELECT] = input.buttons[10]; | |
| 322 mapped->buttons[BUTTON_INDEX_START] = input.buttons[11]; | |
| 323 mapped->buttons[BUTTON_INDEX_LEFT_THUMBSTICK] = input.buttons[13]; | |
| 324 mapped->buttons[BUTTON_INDEX_RIGHT_THUMBSTICK] = input.buttons[14]; | |
| 325 mapped->axes[AXIS_INDEX_RIGHT_STICK_Y] = input.axes[5]; | |
| 326 DpadFromAxis(mapped, input.axes[9]); | |
| 327 | |
| 328 mapped->buttonsLength = BUTTON_INDEX_COUNT - 1; /* no meta */ | |
| 329 mapped->axesLength = AXIS_INDEX_COUNT; | |
| 330 } | |
| 331 | |
| 332 void MapperMogaPro(const blink::WebGamepad& input, blink::WebGamepad* mapped) { | |
| 333 *mapped = input; | |
| 334 mapped->buttons[BUTTON_INDEX_PRIMARY] = input.buttons[0]; | |
| 335 mapped->buttons[BUTTON_INDEX_SECONDARY] = input.buttons[1]; | |
| 336 mapped->buttons[BUTTON_INDEX_TERTIARY] = input.buttons[3]; | |
| 337 mapped->buttons[BUTTON_INDEX_QUATERNARY] = input.buttons[4]; | |
| 338 mapped->buttons[BUTTON_INDEX_LEFT_SHOULDER] = input.buttons[6]; | |
| 339 mapped->buttons[BUTTON_INDEX_RIGHT_SHOULDER] = input.buttons[7]; | |
| 340 mapped->buttons[BUTTON_INDEX_LEFT_TRIGGER] = AxisToButton(input.axes[3]); | |
| 341 mapped->buttons[BUTTON_INDEX_RIGHT_TRIGGER] = AxisToButton(input.axes[4]); | |
| 342 mapped->buttons[BUTTON_INDEX_BACK_SELECT] = NullButton(); | |
| 343 mapped->buttons[BUTTON_INDEX_START] = input.buttons[11]; | |
| 344 mapped->buttons[BUTTON_INDEX_LEFT_THUMBSTICK] = input.buttons[13]; | |
| 345 mapped->buttons[BUTTON_INDEX_RIGHT_THUMBSTICK] = input.buttons[14]; | |
| 346 mapped->axes[AXIS_INDEX_RIGHT_STICK_Y] = input.axes[5]; | |
| 347 DpadFromAxis(mapped, input.axes[9]); | |
| 348 | |
| 349 mapped->buttonsLength = BUTTON_INDEX_COUNT - 1; /* no meta */ | |
| 350 mapped->axesLength = AXIS_INDEX_COUNT; | |
| 351 } | |
| 352 | |
| 353 struct MappingData { | |
| 354 const char* const vendor_id; | |
| 355 const char* const product_id; | |
| 356 GamepadStandardMappingFunction function; | |
| 357 } AvailableMappings[] = { | |
| 358 // http://www.linux-usb.org/usb.ids | |
| 359 {"0079", "0006", MapperDragonRiseGeneric}, // DragonRise Generic USB | |
| 360 {"045e", "028e", MapperXbox360Gamepad}, // Xbox 360 Wired | |
| 361 {"045e", "028f", MapperXbox360Gamepad}, // Xbox 360 Wireless | |
| 362 {"045e", "0719", MapperXbox360Gamepad}, // Xbox 360 Wireless | |
| 363 {"046d", "c216", MapperDirectInputStyle}, // Logitech F310, D mode | |
| 364 {"046d", "c218", MapperDirectInputStyle}, // Logitech F510, D mode | |
| 365 {"046d", "c219", MapperDirectInputStyle}, // Logitech F710, D mode | |
| 366 {"054c", "0268", MapperPlaystationSixAxis}, // Playstation SIXAXIS | |
| 367 {"054c", "05c4", MapperDualshock4}, // Playstation Dualshock 4 | |
| 368 {"0583", "2060", MapperIBuffalo}, // iBuffalo Classic | |
| 369 {"0925", "0005", MapperSmartJoyPLUS}, // SmartJoy PLUS Adapter | |
| 370 {"0955", "7210", MapperNvShield}, // Nvidia Shield gamepad | |
| 371 {"0b05", "4500", MapperADT1}, // Nexus Player Controller | |
| 372 {"0e8f", "0003", MapperXGEAR}, // XFXforce XGEAR PS2 Controller | |
| 373 {"1532", "0900", MapperRazerServal}, // Razer Serval Controller | |
| 374 {"18d1", "2c40", MapperADT1}, // ADT-1 Controller | |
| 375 {"20d6", "6271", MapperMogaPro}, // Moga Pro Controller (HID mode) | |
| 376 {"2222", "0060", MapperDirectInputStyle}, // Macally iShockX, analog mode | |
| 377 {"2222", "4010", MapperMacallyIShock}, // Macally iShock | |
| 378 {"2378", "1008", MapperOnLiveWireless}, // OnLive Controller (Bluetooth) | |
| 379 {"2378", "100a", MapperOnLiveWireless}, // OnLive Controller (Wired) | |
| 380 {"2836", "0001", MapperOUYA}, // OUYA Controller | |
| 381 }; | |
| 382 | |
| 383 } // namespace | |
| 384 | |
| 385 GamepadStandardMappingFunction GetGamepadStandardMappingFunction( | |
| 386 const base::StringPiece& vendor_id, | |
| 387 const base::StringPiece& product_id) { | |
| 388 for (size_t i = 0; i < arraysize(AvailableMappings); ++i) { | |
| 389 MappingData& item = AvailableMappings[i]; | |
| 390 if (vendor_id == item.vendor_id && product_id == item.product_id) | |
| 391 return item.function; | |
| 392 } | |
| 393 return NULL; | |
| 394 } | |
| 395 | |
| 396 } // namespace content | |
| OLD | NEW |