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 "content/browser/gamepad/gamepad_standard_mappings.h" | 8 #include "device/gamepad/gamepad_standard_mappings.h" |
9 | 9 |
10 namespace content { | 10 namespace device { |
11 | 11 |
12 namespace { | 12 namespace { |
13 | 13 |
14 void MapperLogitechDualAction(const blink::WebGamepad& input, | 14 void MapperLogitechDualAction(const blink::WebGamepad& input, |
15 blink::WebGamepad* mapped) { | 15 blink::WebGamepad* mapped) { |
16 *mapped = input; | 16 *mapped = input; |
17 mapped->buttons[BUTTON_INDEX_PRIMARY] = input.buttons[1]; | 17 mapped->buttons[BUTTON_INDEX_PRIMARY] = input.buttons[1]; |
18 mapped->buttons[BUTTON_INDEX_SECONDARY] = input.buttons[2]; | 18 mapped->buttons[BUTTON_INDEX_SECONDARY] = input.buttons[2]; |
19 mapped->buttons[BUTTON_INDEX_TERTIARY] = input.buttons[0]; | 19 mapped->buttons[BUTTON_INDEX_TERTIARY] = input.buttons[0]; |
20 mapped->axes[AXIS_INDEX_RIGHT_STICK_Y] = input.axes[5]; | 20 mapped->axes[AXIS_INDEX_RIGHT_STICK_Y] = input.axes[5]; |
(...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
236 struct MappingData { | 236 struct MappingData { |
237 const char* const vendor_id; | 237 const char* const vendor_id; |
238 const char* const product_id; | 238 const char* const product_id; |
239 GamepadStandardMappingFunction function; | 239 GamepadStandardMappingFunction function; |
240 } AvailableMappings[] = { | 240 } AvailableMappings[] = { |
241 // http://www.linux-usb.org/usb.ids | 241 // http://www.linux-usb.org/usb.ids |
242 {"0079", "0011", Mapper2Axes8Keys}, // 2Axes 8Keys Game Pad | 242 {"0079", "0011", Mapper2Axes8Keys}, // 2Axes 8Keys Game Pad |
243 {"046d", "c216", MapperLogitechDualAction}, // Logitech DualAction | 243 {"046d", "c216", MapperLogitechDualAction}, // Logitech DualAction |
244 {"054c", "05c4", MapperDualshock4}, // Playstation Dualshock 4 | 244 {"054c", "05c4", MapperDualshock4}, // Playstation Dualshock 4 |
245 {"0583", "2060", MapperIBuffalo}, // iBuffalo Classic | 245 {"0583", "2060", MapperIBuffalo}, // iBuffalo Classic |
246 {"0955", "7210", MapperNvShield}, // Nvidia Shield gamepad | 246 {"0955", "7210", MapperNvShield}, // Nvidia Shield gamepad |
247 {"0b05", "4500", MapperADT1}, // Nexus Player Controller | 247 {"0b05", "4500", MapperADT1}, // Nexus Player Controller |
248 {"1532", "0900", MapperRazerServal}, // Razer Serval Controller | 248 {"1532", "0900", MapperRazerServal}, // Razer Serval Controller |
249 {"18d1", "2c40", MapperADT1}, // ADT-1 Controller | 249 {"18d1", "2c40", MapperADT1}, // ADT-1 Controller |
250 {"20d6", "6271", MapperMogaPro}, // Moga Pro Controller (HID mode) | 250 {"20d6", "6271", MapperMogaPro}, // Moga Pro Controller (HID mode) |
251 {"2378", "1008", MapperOnLiveWireless}, // OnLive Controller (Bluetooth) | 251 {"2378", "1008", MapperOnLiveWireless}, // OnLive Controller (Bluetooth) |
252 {"2378", "100a", MapperOnLiveWireless}, // OnLive Controller (Wired) | 252 {"2378", "100a", MapperOnLiveWireless}, // OnLive Controller (Wired) |
253 {"2836", "0001", MapperOUYA}, // OUYA Controller | 253 {"2836", "0001", MapperOUYA}, // OUYA Controller |
254 }; | 254 }; |
255 | 255 |
256 } // namespace | 256 } // namespace |
257 | 257 |
258 GamepadStandardMappingFunction GetGamepadStandardMappingFunction( | 258 GamepadStandardMappingFunction GetGamepadStandardMappingFunction( |
259 const base::StringPiece& vendor_id, | 259 const base::StringPiece& vendor_id, |
260 const base::StringPiece& product_id) { | 260 const base::StringPiece& product_id) { |
261 for (size_t i = 0; i < arraysize(AvailableMappings); ++i) { | 261 for (size_t i = 0; i < arraysize(AvailableMappings); ++i) { |
262 MappingData& item = AvailableMappings[i]; | 262 MappingData& item = AvailableMappings[i]; |
263 if (vendor_id == item.vendor_id && product_id == item.product_id) | 263 if (vendor_id == item.vendor_id && product_id == item.product_id) |
264 return item.function; | 264 return item.function; |
265 } | 265 } |
266 return NULL; | 266 return NULL; |
267 } | 267 } |
268 | 268 |
269 } // namespace content | 269 } // namespace device |
OLD | NEW |