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

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

Issue 625543002: Revert of Use the new java_cpp_enum rule in content. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 2 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
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 namespace content { 7 namespace content {
8 8
9 namespace { 9 namespace {
10 10
11 void MapperLogitechDualAction(const blink::WebGamepad& input, 11 void MapperLogitechDualAction(
12 blink::WebGamepad* mapped) { 12 const blink::WebGamepad& input,
13 blink::WebGamepad* mapped) {
13 *mapped = input; 14 *mapped = input;
14 mapped->buttons[BUTTON_INDEX_PRIMARY] = input.buttons[1]; 15 mapped->buttons[kButtonPrimary] = input.buttons[1];
15 mapped->buttons[BUTTON_INDEX_SECONDARY] = input.buttons[2]; 16 mapped->buttons[kButtonSecondary] = input.buttons[2];
16 mapped->buttons[BUTTON_INDEX_TERTIARY] = input.buttons[0]; 17 mapped->buttons[kButtonTertiary] = input.buttons[0];
17 mapped->axes[AXIS_INDEX_RIGHT_STICK_Y] = input.axes[5]; 18 mapped->axes[kAxisRightStickY] = input.axes[5];
18 DpadFromAxis(mapped, input.axes[9]); 19 DpadFromAxis(mapped, input.axes[9]);
19 20
20 mapped->buttonsLength = BUTTON_INDEX_COUNT; 21 mapped->buttonsLength = kNumButtons;
21 mapped->axesLength = AXIS_INDEX_COUNT; 22 mapped->axesLength = kNumAxes;
22 } 23 }
23 24
24 void Mapper2Axes8Keys(const blink::WebGamepad& input, 25 void Mapper2Axes8Keys(
25 blink::WebGamepad* mapped) { 26 const blink::WebGamepad& input,
27 blink::WebGamepad* mapped) {
26 *mapped = input; 28 *mapped = input;
27 mapped->buttons[BUTTON_INDEX_PRIMARY] = input.buttons[2]; 29 mapped->buttons[kButtonPrimary] = input.buttons[2];
28 mapped->buttons[BUTTON_INDEX_SECONDARY] = input.buttons[1]; 30 mapped->buttons[kButtonSecondary] = input.buttons[1];
29 mapped->buttons[BUTTON_INDEX_TERTIARY] = input.buttons[3]; 31 mapped->buttons[kButtonTertiary] = input.buttons[3];
30 mapped->buttons[BUTTON_INDEX_QUATERNARY] = input.buttons[0]; 32 mapped->buttons[kButtonQuaternary] = input.buttons[0];
31 mapped->buttons[BUTTON_INDEX_DPAD_UP] = AxisNegativeAsButton(input.axes[1]); 33 mapped->buttons[kButtonDpadUp] = AxisNegativeAsButton(input.axes[1]);
32 mapped->buttons[BUTTON_INDEX_DPAD_DOWN] = AxisPositiveAsButton(input.axes[1]); 34 mapped->buttons[kButtonDpadDown] = AxisPositiveAsButton(input.axes[1]);
33 mapped->buttons[BUTTON_INDEX_DPAD_LEFT] = AxisNegativeAsButton(input.axes[0]); 35 mapped->buttons[kButtonDpadLeft] = AxisNegativeAsButton(input.axes[0]);
34 mapped->buttons[BUTTON_INDEX_DPAD_RIGHT] = 36 mapped->buttons[kButtonDpadRight] = AxisPositiveAsButton(input.axes[0]);
35 AxisPositiveAsButton(input.axes[0]);
36 37
37 // Missing buttons 38 // Missing buttons
38 mapped->buttons[BUTTON_INDEX_LEFT_TRIGGER] = blink::WebGamepadButton(); 39 mapped->buttons[kButtonLeftTrigger] = blink::WebGamepadButton();
39 mapped->buttons[BUTTON_INDEX_RIGHT_TRIGGER] = blink::WebGamepadButton(); 40 mapped->buttons[kButtonRightTrigger] = blink::WebGamepadButton();
40 mapped->buttons[BUTTON_INDEX_LEFT_THUMBSTICK] = blink::WebGamepadButton(); 41 mapped->buttons[kButtonLeftThumbstick] = blink::WebGamepadButton();
41 mapped->buttons[BUTTON_INDEX_RIGHT_THUMBSTICK] = blink::WebGamepadButton(); 42 mapped->buttons[kButtonRightThumbstick] = blink::WebGamepadButton();
42 mapped->buttons[BUTTON_INDEX_META] = blink::WebGamepadButton(); 43 mapped->buttons[kButtonMeta] = blink::WebGamepadButton();
43 44
44 mapped->buttonsLength = BUTTON_INDEX_COUNT - 1; 45 mapped->buttonsLength = kNumButtons - 1;
45 mapped->axesLength = 0; 46 mapped->axesLength = 0;
46 } 47 }
47 48
48 void MapperDualshock4(const blink::WebGamepad& input, 49 void MapperDualshock4(
49 blink::WebGamepad* mapped) { 50 const blink::WebGamepad& input,
51 blink::WebGamepad* mapped) {
50 enum Dualshock4Buttons { 52 enum Dualshock4Buttons {
51 DUALSHOCK_BUTTON_TOUCHPAD = BUTTON_INDEX_COUNT, 53 kTouchpadButton = kNumButtons,
52 DUALSHOCK_BUTTON_COUNT 54 kNumDualshock4Buttons
53 }; 55 };
54 56
55 *mapped = input; 57 *mapped = input;
56 mapped->buttons[BUTTON_INDEX_PRIMARY] = input.buttons[1]; 58 mapped->buttons[kButtonPrimary] = input.buttons[1];
57 mapped->buttons[BUTTON_INDEX_SECONDARY] = input.buttons[2]; 59 mapped->buttons[kButtonSecondary] = input.buttons[2];
58 mapped->buttons[BUTTON_INDEX_TERTIARY] = input.buttons[0]; 60 mapped->buttons[kButtonTertiary] = input.buttons[0];
59 mapped->buttons[BUTTON_INDEX_QUATERNARY] = input.buttons[3]; 61 mapped->buttons[kButtonQuaternary] = input.buttons[3];
60 mapped->buttons[BUTTON_INDEX_LEFT_SHOULDER] = input.buttons[4]; 62 mapped->buttons[kButtonLeftShoulder] = input.buttons[4];
61 mapped->buttons[BUTTON_INDEX_RIGHT_SHOULDER] = input.buttons[5]; 63 mapped->buttons[kButtonRightShoulder] = input.buttons[5];
62 mapped->buttons[BUTTON_INDEX_LEFT_TRIGGER] = AxisToButton(input.axes[3]); 64 mapped->buttons[kButtonLeftTrigger] = AxisToButton(input.axes[3]);
63 mapped->buttons[BUTTON_INDEX_RIGHT_TRIGGER] = AxisToButton(input.axes[4]); 65 mapped->buttons[kButtonRightTrigger] = AxisToButton(input.axes[4]);
64 mapped->buttons[BUTTON_INDEX_BACK_SELECT] = input.buttons[8]; 66 mapped->buttons[kButtonBackSelect] = input.buttons[8];
65 mapped->buttons[BUTTON_INDEX_START] = input.buttons[9]; 67 mapped->buttons[kButtonStart] = input.buttons[9];
66 mapped->buttons[BUTTON_INDEX_LEFT_THUMBSTICK] = input.buttons[10]; 68 mapped->buttons[kButtonLeftThumbstick] = input.buttons[10];
67 mapped->buttons[BUTTON_INDEX_RIGHT_THUMBSTICK] = input.buttons[11]; 69 mapped->buttons[kButtonRightThumbstick] = input.buttons[11];
68 mapped->buttons[BUTTON_INDEX_META] = input.buttons[12]; 70 mapped->buttons[kButtonMeta] = input.buttons[12];
69 mapped->buttons[DUALSHOCK_BUTTON_TOUCHPAD] = input.buttons[13]; 71 mapped->buttons[kTouchpadButton] = input.buttons[13];
70 mapped->axes[AXIS_INDEX_RIGHT_STICK_Y] = input.axes[5]; 72 mapped->axes[kAxisRightStickY] = input.axes[5];
71 DpadFromAxis(mapped, input.axes[9]); 73 DpadFromAxis(mapped, input.axes[9]);
72 74
73 mapped->buttonsLength = DUALSHOCK_BUTTON_COUNT; 75 mapped->buttonsLength = kNumDualshock4Buttons;
74 mapped->axesLength = AXIS_INDEX_COUNT; 76 mapped->axesLength = kNumAxes;
75 } 77 }
76 78
77 void MapperOnLiveWireless(const blink::WebGamepad& input, 79 void MapperOnLiveWireless(
78 blink::WebGamepad* mapped) { 80 const blink::WebGamepad& input,
81 blink::WebGamepad* mapped) {
79 *mapped = input; 82 *mapped = input;
80 mapped->buttons[BUTTON_INDEX_PRIMARY] = input.buttons[0]; 83 mapped->buttons[kButtonPrimary] = input.buttons[0];
81 mapped->buttons[BUTTON_INDEX_SECONDARY] = input.buttons[1]; 84 mapped->buttons[kButtonSecondary] = input.buttons[1];
82 mapped->buttons[BUTTON_INDEX_TERTIARY] = input.buttons[3]; 85 mapped->buttons[kButtonTertiary] = input.buttons[3];
83 mapped->buttons[BUTTON_INDEX_QUATERNARY] = input.buttons[4]; 86 mapped->buttons[kButtonQuaternary] = input.buttons[4];
84 mapped->buttons[BUTTON_INDEX_LEFT_SHOULDER] = input.buttons[6]; 87 mapped->buttons[kButtonLeftShoulder] = input.buttons[6];
85 mapped->buttons[BUTTON_INDEX_RIGHT_SHOULDER] = input.buttons[7]; 88 mapped->buttons[kButtonRightShoulder] = input.buttons[7];
86 mapped->buttons[BUTTON_INDEX_LEFT_TRIGGER] = AxisToButton(input.axes[2]); 89 mapped->buttons[kButtonLeftTrigger] = AxisToButton(input.axes[2]);
87 mapped->buttons[BUTTON_INDEX_RIGHT_TRIGGER] = AxisToButton(input.axes[5]); 90 mapped->buttons[kButtonRightTrigger] = AxisToButton(input.axes[5]);
88 mapped->buttons[BUTTON_INDEX_BACK_SELECT] = input.buttons[10]; 91 mapped->buttons[kButtonBackSelect] = input.buttons[10];
89 mapped->buttons[BUTTON_INDEX_START] = input.buttons[11]; 92 mapped->buttons[kButtonStart] = input.buttons[11];
90 mapped->buttons[BUTTON_INDEX_LEFT_THUMBSTICK] = input.buttons[13]; 93 mapped->buttons[kButtonLeftThumbstick] = input.buttons[13];
91 mapped->buttons[BUTTON_INDEX_RIGHT_THUMBSTICK] = input.buttons[14]; 94 mapped->buttons[kButtonRightThumbstick] = input.buttons[14];
92 mapped->buttons[BUTTON_INDEX_META] = input.buttons[12]; 95 mapped->buttons[kButtonMeta] = input.buttons[12];
93 mapped->axes[AXIS_INDEX_RIGHT_STICK_X] = input.axes[3]; 96 mapped->axes[kAxisRightStickX] = input.axes[3];
94 mapped->axes[AXIS_INDEX_RIGHT_STICK_Y] = input.axes[4]; 97 mapped->axes[kAxisRightStickY] = input.axes[4];
95 DpadFromAxis(mapped, input.axes[9]); 98 DpadFromAxis(mapped, input.axes[9]);
96 99
97 mapped->buttonsLength = BUTTON_INDEX_COUNT; 100 mapped->buttonsLength = kNumButtons;
98 mapped->axesLength = AXIS_INDEX_COUNT; 101 mapped->axesLength = kNumAxes;
99 } 102 }
100 103
101 void MapperADT1(const blink::WebGamepad& input, blink::WebGamepad* mapped) { 104 void MapperADT1(
105 const blink::WebGamepad& input,
106 blink::WebGamepad* mapped) {
102 *mapped = input; 107 *mapped = input;
103 mapped->buttons[BUTTON_INDEX_PRIMARY] = input.buttons[0]; 108 mapped->buttons[kButtonPrimary] = input.buttons[0];
104 mapped->buttons[BUTTON_INDEX_SECONDARY] = input.buttons[1]; 109 mapped->buttons[kButtonSecondary] = input.buttons[1];
105 mapped->buttons[BUTTON_INDEX_TERTIARY] = input.buttons[3]; 110 mapped->buttons[kButtonTertiary] = input.buttons[3];
106 mapped->buttons[BUTTON_INDEX_QUATERNARY] = input.buttons[4]; 111 mapped->buttons[kButtonQuaternary] = input.buttons[4];
107 mapped->buttons[BUTTON_INDEX_LEFT_SHOULDER] = input.buttons[6]; 112 mapped->buttons[kButtonLeftShoulder] = input.buttons[6];
108 mapped->buttons[BUTTON_INDEX_RIGHT_SHOULDER] = input.buttons[7]; 113 mapped->buttons[kButtonRightShoulder] = input.buttons[7];
109 mapped->buttons[BUTTON_INDEX_LEFT_TRIGGER] = AxisToButton(input.axes[4]); 114 mapped->buttons[kButtonLeftTrigger] = AxisToButton(input.axes[4]);
110 mapped->buttons[BUTTON_INDEX_RIGHT_TRIGGER] = AxisToButton(input.axes[3]); 115 mapped->buttons[kButtonRightTrigger] = AxisToButton(input.axes[3]);
111 mapped->buttons[BUTTON_INDEX_BACK_SELECT] = NullButton(); 116 mapped->buttons[kButtonBackSelect] = NullButton();
112 mapped->buttons[BUTTON_INDEX_START] = NullButton(); 117 mapped->buttons[kButtonStart] = NullButton();
113 mapped->buttons[BUTTON_INDEX_LEFT_THUMBSTICK] = input.buttons[13]; 118 mapped->buttons[kButtonLeftThumbstick] = input.buttons[13];
114 mapped->buttons[BUTTON_INDEX_RIGHT_THUMBSTICK] = input.buttons[14]; 119 mapped->buttons[kButtonRightThumbstick] = input.buttons[14];
115 mapped->buttons[BUTTON_INDEX_META] = input.buttons[12]; 120 mapped->buttons[kButtonMeta] = input.buttons[12];
116 mapped->axes[AXIS_INDEX_RIGHT_STICK_Y] = input.axes[5]; 121 mapped->axes[kAxisRightStickY] = input.axes[5];
117 DpadFromAxis(mapped, input.axes[9]); 122 DpadFromAxis(mapped, input.axes[9]);
118 123
119 mapped->buttonsLength = BUTTON_INDEX_COUNT; 124 mapped->buttonsLength = kNumButtons;
120 mapped->axesLength = AXIS_INDEX_COUNT; 125 mapped->axesLength = kNumAxes;
121 } 126 }
122 127
123 struct MappingData { 128 struct MappingData {
124 const char* const vendor_id; 129 const char* const vendor_id;
125 const char* const product_id; 130 const char* const product_id;
126 GamepadStandardMappingFunction function; 131 GamepadStandardMappingFunction function;
127 } AvailableMappings[] = { 132 } AvailableMappings[] = {
128 // http://www.linux-usb.org/usb.ids 133 // http://www.linux-usb.org/usb.ids
129 {"046d", "c216", MapperLogitechDualAction}, // Logitech DualAction 134 { "046d", "c216", MapperLogitechDualAction }, // Logitech DualAction
130 {"0079", "0011", Mapper2Axes8Keys}, // 2Axes 8Keys Game Pad 135 { "0079", "0011", Mapper2Axes8Keys }, // 2Axes 8Keys Game Pad
131 {"054c", "05c4", MapperDualshock4}, // Playstation Dualshock 4 136 { "054c", "05c4", MapperDualshock4 }, // Playstation Dualshock 4
132 {"2378", "1008", MapperOnLiveWireless}, // OnLive Controller (Bluetooth) 137 { "2378", "1008", MapperOnLiveWireless }, // OnLive Controller (Bluetooth)
133 {"2378", "100a", MapperOnLiveWireless}, // OnLive Controller (Wired) 138 { "2378", "100a", MapperOnLiveWireless }, // OnLive Controller (Wired)
134 {"18d1", "2c40", MapperADT1}, // ADT-1 Controller 139 { "18d1", "2c40", MapperADT1 }, // ADT-1 Controller
135 }; 140 };
136 141
137 } // namespace 142 } // namespace
138 143
139 GamepadStandardMappingFunction GetGamepadStandardMappingFunction( 144 GamepadStandardMappingFunction GetGamepadStandardMappingFunction(
140 const base::StringPiece& vendor_id, 145 const base::StringPiece& vendor_id,
141 const base::StringPiece& product_id) { 146 const base::StringPiece& product_id) {
142 for (size_t i = 0; i < arraysize(AvailableMappings); ++i) { 147 for (size_t i = 0; i < arraysize(AvailableMappings); ++i) {
143 MappingData& item = AvailableMappings[i]; 148 MappingData& item = AvailableMappings[i];
144 if (vendor_id == item.vendor_id && product_id == item.product_id) 149 if (vendor_id == item.vendor_id && product_id == item.product_id)
145 return item.function; 150 return item.function;
146 } 151 }
147 return NULL; 152 return NULL;
148 } 153 }
149 154
150 } // namespace content 155 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/gamepad/gamepad_standard_mappings_mac.mm ('k') | content/browser/renderer_host/input/selection_event_type.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698