| 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 13 matching lines...) Expand all Loading... |
| 24 mapped->buttons[BUTTON_INDEX_DPAD_LEFT] = AxisNegativeAsButton(input.axes[6]); | 24 mapped->buttons[BUTTON_INDEX_DPAD_LEFT] = AxisNegativeAsButton(input.axes[6]); |
| 25 mapped->buttons[BUTTON_INDEX_DPAD_RIGHT] = | 25 mapped->buttons[BUTTON_INDEX_DPAD_RIGHT] = |
| 26 AxisPositiveAsButton(input.axes[6]); | 26 AxisPositiveAsButton(input.axes[6]); |
| 27 mapped->buttons[BUTTON_INDEX_META] = input.buttons[8]; | 27 mapped->buttons[BUTTON_INDEX_META] = input.buttons[8]; |
| 28 mapped->axes[AXIS_INDEX_RIGHT_STICK_X] = input.axes[3]; | 28 mapped->axes[AXIS_INDEX_RIGHT_STICK_X] = input.axes[3]; |
| 29 mapped->axes[AXIS_INDEX_RIGHT_STICK_Y] = input.axes[4]; | 29 mapped->axes[AXIS_INDEX_RIGHT_STICK_Y] = input.axes[4]; |
| 30 mapped->buttons_length = BUTTON_INDEX_COUNT; | 30 mapped->buttons_length = BUTTON_INDEX_COUNT; |
| 31 mapped->axes_length = AXIS_INDEX_COUNT; | 31 mapped->axes_length = AXIS_INDEX_COUNT; |
| 32 } | 32 } |
| 33 | 33 |
| 34 void MapperXboxOneHidGamepad(const Gamepad& input, Gamepad* mapped) { | 34 void MapperXboxOneS2016Firmware(const Gamepad& input, Gamepad* mapped) { |
| 35 *mapped = input; |
| 36 mapped->buttons[BUTTON_INDEX_PRIMARY] = input.buttons[0]; |
| 37 mapped->buttons[BUTTON_INDEX_SECONDARY] = input.buttons[1]; |
| 38 mapped->buttons[BUTTON_INDEX_TERTIARY] = input.buttons[2]; |
| 39 mapped->buttons[BUTTON_INDEX_QUATERNARY] = input.buttons[3]; |
| 40 mapped->buttons[BUTTON_INDEX_LEFT_SHOULDER] = input.buttons[4]; |
| 41 mapped->buttons[BUTTON_INDEX_RIGHT_SHOULDER] = input.buttons[5]; |
| 42 mapped->buttons[BUTTON_INDEX_LEFT_TRIGGER] = AxisToButton(input.axes[2]); |
| 43 mapped->buttons[BUTTON_INDEX_RIGHT_TRIGGER] = AxisToButton(input.axes[5]); |
| 44 mapped->buttons[BUTTON_INDEX_BACK_SELECT] = input.buttons[6]; |
| 45 mapped->buttons[BUTTON_INDEX_START] = input.buttons[7]; |
| 46 mapped->buttons[BUTTON_INDEX_LEFT_THUMBSTICK] = input.buttons[8]; |
| 47 mapped->buttons[BUTTON_INDEX_RIGHT_THUMBSTICK] = input.buttons[9]; |
| 48 mapped->buttons[BUTTON_INDEX_DPAD_UP] = AxisNegativeAsButton(input.axes[7]); |
| 49 mapped->buttons[BUTTON_INDEX_DPAD_DOWN] = AxisPositiveAsButton(input.axes[7]); |
| 50 mapped->buttons[BUTTON_INDEX_DPAD_LEFT] = AxisNegativeAsButton(input.axes[6]); |
| 51 mapped->buttons[BUTTON_INDEX_DPAD_RIGHT] = |
| 52 AxisPositiveAsButton(input.axes[6]); |
| 53 mapped->axes[AXIS_INDEX_RIGHT_STICK_X] = input.axes[3]; |
| 54 mapped->axes[AXIS_INDEX_RIGHT_STICK_Y] = input.axes[4]; |
| 55 mapped->buttons_length = BUTTON_INDEX_COUNT - 1; /* no meta */ |
| 56 mapped->axes_length = AXIS_INDEX_COUNT; |
| 57 } |
| 58 |
| 59 void MapperXboxOneS(const Gamepad& input, Gamepad* mapped) { |
| 35 *mapped = input; | 60 *mapped = input; |
| 36 | 61 |
| 37 mapped->buttons[BUTTON_INDEX_PRIMARY] = input.buttons[0]; | 62 mapped->buttons[BUTTON_INDEX_PRIMARY] = input.buttons[0]; |
| 38 mapped->buttons[BUTTON_INDEX_SECONDARY] = input.buttons[1]; | 63 mapped->buttons[BUTTON_INDEX_SECONDARY] = input.buttons[1]; |
| 39 mapped->buttons[BUTTON_INDEX_TERTIARY] = input.buttons[3]; | 64 mapped->buttons[BUTTON_INDEX_TERTIARY] = input.buttons[3]; |
| 40 mapped->buttons[BUTTON_INDEX_QUATERNARY] = input.buttons[4]; | 65 mapped->buttons[BUTTON_INDEX_QUATERNARY] = input.buttons[4]; |
| 41 mapped->buttons[BUTTON_INDEX_LEFT_SHOULDER] = input.buttons[6]; | 66 mapped->buttons[BUTTON_INDEX_LEFT_SHOULDER] = input.buttons[6]; |
| 42 mapped->buttons[BUTTON_INDEX_RIGHT_SHOULDER] = input.buttons[7]; | 67 mapped->buttons[BUTTON_INDEX_RIGHT_SHOULDER] = input.buttons[7]; |
| 43 mapped->buttons[BUTTON_INDEX_LEFT_TRIGGER] = AxisToButton(input.axes[5]); | 68 mapped->buttons[BUTTON_INDEX_LEFT_TRIGGER] = AxisToButton(input.axes[5]); |
| 44 mapped->buttons[BUTTON_INDEX_RIGHT_TRIGGER] = AxisToButton(input.axes[4]); | 69 mapped->buttons[BUTTON_INDEX_RIGHT_TRIGGER] = AxisToButton(input.axes[4]); |
| (...skipping 300 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 345 const char* const product_id; | 370 const char* const product_id; |
| 346 GamepadStandardMappingFunction function; | 371 GamepadStandardMappingFunction function; |
| 347 } AvailableMappings[] = { | 372 } AvailableMappings[] = { |
| 348 // http://www.linux-usb.org/usb.ids | 373 // http://www.linux-usb.org/usb.ids |
| 349 {"0079", "0006", MapperDragonRiseGeneric}, // DragonRise Generic USB | 374 {"0079", "0006", MapperDragonRiseGeneric}, // DragonRise Generic USB |
| 350 {"045e", "028e", MapperXInputStyleGamepad}, // Xbox 360 Wired | 375 {"045e", "028e", MapperXInputStyleGamepad}, // Xbox 360 Wired |
| 351 {"045e", "028f", MapperXInputStyleGamepad}, // Xbox 360 Wireless | 376 {"045e", "028f", MapperXInputStyleGamepad}, // Xbox 360 Wireless |
| 352 {"045e", "02a1", MapperXInputStyleGamepad}, // Xbox 360 Wireless | 377 {"045e", "02a1", MapperXInputStyleGamepad}, // Xbox 360 Wireless |
| 353 {"045e", "02d1", MapperXInputStyleGamepad}, // Xbox One Wired | 378 {"045e", "02d1", MapperXInputStyleGamepad}, // Xbox One Wired |
| 354 {"045e", "02dd", MapperXInputStyleGamepad}, // Xbox One Wired (2015 FW) | 379 {"045e", "02dd", MapperXInputStyleGamepad}, // Xbox One Wired (2015 FW) |
| 380 {"045e", "02e0", MapperXboxOneS2016Firmware}, // Xbox One S (Bluetooth) |
| 355 {"045e", "02e3", MapperXInputStyleGamepad}, // Xbox One Elite Wired | 381 {"045e", "02e3", MapperXInputStyleGamepad}, // Xbox One Elite Wired |
| 356 {"045e", "02ea", MapperXInputStyleGamepad}, // Xbox One S (USB) | 382 {"045e", "02ea", MapperXInputStyleGamepad}, // Xbox One S (USB) |
| 357 {"045e", "02fd", MapperXboxOneHidGamepad}, // Xbox One S (Bluetooth) | 383 {"045e", "02fd", MapperXboxOneS}, // Xbox One S (Bluetooth) |
| 358 {"045e", "0719", MapperXInputStyleGamepad}, // Xbox 360 Wireless | 384 {"045e", "0719", MapperXInputStyleGamepad}, // Xbox 360 Wireless |
| 359 {"046d", "c21d", MapperXInputStyleGamepad}, // Logitech F310 | 385 {"046d", "c21d", MapperXInputStyleGamepad}, // Logitech F310 |
| 360 {"046d", "c21e", MapperXInputStyleGamepad}, // Logitech F510 | 386 {"046d", "c21e", MapperXInputStyleGamepad}, // Logitech F510 |
| 361 {"046d", "c21f", MapperXInputStyleGamepad}, // Logitech F710 | 387 {"046d", "c21f", MapperXInputStyleGamepad}, // Logitech F710 |
| 362 {"04e8", "a000", MapperSamsung_EI_GP20}, // Samsung Gamepad EI-GP20 | 388 {"04e8", "a000", MapperSamsung_EI_GP20}, // Samsung Gamepad EI-GP20 |
| 363 {"054c", "0268", MapperPlaystationSixAxis}, // Playstation SIXAXIS | 389 {"054c", "0268", MapperPlaystationSixAxis}, // Playstation SIXAXIS |
| 364 {"054c", "05c4", MapperDualshock4}, // Playstation Dualshock 4 | 390 {"054c", "05c4", MapperDualshock4}, // Playstation Dualshock 4 |
| 365 {"054c", "09cc", MapperDualshock4}, // Dualshock 4 (PS4 Slim) | 391 {"054c", "09cc", MapperDualshock4}, // Dualshock 4 (PS4 Slim) |
| 366 {"0583", "2060", MapperIBuffalo}, // iBuffalo Classic | 392 {"0583", "2060", MapperIBuffalo}, // iBuffalo Classic |
| 367 {"0925", "0005", MapperLakeviewResearch}, // SmartJoy PLUS Adapter | 393 {"0925", "0005", MapperLakeviewResearch}, // SmartJoy PLUS Adapter |
| (...skipping 16 matching lines...) Expand all Loading... |
| 384 const base::StringPiece& product_id) { | 410 const base::StringPiece& product_id) { |
| 385 for (size_t i = 0; i < arraysize(AvailableMappings); ++i) { | 411 for (size_t i = 0; i < arraysize(AvailableMappings); ++i) { |
| 386 MappingData& item = AvailableMappings[i]; | 412 MappingData& item = AvailableMappings[i]; |
| 387 if (vendor_id == item.vendor_id && product_id == item.product_id) | 413 if (vendor_id == item.vendor_id && product_id == item.product_id) |
| 388 return item.function; | 414 return item.function; |
| 389 } | 415 } |
| 390 return NULL; | 416 return NULL; |
| 391 } | 417 } |
| 392 | 418 |
| 393 } // namespace device | 419 } // namespace device |
| OLD | NEW |