| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include <stddef.h> | 5 #include <stddef.h> |
| 6 | 6 |
| 7 #include "base/macros.h" | 7 #include "base/macros.h" |
| 8 #include "device/gamepad/gamepad_standard_mappings.h" | 8 #include "device/gamepad/gamepad_standard_mappings.h" |
| 9 | 9 |
| 10 namespace device { | 10 namespace device { |
| (...skipping 17 matching lines...) Expand all Loading... |
| 28 mapped->buttons[BUTTON_INDEX_META] = input.buttons[8]; | 28 mapped->buttons[BUTTON_INDEX_META] = input.buttons[8]; |
| 29 mapped->axes[AXIS_INDEX_RIGHT_STICK_X] = input.axes[3]; | 29 mapped->axes[AXIS_INDEX_RIGHT_STICK_X] = input.axes[3]; |
| 30 mapped->axes[AXIS_INDEX_RIGHT_STICK_Y] = input.axes[4]; | 30 mapped->axes[AXIS_INDEX_RIGHT_STICK_Y] = input.axes[4]; |
| 31 mapped->buttonsLength = BUTTON_INDEX_COUNT; | 31 mapped->buttonsLength = BUTTON_INDEX_COUNT; |
| 32 mapped->axesLength = AXIS_INDEX_COUNT; | 32 mapped->axesLength = AXIS_INDEX_COUNT; |
| 33 } | 33 } |
| 34 | 34 |
| 35 void MapperXboxOneHidGamepad(const blink::WebGamepad& input, | 35 void MapperXboxOneHidGamepad(const blink::WebGamepad& input, |
| 36 blink::WebGamepad* mapped) { | 36 blink::WebGamepad* mapped) { |
| 37 *mapped = input; | 37 *mapped = input; |
| 38 mapped->buttons[BUTTON_INDEX_LEFT_TRIGGER] = AxisToButton(input.axes[2]); | 38 |
| 39 mapped->buttons[BUTTON_INDEX_RIGHT_TRIGGER] = AxisToButton(input.axes[5]); | 39 mapped->buttons[BUTTON_INDEX_PRIMARY] = input.buttons[0]; |
| 40 mapped->buttons[BUTTON_INDEX_BACK_SELECT] = input.buttons[6]; | 40 mapped->buttons[BUTTON_INDEX_SECONDARY] = input.buttons[1]; |
| 41 mapped->buttons[BUTTON_INDEX_START] = input.buttons[7]; | 41 mapped->buttons[BUTTON_INDEX_TERTIARY] = input.buttons[3]; |
| 42 mapped->buttons[BUTTON_INDEX_LEFT_THUMBSTICK] = input.buttons[8]; | 42 mapped->buttons[BUTTON_INDEX_QUATERNARY] = input.buttons[4]; |
| 43 mapped->buttons[BUTTON_INDEX_RIGHT_THUMBSTICK] = input.buttons[9]; | 43 mapped->buttons[BUTTON_INDEX_LEFT_SHOULDER] = input.buttons[6]; |
| 44 mapped->buttons[BUTTON_INDEX_RIGHT_SHOULDER] = input.buttons[7]; |
| 45 mapped->buttons[BUTTON_INDEX_LEFT_TRIGGER] = AxisToButton(input.axes[5]); |
| 46 mapped->buttons[BUTTON_INDEX_RIGHT_TRIGGER] = AxisToButton(input.axes[4]); |
| 47 mapped->buttons[BUTTON_INDEX_BACK_SELECT] = NullButton(); |
| 48 mapped->buttons[BUTTON_INDEX_START] = input.buttons[11]; |
| 49 mapped->buttons[BUTTON_INDEX_LEFT_THUMBSTICK] = input.buttons[13]; |
| 50 mapped->buttons[BUTTON_INDEX_RIGHT_THUMBSTICK] = input.buttons[14]; |
| 44 mapped->buttons[BUTTON_INDEX_DPAD_UP] = AxisNegativeAsButton(input.axes[7]); | 51 mapped->buttons[BUTTON_INDEX_DPAD_UP] = AxisNegativeAsButton(input.axes[7]); |
| 45 mapped->buttons[BUTTON_INDEX_DPAD_DOWN] = AxisPositiveAsButton(input.axes[7]); | 52 mapped->buttons[BUTTON_INDEX_DPAD_DOWN] = AxisPositiveAsButton(input.axes[7]); |
| 46 mapped->buttons[BUTTON_INDEX_DPAD_LEFT] = AxisNegativeAsButton(input.axes[6]); | 53 mapped->buttons[BUTTON_INDEX_DPAD_LEFT] = AxisNegativeAsButton(input.axes[6]); |
| 47 mapped->buttons[BUTTON_INDEX_DPAD_RIGHT] = | 54 mapped->buttons[BUTTON_INDEX_DPAD_RIGHT] = |
| 48 AxisPositiveAsButton(input.axes[6]); | 55 AxisPositiveAsButton(input.axes[6]); |
| 49 mapped->axes[AXIS_INDEX_RIGHT_STICK_X] = input.axes[3]; | 56 mapped->axes[AXIS_INDEX_RIGHT_STICK_Y] = input.axes[3]; |
| 50 mapped->axes[AXIS_INDEX_RIGHT_STICK_Y] = input.axes[4]; | |
| 51 | 57 |
| 52 mapped->buttonsLength = BUTTON_INDEX_COUNT - 1; /* no meta */ | 58 mapped->buttonsLength = BUTTON_INDEX_COUNT - 1; /* no meta */ |
| 53 mapped->axesLength = AXIS_INDEX_COUNT; | 59 mapped->axesLength = AXIS_INDEX_COUNT; |
| 54 } | 60 } |
| 55 | 61 |
| 56 void MapperLakeviewResearch(const blink::WebGamepad& input, | 62 void MapperLakeviewResearch(const blink::WebGamepad& input, |
| 57 blink::WebGamepad* mapped) { | 63 blink::WebGamepad* mapped) { |
| 58 *mapped = input; | 64 *mapped = input; |
| 59 mapped->buttons[BUTTON_INDEX_PRIMARY] = input.buttons[2]; | 65 mapped->buttons[BUTTON_INDEX_PRIMARY] = input.buttons[2]; |
| 60 mapped->buttons[BUTTON_INDEX_TERTIARY] = input.buttons[3]; | 66 mapped->buttons[BUTTON_INDEX_TERTIARY] = input.buttons[3]; |
| (...skipping 254 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 315 const char* const vendor_id; | 321 const char* const vendor_id; |
| 316 const char* const product_id; | 322 const char* const product_id; |
| 317 GamepadStandardMappingFunction function; | 323 GamepadStandardMappingFunction function; |
| 318 } AvailableMappings[] = { | 324 } AvailableMappings[] = { |
| 319 // http://www.linux-usb.org/usb.ids | 325 // http://www.linux-usb.org/usb.ids |
| 320 {"0079", "0006", MapperDragonRiseGeneric}, // DragonRise Generic USB | 326 {"0079", "0006", MapperDragonRiseGeneric}, // DragonRise Generic USB |
| 321 {"045e", "028e", MapperXInputStyleGamepad}, // Xbox 360 Wired | 327 {"045e", "028e", MapperXInputStyleGamepad}, // Xbox 360 Wired |
| 322 {"045e", "028f", MapperXInputStyleGamepad}, // Xbox 360 Wireless | 328 {"045e", "028f", MapperXInputStyleGamepad}, // Xbox 360 Wireless |
| 323 {"045e", "02d1", MapperXInputStyleGamepad}, // Xbox One Wired | 329 {"045e", "02d1", MapperXInputStyleGamepad}, // Xbox One Wired |
| 324 {"045e", "02dd", MapperXInputStyleGamepad}, // Xbox One Wired (2015 FW) | 330 {"045e", "02dd", MapperXInputStyleGamepad}, // Xbox One Wired (2015 FW) |
| 325 {"045e", "02e0", MapperXboxOneHidGamepad}, // Xbox One S (Bluetooth mode) | |
| 326 {"045e", "02e3", MapperXInputStyleGamepad}, // Xbox One Elite Wired | 331 {"045e", "02e3", MapperXInputStyleGamepad}, // Xbox One Elite Wired |
| 327 {"045e", "02ea", MapperXInputStyleGamepad}, // Xbox One S (USB) | 332 {"045e", "02ea", MapperXInputStyleGamepad}, // Xbox One S (USB) |
| 333 {"045e", "02fd", MapperXboxOneHidGamepad}, // Xbox One S (Bluetooth) |
| 328 {"045e", "0719", MapperXInputStyleGamepad}, // Xbox 360 Wireless | 334 {"045e", "0719", MapperXInputStyleGamepad}, // Xbox 360 Wireless |
| 329 {"046d", "c21d", MapperXInputStyleGamepad}, // Logitech F310 | 335 {"046d", "c21d", MapperXInputStyleGamepad}, // Logitech F310 |
| 330 {"046d", "c21e", MapperXInputStyleGamepad}, // Logitech F510 | 336 {"046d", "c21e", MapperXInputStyleGamepad}, // Logitech F510 |
| 331 {"046d", "c21f", MapperXInputStyleGamepad}, // Logitech F710 | 337 {"046d", "c21f", MapperXInputStyleGamepad}, // Logitech F710 |
| 332 {"054c", "0268", MapperPlaystationSixAxis}, // Playstation SIXAXIS | 338 {"054c", "0268", MapperPlaystationSixAxis}, // Playstation SIXAXIS |
| 333 {"054c", "05c4", MapperDualshock4}, // Playstation Dualshock 4 | 339 {"054c", "05c4", MapperDualshock4}, // Playstation Dualshock 4 |
| 334 {"054c", "09cc", MapperDualshock4}, // Dualshock 4 (PS4 Slim) | 340 {"054c", "09cc", MapperDualshock4}, // Dualshock 4 (PS4 Slim) |
| 335 {"0583", "2060", MapperIBuffalo}, // iBuffalo Classic | 341 {"0583", "2060", MapperIBuffalo}, // iBuffalo Classic |
| 336 {"0925", "0005", MapperLakeviewResearch}, // SmartJoy PLUS Adapter | 342 {"0925", "0005", MapperLakeviewResearch}, // SmartJoy PLUS Adapter |
| 337 {"0925", "8866", MapperLakeviewResearch}, // WiseGroup MP-8866 | 343 {"0925", "8866", MapperLakeviewResearch}, // WiseGroup MP-8866 |
| (...skipping 15 matching lines...) Expand all Loading... |
| 353 const base::StringPiece& product_id) { | 359 const base::StringPiece& product_id) { |
| 354 for (size_t i = 0; i < arraysize(AvailableMappings); ++i) { | 360 for (size_t i = 0; i < arraysize(AvailableMappings); ++i) { |
| 355 MappingData& item = AvailableMappings[i]; | 361 MappingData& item = AvailableMappings[i]; |
| 356 if (vendor_id == item.vendor_id && product_id == item.product_id) | 362 if (vendor_id == item.vendor_id && product_id == item.product_id) |
| 357 return item.function; | 363 return item.function; |
| 358 } | 364 } |
| 359 return NULL; | 365 return NULL; |
| 360 } | 366 } |
| 361 | 367 |
| 362 } // namespace device | 368 } // namespace device |
| OLD | NEW |