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

Side by Side Diff: content/browser/gamepad/gamepad_standard_mappings_mac.mm

Issue 10832162: Add support for Macally iShock. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: space 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 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
86 (dir >= .95f && dir <= 1.f); 86 (dir >= .95f && dir <= 1.f);
87 mapped->buttons[kButtonDpadRight] = dir >= -.75f && dir < -.1f; 87 mapped->buttons[kButtonDpadRight] = dir >= -.75f && dir < -.1f;
88 mapped->buttons[kButtonDpadDown] = dir >= -.2f && dir < .45f; 88 mapped->buttons[kButtonDpadDown] = dir >= -.2f && dir < .45f;
89 mapped->buttons[kButtonDpadLeft] = dir >= .4f && dir <= 1.f; 89 mapped->buttons[kButtonDpadLeft] = dir >= .4f && dir <= 1.f;
90 } 90 }
91 91
92 mapped->buttonsLength = kNumButtons - 1; /* no meta */ 92 mapped->buttonsLength = kNumButtons - 1; /* no meta */
93 mapped->axesLength = kNumAxes; 93 mapped->axesLength = kNumAxes;
94 } 94 }
95 95
96 void MapperMacallyIShock(
97 const WebKit::WebGamepad& input,
98 WebKit::WebGamepad* mapped) {
99 enum IShockButtons {
100 kButtonC = kNumButtons,
101 kButtonD,
102 kButtonE,
103 kNumIShockButtons
104 };
105
106 *mapped = input;
107 mapped->buttons[kButtonPrimary] = input.buttons[6];
108 mapped->buttons[kButtonSecondary] = input.buttons[5];
109 mapped->buttons[kButtonTertiary] = input.buttons[7];
110 mapped->buttons[kButtonQuaternary] = input.buttons[4];
111 mapped->buttons[kButtonLeftShoulder] = input.buttons[14];
112 mapped->buttons[kButtonRightShoulder] = input.buttons[12];
113 mapped->buttons[kButtonLeftTrigger] = input.buttons[15];
114 mapped->buttons[kButtonRightTrigger] = input.buttons[13];
115 mapped->buttons[kButtonBackSelect] = input.buttons[9];
116 mapped->buttons[kButtonStart] = input.buttons[10];
117 mapped->buttons[kButtonLeftThumbstick] = input.buttons[16];
118 mapped->buttons[kButtonRightThumbstick] = input.buttons[17];
119 mapped->buttons[kButtonDpadUp] = input.buttons[0];
120 mapped->buttons[kButtonDpadDown] = input.buttons[1];
121 mapped->buttons[kButtonDpadLeft] = input.buttons[2];
122 mapped->buttons[kButtonDpadRight] = input.buttons[3];
123 mapped->buttons[kButtonMeta] = input.buttons[11];
124 mapped->buttons[kButtonC] = input.buttons[8];
125 mapped->buttons[kButtonD] = input.buttons[18];
126 mapped->buttons[kButtonE] = input.buttons[19];
127 mapped->axes[kAxisLeftStickX] = input.axes[0];
128 mapped->axes[kAxisLeftStickY] = input.axes[1];
129 mapped->axes[kAxisRightStickX] = -input.axes[5];
130 mapped->axes[kAxisRightStickY] = input.axes[6];
131
132 mapped->buttonsLength = kNumIShockButtons;
133 mapped->axesLength = kNumAxes;
134 }
135
96 struct MappingData { 136 struct MappingData {
97 const char* const vendor_id; 137 const char* const vendor_id;
98 const char* const product_id; 138 const char* const product_id;
99 GamepadStandardMappingFunction function; 139 GamepadStandardMappingFunction function;
100 } AvailableMappings[] = { 140 } AvailableMappings[] = {
101 // http://www.linux-usb.org/usb.ids 141 // http://www.linux-usb.org/usb.ids
102 { "045e", "028e", MapperXbox360Gamepad }, // Xbox 360 Controller 142 { "045e", "028e", MapperXbox360Gamepad }, // Xbox 360 Controller
103 { "045e", "028f", MapperXbox360Gamepad }, // Xbox 360 Wireless Controller 143 { "045e", "028f", MapperXbox360Gamepad }, // Xbox 360 Wireless Controller
104 { "046d", "c216", MapperDirectInputStyle }, // Logitech F310, D mode 144 { "046d", "c216", MapperDirectInputStyle }, // Logitech F310, D mode
105 { "046d", "c218", MapperDirectInputStyle }, // Logitech F510, D mode 145 { "046d", "c218", MapperDirectInputStyle }, // Logitech F510, D mode
106 { "046d", "c219", MapperDirectInputStyle }, // Logitech F710, D mode 146 { "046d", "c219", MapperDirectInputStyle }, // Logitech F710, D mode
107 { "054c", "0268", MapperPlaystationSixAxis }, // Playstation SIXAXIS 147 { "054c", "0268", MapperPlaystationSixAxis }, // Playstation SIXAXIS
108 { "2222", "0060", MapperDirectInputStyle }, // Macally iShockX, analog mode 148 { "2222", "0060", MapperDirectInputStyle }, // Macally iShockX, analog mode
149 { "2222", "4010", MapperMacallyIShock }, // Macally iShock
109 }; 150 };
110 151
111 } // namespace 152 } // namespace
112 153
113 GamepadStandardMappingFunction GetGamepadStandardMappingFunction( 154 GamepadStandardMappingFunction GetGamepadStandardMappingFunction(
114 const base::StringPiece& vendor_id, 155 const base::StringPiece& vendor_id,
115 const base::StringPiece& product_id) { 156 const base::StringPiece& product_id) {
116 for (size_t i = 0; i < arraysize(AvailableMappings); ++i) { 157 for (size_t i = 0; i < arraysize(AvailableMappings); ++i) {
117 MappingData& item = AvailableMappings[i]; 158 MappingData& item = AvailableMappings[i];
118 if (vendor_id == item.vendor_id && product_id == item.product_id) 159 if (vendor_id == item.vendor_id && product_id == item.product_id)
119 return item.function; 160 return item.function;
120 } 161 }
121 return NULL; 162 return NULL;
122 } 163 }
123 164
124 } // namespace content 165 } // 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