| 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 14 matching lines...) Expand all Loading... |
| 25 mapped->buttons[BUTTON_INDEX_DPAD_LEFT] = AxisNegativeAsButton(input.axes[6]); | 25 mapped->buttons[BUTTON_INDEX_DPAD_LEFT] = AxisNegativeAsButton(input.axes[6]); |
| 26 mapped->buttons[BUTTON_INDEX_DPAD_RIGHT] = | 26 mapped->buttons[BUTTON_INDEX_DPAD_RIGHT] = |
| 27 AxisPositiveAsButton(input.axes[6]); | 27 AxisPositiveAsButton(input.axes[6]); |
| 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, |
| 36 blink::WebGamepad* mapped) { |
| 37 *mapped = input; |
| 38 mapped->buttons[BUTTON_INDEX_LEFT_TRIGGER] = AxisToButton(input.axes[2]); |
| 39 mapped->buttons[BUTTON_INDEX_RIGHT_TRIGGER] = AxisToButton(input.axes[5]); |
| 40 mapped->buttons[BUTTON_INDEX_BACK_SELECT] = input.buttons[6]; |
| 41 mapped->buttons[BUTTON_INDEX_START] = input.buttons[7]; |
| 42 mapped->buttons[BUTTON_INDEX_LEFT_THUMBSTICK] = input.buttons[8]; |
| 43 mapped->buttons[BUTTON_INDEX_RIGHT_THUMBSTICK] = input.buttons[9]; |
| 44 mapped->buttons[BUTTON_INDEX_DPAD_UP] = AxisNegativeAsButton(input.axes[7]); |
| 45 mapped->buttons[BUTTON_INDEX_DPAD_DOWN] = AxisPositiveAsButton(input.axes[7]); |
| 46 mapped->buttons[BUTTON_INDEX_DPAD_LEFT] = AxisNegativeAsButton(input.axes[6]); |
| 47 mapped->buttons[BUTTON_INDEX_DPAD_RIGHT] = |
| 48 AxisPositiveAsButton(input.axes[6]); |
| 49 mapped->axes[AXIS_INDEX_RIGHT_STICK_X] = input.axes[3]; |
| 50 mapped->axes[AXIS_INDEX_RIGHT_STICK_Y] = input.axes[4]; |
| 51 |
| 52 mapped->buttonsLength = BUTTON_INDEX_COUNT - 1; /* no meta */ |
| 53 mapped->axesLength = AXIS_INDEX_COUNT; |
| 54 } |
| 55 |
| 35 void MapperLakeviewResearch(const blink::WebGamepad& input, | 56 void MapperLakeviewResearch(const blink::WebGamepad& input, |
| 36 blink::WebGamepad* mapped) { | 57 blink::WebGamepad* mapped) { |
| 37 *mapped = input; | 58 *mapped = input; |
| 38 mapped->buttons[BUTTON_INDEX_PRIMARY] = input.buttons[2]; | 59 mapped->buttons[BUTTON_INDEX_PRIMARY] = input.buttons[2]; |
| 39 mapped->buttons[BUTTON_INDEX_TERTIARY] = input.buttons[3]; | 60 mapped->buttons[BUTTON_INDEX_TERTIARY] = input.buttons[3]; |
| 40 mapped->buttons[BUTTON_INDEX_QUATERNARY] = input.buttons[0]; | 61 mapped->buttons[BUTTON_INDEX_QUATERNARY] = input.buttons[0]; |
| 41 mapped->buttons[BUTTON_INDEX_LEFT_SHOULDER] = input.buttons[6]; | 62 mapped->buttons[BUTTON_INDEX_LEFT_SHOULDER] = input.buttons[6]; |
| 42 mapped->buttons[BUTTON_INDEX_RIGHT_SHOULDER] = input.buttons[7]; | 63 mapped->buttons[BUTTON_INDEX_RIGHT_SHOULDER] = input.buttons[7]; |
| 43 mapped->buttons[BUTTON_INDEX_LEFT_TRIGGER] = input.buttons[4]; | 64 mapped->buttons[BUTTON_INDEX_LEFT_TRIGGER] = input.buttons[4]; |
| 44 mapped->buttons[BUTTON_INDEX_RIGHT_TRIGGER] = input.buttons[5]; | 65 mapped->buttons[BUTTON_INDEX_RIGHT_TRIGGER] = input.buttons[5]; |
| (...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 292 | 313 |
| 293 struct MappingData { | 314 struct MappingData { |
| 294 const char* const vendor_id; | 315 const char* const vendor_id; |
| 295 const char* const product_id; | 316 const char* const product_id; |
| 296 GamepadStandardMappingFunction function; | 317 GamepadStandardMappingFunction function; |
| 297 } AvailableMappings[] = { | 318 } AvailableMappings[] = { |
| 298 // http://www.linux-usb.org/usb.ids | 319 // http://www.linux-usb.org/usb.ids |
| 299 {"0079", "0006", MapperDragonRiseGeneric}, // DragonRise Generic USB | 320 {"0079", "0006", MapperDragonRiseGeneric}, // DragonRise Generic USB |
| 300 {"045e", "028e", MapperXInputStyleGamepad}, // Xbox 360 Wired | 321 {"045e", "028e", MapperXInputStyleGamepad}, // Xbox 360 Wired |
| 301 {"045e", "028f", MapperXInputStyleGamepad}, // Xbox 360 Wireless | 322 {"045e", "028f", MapperXInputStyleGamepad}, // Xbox 360 Wireless |
| 323 {"045e", "02e0", MapperXboxOneHidGamepad}, // Xbox One S (Bluetooth mode) |
| 302 {"045e", "0719", MapperXInputStyleGamepad}, // Xbox 360 Wireless | 324 {"045e", "0719", MapperXInputStyleGamepad}, // Xbox 360 Wireless |
| 303 {"046d", "c21d", MapperXInputStyleGamepad}, // Logitech F310 | 325 {"046d", "c21d", MapperXInputStyleGamepad}, // Logitech F310 |
| 304 {"046d", "c21e", MapperXInputStyleGamepad}, // Logitech F510 | 326 {"046d", "c21e", MapperXInputStyleGamepad}, // Logitech F510 |
| 305 {"046d", "c21f", MapperXInputStyleGamepad}, // Logitech F710 | 327 {"046d", "c21f", MapperXInputStyleGamepad}, // Logitech F710 |
| 306 {"054c", "0268", MapperPlaystationSixAxis}, // Playstation SIXAXIS | 328 {"054c", "0268", MapperPlaystationSixAxis}, // Playstation SIXAXIS |
| 307 {"054c", "05c4", MapperDualshock4}, // Playstation Dualshock 4 | 329 {"054c", "05c4", MapperDualshock4}, // Playstation Dualshock 4 |
| 308 {"0583", "2060", MapperIBuffalo}, // iBuffalo Classic | 330 {"0583", "2060", MapperIBuffalo}, // iBuffalo Classic |
| 309 {"0925", "0005", MapperLakeviewResearch}, // SmartJoy PLUS Adapter | 331 {"0925", "0005", MapperLakeviewResearch}, // SmartJoy PLUS Adapter |
| 310 {"0925", "8866", MapperLakeviewResearch}, // WiseGroup MP-8866 | 332 {"0925", "8866", MapperLakeviewResearch}, // WiseGroup MP-8866 |
| 311 {"0955", "7210", MapperNvShield}, // Nvidia Shield gamepad | 333 {"0955", "7210", MapperNvShield}, // Nvidia Shield gamepad |
| (...skipping 14 matching lines...) Expand all Loading... |
| 326 const base::StringPiece& product_id) { | 348 const base::StringPiece& product_id) { |
| 327 for (size_t i = 0; i < arraysize(AvailableMappings); ++i) { | 349 for (size_t i = 0; i < arraysize(AvailableMappings); ++i) { |
| 328 MappingData& item = AvailableMappings[i]; | 350 MappingData& item = AvailableMappings[i]; |
| 329 if (vendor_id == item.vendor_id && product_id == item.product_id) | 351 if (vendor_id == item.vendor_id && product_id == item.product_id) |
| 330 return item.function; | 352 return item.function; |
| 331 } | 353 } |
| 332 return NULL; | 354 return NULL; |
| 333 } | 355 } |
| 334 | 356 |
| 335 } // namespace device | 357 } // namespace device |
| OLD | NEW |