Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(706)

Side by Side Diff: content/browser/gamepad/gamepad_standard_mappings_linux.cc

Issue 10832231: Add gamepad mapping for XFXforce XGEAR PS2 Controller on Linux (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
83 mapped->buttons[kButtonDpadUp] = AxisToButton(input.axes[8]); 83 mapped->buttons[kButtonDpadUp] = AxisToButton(input.axes[8]);
84 mapped->buttons[kButtonDpadDown] = AxisToButton(input.axes[10]); 84 mapped->buttons[kButtonDpadDown] = AxisToButton(input.axes[10]);
85 mapped->buttons[kButtonDpadLeft] = input.buttons[7]; 85 mapped->buttons[kButtonDpadLeft] = input.buttons[7];
86 mapped->buttons[kButtonDpadRight] = AxisToButton(input.axes[9]); 86 mapped->buttons[kButtonDpadRight] = AxisToButton(input.axes[9]);
87 mapped->buttons[kButtonMeta] = input.buttons[16]; 87 mapped->buttons[kButtonMeta] = input.buttons[16];
88 88
89 mapped->buttonsLength = kNumButtons; 89 mapped->buttonsLength = kNumButtons;
90 mapped->axesLength = kNumAxes; 90 mapped->axesLength = kNumAxes;
91 } 91 }
92 92
93 void MapperXGEAR(
94 const WebKit::WebGamepad& input,
95 WebKit::WebGamepad* mapped) {
96 *mapped = input;
97 mapped->buttons[kButtonPrimary] = input.buttons[2];
98 mapped->buttons[kButtonSecondary] = input.buttons[1];
99 mapped->buttons[kButtonTertiary] = input.buttons[3];
100 mapped->buttons[kButtonQuaternary] = input.buttons[0];
101 mapped->buttons[kButtonLeftShoulder] = input.buttons[6];
102 mapped->buttons[kButtonRightShoulder] = input.buttons[7];
103 mapped->buttons[kButtonLeftTrigger] = input.buttons[4];
104 mapped->buttons[kButtonRightTrigger] = input.buttons[5];
105 mapped->buttons[kButtonDpadUp] = AxisNegativeAsButton(input.axes[5]);
106 mapped->buttons[kButtonDpadDown] = AxisPositiveAsButton(input.axes[5]);
107 mapped->buttons[kButtonDpadLeft] = AxisNegativeAsButton(input.axes[4]);
108 mapped->buttons[kButtonDpadRight] = AxisPositiveAsButton(input.axes[4]);
109 mapped->axes[kAxisRightStickX] = input.axes[3];
110 mapped->axes[kAxisRightStickY] = input.axes[2];
111 mapped->buttonsLength = kNumButtons - 1; // no Meta on this device
112 mapped->axesLength = kNumAxes;
113 }
114
115
93 struct MappingData { 116 struct MappingData {
94 const char* const vendor_id; 117 const char* const vendor_id;
95 const char* const product_id; 118 const char* const product_id;
96 GamepadStandardMappingFunction function; 119 GamepadStandardMappingFunction function;
97 } AvailableMappings[] = { 120 } AvailableMappings[] = {
98 // http://www.linux-usb.org/usb.ids 121 // http://www.linux-usb.org/usb.ids
99 { "045e", "028e", MapperXInputStyleGamepad }, // Xbox 360 Controller 122 { "045e", "028e", MapperXInputStyleGamepad }, // Xbox 360 Controller
100 { "045e", "028f", MapperXInputStyleGamepad }, // Xbox 360 Wireless Controller 123 { "045e", "028f", MapperXInputStyleGamepad }, // Xbox 360 Wireless Controller
101 { "046d", "c21d", MapperXInputStyleGamepad }, // Logitech F310 124 { "046d", "c21d", MapperXInputStyleGamepad }, // Logitech F310
102 { "046d", "c21e", MapperXInputStyleGamepad }, // Logitech F510 125 { "046d", "c21e", MapperXInputStyleGamepad }, // Logitech F510
103 { "046d", "c21f", MapperXInputStyleGamepad }, // Logitech F710 126 { "046d", "c21f", MapperXInputStyleGamepad }, // Logitech F710
104 { "054c", "0268", MapperPlaystationSixAxis }, // Playstation SIXAXIS 127 { "054c", "0268", MapperPlaystationSixAxis }, // Playstation SIXAXIS
105 { "0925", "8866", MapperMP8866 }, // WiseGroup MP-8866 128 { "0925", "8866", MapperMP8866 }, // WiseGroup MP-8866
129 { "0e8f", "0003", MapperXGEAR }, // XFXforce XGEAR PS2 Controller
106 }; 130 };
107 131
108 } // namespace 132 } // namespace
109 133
110 GamepadStandardMappingFunction GetGamepadStandardMappingFunction( 134 GamepadStandardMappingFunction GetGamepadStandardMappingFunction(
111 const base::StringPiece& vendor_id, 135 const base::StringPiece& vendor_id,
112 const base::StringPiece& product_id) { 136 const base::StringPiece& product_id) {
113 for (size_t i = 0; i < arraysize(AvailableMappings); ++i) { 137 for (size_t i = 0; i < arraysize(AvailableMappings); ++i) {
114 MappingData& item = AvailableMappings[i]; 138 MappingData& item = AvailableMappings[i];
115 if (vendor_id == item.vendor_id && product_id == item.product_id) 139 if (vendor_id == item.vendor_id && product_id == item.product_id)
116 return item.function; 140 return item.function;
117 } 141 }
118 return NULL; 142 return NULL;
119 } 143 }
120 144
121 } // namespace content 145 } // namespace content
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698