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 "content/browser/gamepad/gamepad_standard_mappings.h" | 5 #include "content/browser/gamepad/gamepad_standard_mappings.h" |
6 | 6 |
7 #include "content/common/gamepad_hardware_buffer.h" | 7 #include "content/common/gamepad_hardware_buffer.h" |
8 | 8 |
9 namespace content { | 9 namespace content { |
10 | 10 |
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
145 mapped->buttons[kButtonRightShoulder] = input.buttons[7]; | 145 mapped->buttons[kButtonRightShoulder] = input.buttons[7]; |
146 mapped->buttons[kButtonLeftTrigger] = input.buttons[4]; | 146 mapped->buttons[kButtonLeftTrigger] = input.buttons[4]; |
147 mapped->buttons[kButtonRightTrigger] = input.buttons[5]; | 147 mapped->buttons[kButtonRightTrigger] = input.buttons[5]; |
148 DpadFromAxis(mapped, input.axes[9]); | 148 DpadFromAxis(mapped, input.axes[9]); |
149 mapped->axes[kAxisRightStickX] = input.axes[5]; | 149 mapped->axes[kAxisRightStickX] = input.axes[5]; |
150 mapped->axes[kAxisRightStickY] = input.axes[2]; | 150 mapped->axes[kAxisRightStickY] = input.axes[2]; |
151 mapped->buttonsLength = kNumButtons - 1; /* no meta */ | 151 mapped->buttonsLength = kNumButtons - 1; /* no meta */ |
152 mapped->axesLength = kNumAxes; | 152 mapped->axesLength = kNumAxes; |
153 } | 153 } |
154 | 154 |
| 155 void MapperSmartJoyPLUS( |
| 156 const WebKit::WebGamepad& input, |
| 157 WebKit::WebGamepad* mapped) { |
| 158 *mapped = input; |
| 159 mapped->buttons[kButtonPrimary] = input.buttons[2]; |
| 160 mapped->buttons[kButtonTertiary] = input.buttons[3]; |
| 161 mapped->buttons[kButtonQuaternary] = input.buttons[0]; |
| 162 mapped->buttons[kButtonStart] = input.buttons[8]; |
| 163 mapped->buttons[kButtonBackSelect] = input.buttons[9]; |
| 164 mapped->buttons[kButtonLeftShoulder] = input.buttons[6]; |
| 165 mapped->buttons[kButtonRightShoulder] = input.buttons[7]; |
| 166 mapped->buttons[kButtonLeftTrigger] = input.buttons[4]; |
| 167 mapped->buttons[kButtonRightTrigger] = input.buttons[5]; |
| 168 DpadFromAxis(mapped, input.axes[9]); |
| 169 mapped->axes[kAxisRightStickY] = input.axes[5]; |
| 170 mapped->buttonsLength = kNumButtons - 1; /* no meta */ |
| 171 mapped->axesLength = kNumAxes; |
| 172 } |
| 173 |
155 struct MappingData { | 174 struct MappingData { |
156 const char* const vendor_id; | 175 const char* const vendor_id; |
157 const char* const product_id; | 176 const char* const product_id; |
158 GamepadStandardMappingFunction function; | 177 GamepadStandardMappingFunction function; |
159 } AvailableMappings[] = { | 178 } AvailableMappings[] = { |
160 // http://www.linux-usb.org/usb.ids | 179 // http://www.linux-usb.org/usb.ids |
161 { "045e", "028e", MapperXbox360Gamepad }, // Xbox 360 Controller | 180 { "045e", "028e", MapperXbox360Gamepad }, // Xbox 360 Controller |
162 { "045e", "028f", MapperXbox360Gamepad }, // Xbox 360 Wireless Controller | 181 { "045e", "028f", MapperXbox360Gamepad }, // Xbox 360 Wireless Controller |
163 { "046d", "c216", MapperDirectInputStyle }, // Logitech F310, D mode | 182 { "046d", "c216", MapperDirectInputStyle }, // Logitech F310, D mode |
164 { "046d", "c218", MapperDirectInputStyle }, // Logitech F510, D mode | 183 { "046d", "c218", MapperDirectInputStyle }, // Logitech F510, D mode |
165 { "046d", "c219", MapperDirectInputStyle }, // Logitech F710, D mode | 184 { "046d", "c219", MapperDirectInputStyle }, // Logitech F710, D mode |
166 { "054c", "0268", MapperPlaystationSixAxis }, // Playstation SIXAXIS | 185 { "054c", "0268", MapperPlaystationSixAxis }, // Playstation SIXAXIS |
| 186 { "0925", "0005", MapperSmartJoyPLUS }, // SmartJoy PLUS Adapter |
167 { "0e8f", "0003", MapperXGEAR }, // XFXforce XGEAR PS2 Controller | 187 { "0e8f", "0003", MapperXGEAR }, // XFXforce XGEAR PS2 Controller |
168 { "2222", "0060", MapperDirectInputStyle }, // Macally iShockX, analog mode | 188 { "2222", "0060", MapperDirectInputStyle }, // Macally iShockX, analog mode |
169 { "2222", "4010", MapperMacallyIShock }, // Macally iShock | 189 { "2222", "4010", MapperMacallyIShock }, // Macally iShock |
170 }; | 190 }; |
171 | 191 |
172 } // namespace | 192 } // namespace |
173 | 193 |
174 GamepadStandardMappingFunction GetGamepadStandardMappingFunction( | 194 GamepadStandardMappingFunction GetGamepadStandardMappingFunction( |
175 const base::StringPiece& vendor_id, | 195 const base::StringPiece& vendor_id, |
176 const base::StringPiece& product_id) { | 196 const base::StringPiece& product_id) { |
177 for (size_t i = 0; i < arraysize(AvailableMappings); ++i) { | 197 for (size_t i = 0; i < arraysize(AvailableMappings); ++i) { |
178 MappingData& item = AvailableMappings[i]; | 198 MappingData& item = AvailableMappings[i]; |
179 if (vendor_id == item.vendor_id && product_id == item.product_id) | 199 if (vendor_id == item.vendor_id && product_id == item.product_id) |
180 return item.function; | 200 return item.function; |
181 } | 201 } |
182 return NULL; | 202 return NULL; |
183 } | 203 } |
184 | 204 |
185 } // namespace content | 205 } // namespace content |
OLD | NEW |