| 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 "device/gamepad/gamepad_standard_mappings.h" | 8 #include "device/gamepad/gamepad_standard_mappings.h" |
| 9 | 9 |
| 10 namespace device { | 10 namespace device { |
| 11 | 11 |
| 12 namespace { | 12 namespace { |
| 13 | 13 |
| 14 void MapperLogitechDualAction(const blink::WebGamepad& input, | 14 void MapperLogitechDualAction(const Gamepad& input, Gamepad* mapped) { |
| 15 blink::WebGamepad* mapped) { | |
| 16 *mapped = input; | 15 *mapped = input; |
| 17 mapped->buttons[BUTTON_INDEX_PRIMARY] = input.buttons[1]; | 16 mapped->buttons[BUTTON_INDEX_PRIMARY] = input.buttons[1]; |
| 18 mapped->buttons[BUTTON_INDEX_SECONDARY] = input.buttons[2]; | 17 mapped->buttons[BUTTON_INDEX_SECONDARY] = input.buttons[2]; |
| 19 mapped->buttons[BUTTON_INDEX_TERTIARY] = input.buttons[0]; | 18 mapped->buttons[BUTTON_INDEX_TERTIARY] = input.buttons[0]; |
| 20 mapped->axes[AXIS_INDEX_RIGHT_STICK_Y] = input.axes[5]; | 19 mapped->axes[AXIS_INDEX_RIGHT_STICK_Y] = input.axes[5]; |
| 21 DpadFromAxis(mapped, input.axes[9]); | 20 DpadFromAxis(mapped, input.axes[9]); |
| 22 | 21 |
| 23 mapped->buttons_length = BUTTON_INDEX_COUNT; | 22 mapped->buttons_length = BUTTON_INDEX_COUNT; |
| 24 mapped->axes_length = AXIS_INDEX_COUNT; | 23 mapped->axes_length = AXIS_INDEX_COUNT; |
| 25 } | 24 } |
| 26 | 25 |
| 27 void Mapper2Axes8Keys(const blink::WebGamepad& input, | 26 void Mapper2Axes8Keys(const Gamepad& input, Gamepad* mapped) { |
| 28 blink::WebGamepad* mapped) { | |
| 29 *mapped = input; | 27 *mapped = input; |
| 30 mapped->buttons[BUTTON_INDEX_PRIMARY] = input.buttons[2]; | 28 mapped->buttons[BUTTON_INDEX_PRIMARY] = input.buttons[2]; |
| 31 mapped->buttons[BUTTON_INDEX_SECONDARY] = input.buttons[1]; | 29 mapped->buttons[BUTTON_INDEX_SECONDARY] = input.buttons[1]; |
| 32 mapped->buttons[BUTTON_INDEX_TERTIARY] = input.buttons[3]; | 30 mapped->buttons[BUTTON_INDEX_TERTIARY] = input.buttons[3]; |
| 33 mapped->buttons[BUTTON_INDEX_QUATERNARY] = input.buttons[0]; | 31 mapped->buttons[BUTTON_INDEX_QUATERNARY] = input.buttons[0]; |
| 34 mapped->buttons[BUTTON_INDEX_DPAD_UP] = AxisNegativeAsButton(input.axes[1]); | 32 mapped->buttons[BUTTON_INDEX_DPAD_UP] = AxisNegativeAsButton(input.axes[1]); |
| 35 mapped->buttons[BUTTON_INDEX_DPAD_DOWN] = AxisPositiveAsButton(input.axes[1]); | 33 mapped->buttons[BUTTON_INDEX_DPAD_DOWN] = AxisPositiveAsButton(input.axes[1]); |
| 36 mapped->buttons[BUTTON_INDEX_DPAD_LEFT] = AxisNegativeAsButton(input.axes[0]); | 34 mapped->buttons[BUTTON_INDEX_DPAD_LEFT] = AxisNegativeAsButton(input.axes[0]); |
| 37 mapped->buttons[BUTTON_INDEX_DPAD_RIGHT] = | 35 mapped->buttons[BUTTON_INDEX_DPAD_RIGHT] = |
| 38 AxisPositiveAsButton(input.axes[0]); | 36 AxisPositiveAsButton(input.axes[0]); |
| 39 | 37 |
| 40 // Missing buttons | 38 // Missing buttons |
| 41 mapped->buttons[BUTTON_INDEX_LEFT_TRIGGER] = blink::WebGamepadButton(); | 39 mapped->buttons[BUTTON_INDEX_LEFT_TRIGGER] = GamepadButton(); |
| 42 mapped->buttons[BUTTON_INDEX_RIGHT_TRIGGER] = blink::WebGamepadButton(); | 40 mapped->buttons[BUTTON_INDEX_RIGHT_TRIGGER] = GamepadButton(); |
| 43 mapped->buttons[BUTTON_INDEX_LEFT_THUMBSTICK] = blink::WebGamepadButton(); | 41 mapped->buttons[BUTTON_INDEX_LEFT_THUMBSTICK] = GamepadButton(); |
| 44 mapped->buttons[BUTTON_INDEX_RIGHT_THUMBSTICK] = blink::WebGamepadButton(); | 42 mapped->buttons[BUTTON_INDEX_RIGHT_THUMBSTICK] = GamepadButton(); |
| 45 mapped->buttons[BUTTON_INDEX_META] = blink::WebGamepadButton(); | 43 mapped->buttons[BUTTON_INDEX_META] = GamepadButton(); |
| 46 | 44 |
| 47 mapped->buttons_length = BUTTON_INDEX_COUNT - 1; | 45 mapped->buttons_length = BUTTON_INDEX_COUNT - 1; |
| 48 mapped->axes_length = 0; | 46 mapped->axes_length = 0; |
| 49 } | 47 } |
| 50 | 48 |
| 51 void MapperDualshock4(const blink::WebGamepad& input, | 49 void MapperDualshock4(const Gamepad& input, Gamepad* mapped) { |
| 52 blink::WebGamepad* mapped) { | |
| 53 enum Dualshock4Buttons { | 50 enum Dualshock4Buttons { |
| 54 DUALSHOCK_BUTTON_TOUCHPAD = BUTTON_INDEX_COUNT, | 51 DUALSHOCK_BUTTON_TOUCHPAD = BUTTON_INDEX_COUNT, |
| 55 DUALSHOCK_BUTTON_COUNT | 52 DUALSHOCK_BUTTON_COUNT |
| 56 }; | 53 }; |
| 57 | 54 |
| 58 *mapped = input; | 55 *mapped = input; |
| 59 mapped->buttons[BUTTON_INDEX_PRIMARY] = input.buttons[1]; | 56 mapped->buttons[BUTTON_INDEX_PRIMARY] = input.buttons[1]; |
| 60 mapped->buttons[BUTTON_INDEX_SECONDARY] = input.buttons[2]; | 57 mapped->buttons[BUTTON_INDEX_SECONDARY] = input.buttons[2]; |
| 61 mapped->buttons[BUTTON_INDEX_TERTIARY] = input.buttons[0]; | 58 mapped->buttons[BUTTON_INDEX_TERTIARY] = input.buttons[0]; |
| 62 mapped->buttons[BUTTON_INDEX_QUATERNARY] = input.buttons[3]; | 59 mapped->buttons[BUTTON_INDEX_QUATERNARY] = input.buttons[3]; |
| 63 mapped->buttons[BUTTON_INDEX_LEFT_SHOULDER] = input.buttons[4]; | 60 mapped->buttons[BUTTON_INDEX_LEFT_SHOULDER] = input.buttons[4]; |
| 64 mapped->buttons[BUTTON_INDEX_RIGHT_SHOULDER] = input.buttons[5]; | 61 mapped->buttons[BUTTON_INDEX_RIGHT_SHOULDER] = input.buttons[5]; |
| 65 mapped->buttons[BUTTON_INDEX_LEFT_TRIGGER] = AxisToButton(input.axes[3]); | 62 mapped->buttons[BUTTON_INDEX_LEFT_TRIGGER] = AxisToButton(input.axes[3]); |
| 66 mapped->buttons[BUTTON_INDEX_RIGHT_TRIGGER] = AxisToButton(input.axes[4]); | 63 mapped->buttons[BUTTON_INDEX_RIGHT_TRIGGER] = AxisToButton(input.axes[4]); |
| 67 mapped->buttons[BUTTON_INDEX_BACK_SELECT] = input.buttons[8]; | 64 mapped->buttons[BUTTON_INDEX_BACK_SELECT] = input.buttons[8]; |
| 68 mapped->buttons[BUTTON_INDEX_START] = input.buttons[9]; | 65 mapped->buttons[BUTTON_INDEX_START] = input.buttons[9]; |
| 69 mapped->buttons[BUTTON_INDEX_LEFT_THUMBSTICK] = input.buttons[10]; | 66 mapped->buttons[BUTTON_INDEX_LEFT_THUMBSTICK] = input.buttons[10]; |
| 70 mapped->buttons[BUTTON_INDEX_RIGHT_THUMBSTICK] = input.buttons[11]; | 67 mapped->buttons[BUTTON_INDEX_RIGHT_THUMBSTICK] = input.buttons[11]; |
| 71 mapped->buttons[BUTTON_INDEX_META] = input.buttons[12]; | 68 mapped->buttons[BUTTON_INDEX_META] = input.buttons[12]; |
| 72 mapped->buttons[DUALSHOCK_BUTTON_TOUCHPAD] = input.buttons[13]; | 69 mapped->buttons[DUALSHOCK_BUTTON_TOUCHPAD] = input.buttons[13]; |
| 73 mapped->axes[AXIS_INDEX_RIGHT_STICK_Y] = input.axes[5]; | 70 mapped->axes[AXIS_INDEX_RIGHT_STICK_Y] = input.axes[5]; |
| 74 DpadFromAxis(mapped, input.axes[9]); | 71 DpadFromAxis(mapped, input.axes[9]); |
| 75 | 72 |
| 76 mapped->buttons_length = DUALSHOCK_BUTTON_COUNT; | 73 mapped->buttons_length = DUALSHOCK_BUTTON_COUNT; |
| 77 mapped->axes_length = AXIS_INDEX_COUNT; | 74 mapped->axes_length = AXIS_INDEX_COUNT; |
| 78 } | 75 } |
| 79 | 76 |
| 80 void MapperIBuffalo(const blink::WebGamepad& input, blink::WebGamepad* mapped) { | 77 void MapperIBuffalo(const Gamepad& input, Gamepad* mapped) { |
| 81 *mapped = input; | 78 *mapped = input; |
| 82 mapped->buttons[BUTTON_INDEX_PRIMARY] = input.buttons[1]; | 79 mapped->buttons[BUTTON_INDEX_PRIMARY] = input.buttons[1]; |
| 83 mapped->buttons[BUTTON_INDEX_SECONDARY] = input.buttons[0]; | 80 mapped->buttons[BUTTON_INDEX_SECONDARY] = input.buttons[0]; |
| 84 mapped->buttons[BUTTON_INDEX_TERTIARY] = input.buttons[3]; | 81 mapped->buttons[BUTTON_INDEX_TERTIARY] = input.buttons[3]; |
| 85 mapped->buttons[BUTTON_INDEX_QUATERNARY] = input.buttons[2]; | 82 mapped->buttons[BUTTON_INDEX_QUATERNARY] = input.buttons[2]; |
| 86 mapped->buttons[BUTTON_INDEX_BACK_SELECT] = input.buttons[6]; | 83 mapped->buttons[BUTTON_INDEX_BACK_SELECT] = input.buttons[6]; |
| 87 mapped->buttons[BUTTON_INDEX_START] = input.buttons[7]; | 84 mapped->buttons[BUTTON_INDEX_START] = input.buttons[7]; |
| 88 mapped->buttons[BUTTON_INDEX_LEFT_TRIGGER] = input.buttons[4]; | 85 mapped->buttons[BUTTON_INDEX_LEFT_TRIGGER] = input.buttons[4]; |
| 89 mapped->buttons[BUTTON_INDEX_RIGHT_TRIGGER] = input.buttons[5]; | 86 mapped->buttons[BUTTON_INDEX_RIGHT_TRIGGER] = input.buttons[5]; |
| 90 mapped->buttons[BUTTON_INDEX_DPAD_UP] = AxisNegativeAsButton(input.axes[1]); | 87 mapped->buttons[BUTTON_INDEX_DPAD_UP] = AxisNegativeAsButton(input.axes[1]); |
| 91 mapped->buttons[BUTTON_INDEX_DPAD_DOWN] = AxisPositiveAsButton(input.axes[1]); | 88 mapped->buttons[BUTTON_INDEX_DPAD_DOWN] = AxisPositiveAsButton(input.axes[1]); |
| 92 mapped->buttons[BUTTON_INDEX_DPAD_LEFT] = AxisNegativeAsButton(input.axes[0]); | 89 mapped->buttons[BUTTON_INDEX_DPAD_LEFT] = AxisNegativeAsButton(input.axes[0]); |
| 93 mapped->buttons[BUTTON_INDEX_DPAD_RIGHT] = | 90 mapped->buttons[BUTTON_INDEX_DPAD_RIGHT] = |
| 94 AxisPositiveAsButton(input.axes[0]); | 91 AxisPositiveAsButton(input.axes[0]); |
| 95 mapped->buttons_length = BUTTON_INDEX_COUNT - 1; /* no meta */ | 92 mapped->buttons_length = BUTTON_INDEX_COUNT - 1; /* no meta */ |
| 96 mapped->axes_length = 2; | 93 mapped->axes_length = 2; |
| 97 } | 94 } |
| 98 | 95 |
| 99 void MapperOnLiveWireless(const blink::WebGamepad& input, | 96 void MapperOnLiveWireless(const Gamepad& input, Gamepad* mapped) { |
| 100 blink::WebGamepad* mapped) { | |
| 101 *mapped = input; | 97 *mapped = input; |
| 102 mapped->buttons[BUTTON_INDEX_PRIMARY] = input.buttons[0]; | 98 mapped->buttons[BUTTON_INDEX_PRIMARY] = input.buttons[0]; |
| 103 mapped->buttons[BUTTON_INDEX_SECONDARY] = input.buttons[1]; | 99 mapped->buttons[BUTTON_INDEX_SECONDARY] = input.buttons[1]; |
| 104 mapped->buttons[BUTTON_INDEX_TERTIARY] = input.buttons[3]; | 100 mapped->buttons[BUTTON_INDEX_TERTIARY] = input.buttons[3]; |
| 105 mapped->buttons[BUTTON_INDEX_QUATERNARY] = input.buttons[4]; | 101 mapped->buttons[BUTTON_INDEX_QUATERNARY] = input.buttons[4]; |
| 106 mapped->buttons[BUTTON_INDEX_LEFT_SHOULDER] = input.buttons[6]; | 102 mapped->buttons[BUTTON_INDEX_LEFT_SHOULDER] = input.buttons[6]; |
| 107 mapped->buttons[BUTTON_INDEX_RIGHT_SHOULDER] = input.buttons[7]; | 103 mapped->buttons[BUTTON_INDEX_RIGHT_SHOULDER] = input.buttons[7]; |
| 108 mapped->buttons[BUTTON_INDEX_LEFT_TRIGGER] = AxisToButton(input.axes[2]); | 104 mapped->buttons[BUTTON_INDEX_LEFT_TRIGGER] = AxisToButton(input.axes[2]); |
| 109 mapped->buttons[BUTTON_INDEX_RIGHT_TRIGGER] = AxisToButton(input.axes[5]); | 105 mapped->buttons[BUTTON_INDEX_RIGHT_TRIGGER] = AxisToButton(input.axes[5]); |
| 110 mapped->buttons[BUTTON_INDEX_BACK_SELECT] = input.buttons[10]; | 106 mapped->buttons[BUTTON_INDEX_BACK_SELECT] = input.buttons[10]; |
| 111 mapped->buttons[BUTTON_INDEX_START] = input.buttons[11]; | 107 mapped->buttons[BUTTON_INDEX_START] = input.buttons[11]; |
| 112 mapped->buttons[BUTTON_INDEX_LEFT_THUMBSTICK] = input.buttons[13]; | 108 mapped->buttons[BUTTON_INDEX_LEFT_THUMBSTICK] = input.buttons[13]; |
| 113 mapped->buttons[BUTTON_INDEX_RIGHT_THUMBSTICK] = input.buttons[14]; | 109 mapped->buttons[BUTTON_INDEX_RIGHT_THUMBSTICK] = input.buttons[14]; |
| 114 mapped->buttons[BUTTON_INDEX_META] = input.buttons[12]; | 110 mapped->buttons[BUTTON_INDEX_META] = input.buttons[12]; |
| 115 mapped->axes[AXIS_INDEX_RIGHT_STICK_X] = input.axes[3]; | 111 mapped->axes[AXIS_INDEX_RIGHT_STICK_X] = input.axes[3]; |
| 116 mapped->axes[AXIS_INDEX_RIGHT_STICK_Y] = input.axes[4]; | 112 mapped->axes[AXIS_INDEX_RIGHT_STICK_Y] = input.axes[4]; |
| 117 DpadFromAxis(mapped, input.axes[9]); | 113 DpadFromAxis(mapped, input.axes[9]); |
| 118 | 114 |
| 119 mapped->buttons_length = BUTTON_INDEX_COUNT; | 115 mapped->buttons_length = BUTTON_INDEX_COUNT; |
| 120 mapped->axes_length = AXIS_INDEX_COUNT; | 116 mapped->axes_length = AXIS_INDEX_COUNT; |
| 121 } | 117 } |
| 122 | 118 |
| 123 void MapperADT1(const blink::WebGamepad& input, blink::WebGamepad* mapped) { | 119 void MapperADT1(const Gamepad& input, Gamepad* mapped) { |
| 124 *mapped = input; | 120 *mapped = input; |
| 125 mapped->buttons[BUTTON_INDEX_PRIMARY] = input.buttons[0]; | 121 mapped->buttons[BUTTON_INDEX_PRIMARY] = input.buttons[0]; |
| 126 mapped->buttons[BUTTON_INDEX_SECONDARY] = input.buttons[1]; | 122 mapped->buttons[BUTTON_INDEX_SECONDARY] = input.buttons[1]; |
| 127 mapped->buttons[BUTTON_INDEX_TERTIARY] = input.buttons[3]; | 123 mapped->buttons[BUTTON_INDEX_TERTIARY] = input.buttons[3]; |
| 128 mapped->buttons[BUTTON_INDEX_QUATERNARY] = input.buttons[4]; | 124 mapped->buttons[BUTTON_INDEX_QUATERNARY] = input.buttons[4]; |
| 129 mapped->buttons[BUTTON_INDEX_LEFT_SHOULDER] = input.buttons[6]; | 125 mapped->buttons[BUTTON_INDEX_LEFT_SHOULDER] = input.buttons[6]; |
| 130 mapped->buttons[BUTTON_INDEX_RIGHT_SHOULDER] = input.buttons[7]; | 126 mapped->buttons[BUTTON_INDEX_RIGHT_SHOULDER] = input.buttons[7]; |
| 131 mapped->buttons[BUTTON_INDEX_LEFT_TRIGGER] = AxisToButton(input.axes[4]); | 127 mapped->buttons[BUTTON_INDEX_LEFT_TRIGGER] = AxisToButton(input.axes[4]); |
| 132 mapped->buttons[BUTTON_INDEX_RIGHT_TRIGGER] = AxisToButton(input.axes[3]); | 128 mapped->buttons[BUTTON_INDEX_RIGHT_TRIGGER] = AxisToButton(input.axes[3]); |
| 133 mapped->buttons[BUTTON_INDEX_BACK_SELECT] = NullButton(); | 129 mapped->buttons[BUTTON_INDEX_BACK_SELECT] = NullButton(); |
| 134 mapped->buttons[BUTTON_INDEX_START] = NullButton(); | 130 mapped->buttons[BUTTON_INDEX_START] = NullButton(); |
| 135 mapped->buttons[BUTTON_INDEX_LEFT_THUMBSTICK] = input.buttons[13]; | 131 mapped->buttons[BUTTON_INDEX_LEFT_THUMBSTICK] = input.buttons[13]; |
| 136 mapped->buttons[BUTTON_INDEX_RIGHT_THUMBSTICK] = input.buttons[14]; | 132 mapped->buttons[BUTTON_INDEX_RIGHT_THUMBSTICK] = input.buttons[14]; |
| 137 mapped->buttons[BUTTON_INDEX_META] = input.buttons[12]; | 133 mapped->buttons[BUTTON_INDEX_META] = input.buttons[12]; |
| 138 mapped->axes[AXIS_INDEX_RIGHT_STICK_Y] = input.axes[5]; | 134 mapped->axes[AXIS_INDEX_RIGHT_STICK_Y] = input.axes[5]; |
| 139 DpadFromAxis(mapped, input.axes[9]); | 135 DpadFromAxis(mapped, input.axes[9]); |
| 140 | 136 |
| 141 mapped->buttons_length = BUTTON_INDEX_COUNT; | 137 mapped->buttons_length = BUTTON_INDEX_COUNT; |
| 142 mapped->axes_length = AXIS_INDEX_COUNT; | 138 mapped->axes_length = AXIS_INDEX_COUNT; |
| 143 } | 139 } |
| 144 | 140 |
| 145 void MapperNvShield(const blink::WebGamepad& input, blink::WebGamepad* mapped) { | 141 void MapperNvShield(const Gamepad& input, Gamepad* mapped) { |
| 146 *mapped = input; | 142 *mapped = input; |
| 147 mapped->buttons[BUTTON_INDEX_PRIMARY] = input.buttons[0]; | 143 mapped->buttons[BUTTON_INDEX_PRIMARY] = input.buttons[0]; |
| 148 mapped->buttons[BUTTON_INDEX_SECONDARY] = input.buttons[1]; | 144 mapped->buttons[BUTTON_INDEX_SECONDARY] = input.buttons[1]; |
| 149 mapped->buttons[BUTTON_INDEX_TERTIARY] = input.buttons[3]; | 145 mapped->buttons[BUTTON_INDEX_TERTIARY] = input.buttons[3]; |
| 150 mapped->buttons[BUTTON_INDEX_QUATERNARY] = input.buttons[4]; | 146 mapped->buttons[BUTTON_INDEX_QUATERNARY] = input.buttons[4]; |
| 151 mapped->buttons[BUTTON_INDEX_LEFT_SHOULDER] = input.buttons[6]; | 147 mapped->buttons[BUTTON_INDEX_LEFT_SHOULDER] = input.buttons[6]; |
| 152 mapped->buttons[BUTTON_INDEX_RIGHT_SHOULDER] = input.buttons[7]; | 148 mapped->buttons[BUTTON_INDEX_RIGHT_SHOULDER] = input.buttons[7]; |
| 153 mapped->buttons[BUTTON_INDEX_LEFT_TRIGGER] = AxisToButton(input.axes[4]); | 149 mapped->buttons[BUTTON_INDEX_LEFT_TRIGGER] = AxisToButton(input.axes[4]); |
| 154 mapped->buttons[BUTTON_INDEX_RIGHT_TRIGGER] = AxisToButton(input.axes[3]); | 150 mapped->buttons[BUTTON_INDEX_RIGHT_TRIGGER] = AxisToButton(input.axes[3]); |
| 155 mapped->buttons[BUTTON_INDEX_BACK_SELECT] = NullButton(); | 151 mapped->buttons[BUTTON_INDEX_BACK_SELECT] = NullButton(); |
| 156 mapped->buttons[BUTTON_INDEX_START] = input.buttons[11]; | 152 mapped->buttons[BUTTON_INDEX_START] = input.buttons[11]; |
| 157 mapped->buttons[BUTTON_INDEX_LEFT_THUMBSTICK] = input.buttons[13]; | 153 mapped->buttons[BUTTON_INDEX_LEFT_THUMBSTICK] = input.buttons[13]; |
| 158 mapped->buttons[BUTTON_INDEX_RIGHT_THUMBSTICK] = input.buttons[14]; | 154 mapped->buttons[BUTTON_INDEX_RIGHT_THUMBSTICK] = input.buttons[14]; |
| 159 mapped->buttons[BUTTON_INDEX_META] = input.buttons[8]; | 155 mapped->buttons[BUTTON_INDEX_META] = input.buttons[8]; |
| 160 mapped->axes[AXIS_INDEX_RIGHT_STICK_Y] = input.axes[5]; | 156 mapped->axes[AXIS_INDEX_RIGHT_STICK_Y] = input.axes[5]; |
| 161 DpadFromAxis(mapped, input.axes[9]); | 157 DpadFromAxis(mapped, input.axes[9]); |
| 162 | 158 |
| 163 mapped->buttons_length = BUTTON_INDEX_COUNT; | 159 mapped->buttons_length = BUTTON_INDEX_COUNT; |
| 164 mapped->axes_length = AXIS_INDEX_COUNT; | 160 mapped->axes_length = AXIS_INDEX_COUNT; |
| 165 } | 161 } |
| 166 | 162 |
| 167 void MapperOUYA(const blink::WebGamepad& input, blink::WebGamepad* mapped) { | 163 void MapperOUYA(const Gamepad& input, Gamepad* mapped) { |
| 168 *mapped = input; | 164 *mapped = input; |
| 169 mapped->buttons[BUTTON_INDEX_PRIMARY] = input.buttons[0]; | 165 mapped->buttons[BUTTON_INDEX_PRIMARY] = input.buttons[0]; |
| 170 mapped->buttons[BUTTON_INDEX_SECONDARY] = input.buttons[3]; | 166 mapped->buttons[BUTTON_INDEX_SECONDARY] = input.buttons[3]; |
| 171 mapped->buttons[BUTTON_INDEX_TERTIARY] = input.buttons[1]; | 167 mapped->buttons[BUTTON_INDEX_TERTIARY] = input.buttons[1]; |
| 172 mapped->buttons[BUTTON_INDEX_QUATERNARY] = input.buttons[2]; | 168 mapped->buttons[BUTTON_INDEX_QUATERNARY] = input.buttons[2]; |
| 173 mapped->buttons[BUTTON_INDEX_LEFT_SHOULDER] = input.buttons[4]; | 169 mapped->buttons[BUTTON_INDEX_LEFT_SHOULDER] = input.buttons[4]; |
| 174 mapped->buttons[BUTTON_INDEX_RIGHT_SHOULDER] = input.buttons[5]; | 170 mapped->buttons[BUTTON_INDEX_RIGHT_SHOULDER] = input.buttons[5]; |
| 175 mapped->buttons[BUTTON_INDEX_LEFT_TRIGGER] = AxisToButton(input.axes[2]); | 171 mapped->buttons[BUTTON_INDEX_LEFT_TRIGGER] = AxisToButton(input.axes[2]); |
| 176 mapped->buttons[BUTTON_INDEX_RIGHT_TRIGGER] = AxisToButton(input.axes[5]); | 172 mapped->buttons[BUTTON_INDEX_RIGHT_TRIGGER] = AxisToButton(input.axes[5]); |
| 177 mapped->buttons[BUTTON_INDEX_BACK_SELECT] = NullButton(); | 173 mapped->buttons[BUTTON_INDEX_BACK_SELECT] = NullButton(); |
| 178 mapped->buttons[BUTTON_INDEX_START] = NullButton(); | 174 mapped->buttons[BUTTON_INDEX_START] = NullButton(); |
| 179 mapped->buttons[BUTTON_INDEX_LEFT_THUMBSTICK] = input.buttons[6]; | 175 mapped->buttons[BUTTON_INDEX_LEFT_THUMBSTICK] = input.buttons[6]; |
| 180 mapped->buttons[BUTTON_INDEX_RIGHT_THUMBSTICK] = input.buttons[7]; | 176 mapped->buttons[BUTTON_INDEX_RIGHT_THUMBSTICK] = input.buttons[7]; |
| 181 mapped->buttons[BUTTON_INDEX_DPAD_UP] = input.buttons[8]; | 177 mapped->buttons[BUTTON_INDEX_DPAD_UP] = input.buttons[8]; |
| 182 mapped->buttons[BUTTON_INDEX_DPAD_DOWN] = input.buttons[9]; | 178 mapped->buttons[BUTTON_INDEX_DPAD_DOWN] = input.buttons[9]; |
| 183 mapped->buttons[BUTTON_INDEX_DPAD_LEFT] = input.buttons[10]; | 179 mapped->buttons[BUTTON_INDEX_DPAD_LEFT] = input.buttons[10]; |
| 184 mapped->buttons[BUTTON_INDEX_DPAD_RIGHT] = input.buttons[11]; | 180 mapped->buttons[BUTTON_INDEX_DPAD_RIGHT] = input.buttons[11]; |
| 185 mapped->buttons[BUTTON_INDEX_META] = input.buttons[15]; | 181 mapped->buttons[BUTTON_INDEX_META] = input.buttons[15]; |
| 186 mapped->axes[AXIS_INDEX_RIGHT_STICK_X] = input.axes[3]; | 182 mapped->axes[AXIS_INDEX_RIGHT_STICK_X] = input.axes[3]; |
| 187 mapped->axes[AXIS_INDEX_RIGHT_STICK_Y] = input.axes[4]; | 183 mapped->axes[AXIS_INDEX_RIGHT_STICK_Y] = input.axes[4]; |
| 188 | 184 |
| 189 mapped->buttons_length = BUTTON_INDEX_COUNT; | 185 mapped->buttons_length = BUTTON_INDEX_COUNT; |
| 190 mapped->axes_length = AXIS_INDEX_COUNT; | 186 mapped->axes_length = AXIS_INDEX_COUNT; |
| 191 } | 187 } |
| 192 | 188 |
| 193 void MapperRazerServal(const blink::WebGamepad& input, | 189 void MapperRazerServal(const Gamepad& input, Gamepad* mapped) { |
| 194 blink::WebGamepad* mapped) { | |
| 195 *mapped = input; | 190 *mapped = input; |
| 196 mapped->buttons[BUTTON_INDEX_PRIMARY] = input.buttons[0]; | 191 mapped->buttons[BUTTON_INDEX_PRIMARY] = input.buttons[0]; |
| 197 mapped->buttons[BUTTON_INDEX_SECONDARY] = input.buttons[1]; | 192 mapped->buttons[BUTTON_INDEX_SECONDARY] = input.buttons[1]; |
| 198 mapped->buttons[BUTTON_INDEX_TERTIARY] = input.buttons[3]; | 193 mapped->buttons[BUTTON_INDEX_TERTIARY] = input.buttons[3]; |
| 199 mapped->buttons[BUTTON_INDEX_QUATERNARY] = input.buttons[4]; | 194 mapped->buttons[BUTTON_INDEX_QUATERNARY] = input.buttons[4]; |
| 200 mapped->buttons[BUTTON_INDEX_LEFT_SHOULDER] = input.buttons[6]; | 195 mapped->buttons[BUTTON_INDEX_LEFT_SHOULDER] = input.buttons[6]; |
| 201 mapped->buttons[BUTTON_INDEX_RIGHT_SHOULDER] = input.buttons[7]; | 196 mapped->buttons[BUTTON_INDEX_RIGHT_SHOULDER] = input.buttons[7]; |
| 202 mapped->buttons[BUTTON_INDEX_LEFT_TRIGGER] = AxisToButton(input.axes[4]); | 197 mapped->buttons[BUTTON_INDEX_LEFT_TRIGGER] = AxisToButton(input.axes[4]); |
| 203 mapped->buttons[BUTTON_INDEX_RIGHT_TRIGGER] = AxisToButton(input.axes[3]); | 198 mapped->buttons[BUTTON_INDEX_RIGHT_TRIGGER] = AxisToButton(input.axes[3]); |
| 204 mapped->buttons[BUTTON_INDEX_BACK_SELECT] = input.buttons[10]; | 199 mapped->buttons[BUTTON_INDEX_BACK_SELECT] = input.buttons[10]; |
| 205 mapped->buttons[BUTTON_INDEX_START] = input.buttons[11]; | 200 mapped->buttons[BUTTON_INDEX_START] = input.buttons[11]; |
| 206 mapped->buttons[BUTTON_INDEX_LEFT_THUMBSTICK] = input.buttons[13]; | 201 mapped->buttons[BUTTON_INDEX_LEFT_THUMBSTICK] = input.buttons[13]; |
| 207 mapped->buttons[BUTTON_INDEX_RIGHT_THUMBSTICK] = input.buttons[14]; | 202 mapped->buttons[BUTTON_INDEX_RIGHT_THUMBSTICK] = input.buttons[14]; |
| 208 mapped->axes[AXIS_INDEX_RIGHT_STICK_Y] = input.axes[5]; | 203 mapped->axes[AXIS_INDEX_RIGHT_STICK_Y] = input.axes[5]; |
| 209 DpadFromAxis(mapped, input.axes[9]); | 204 DpadFromAxis(mapped, input.axes[9]); |
| 210 | 205 |
| 211 mapped->buttons_length = BUTTON_INDEX_COUNT - 1; /* no meta */ | 206 mapped->buttons_length = BUTTON_INDEX_COUNT - 1; /* no meta */ |
| 212 mapped->axes_length = AXIS_INDEX_COUNT; | 207 mapped->axes_length = AXIS_INDEX_COUNT; |
| 213 } | 208 } |
| 214 | 209 |
| 215 void MapperMogaPro(const blink::WebGamepad& input, blink::WebGamepad* mapped) { | 210 void MapperMogaPro(const Gamepad& input, Gamepad* mapped) { |
| 216 *mapped = input; | 211 *mapped = input; |
| 217 mapped->buttons[BUTTON_INDEX_PRIMARY] = input.buttons[0]; | 212 mapped->buttons[BUTTON_INDEX_PRIMARY] = input.buttons[0]; |
| 218 mapped->buttons[BUTTON_INDEX_SECONDARY] = input.buttons[1]; | 213 mapped->buttons[BUTTON_INDEX_SECONDARY] = input.buttons[1]; |
| 219 mapped->buttons[BUTTON_INDEX_TERTIARY] = input.buttons[3]; | 214 mapped->buttons[BUTTON_INDEX_TERTIARY] = input.buttons[3]; |
| 220 mapped->buttons[BUTTON_INDEX_QUATERNARY] = input.buttons[4]; | 215 mapped->buttons[BUTTON_INDEX_QUATERNARY] = input.buttons[4]; |
| 221 mapped->buttons[BUTTON_INDEX_LEFT_SHOULDER] = input.buttons[6]; | 216 mapped->buttons[BUTTON_INDEX_LEFT_SHOULDER] = input.buttons[6]; |
| 222 mapped->buttons[BUTTON_INDEX_RIGHT_SHOULDER] = input.buttons[7]; | 217 mapped->buttons[BUTTON_INDEX_RIGHT_SHOULDER] = input.buttons[7]; |
| 223 mapped->buttons[BUTTON_INDEX_LEFT_TRIGGER] = AxisToButton(input.axes[4]); | 218 mapped->buttons[BUTTON_INDEX_LEFT_TRIGGER] = AxisToButton(input.axes[4]); |
| 224 mapped->buttons[BUTTON_INDEX_RIGHT_TRIGGER] = AxisToButton(input.axes[3]); | 219 mapped->buttons[BUTTON_INDEX_RIGHT_TRIGGER] = AxisToButton(input.axes[3]); |
| 225 mapped->buttons[BUTTON_INDEX_BACK_SELECT] = NullButton(); | 220 mapped->buttons[BUTTON_INDEX_BACK_SELECT] = NullButton(); |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 261 const base::StringPiece& product_id) { | 256 const base::StringPiece& product_id) { |
| 262 for (size_t i = 0; i < arraysize(AvailableMappings); ++i) { | 257 for (size_t i = 0; i < arraysize(AvailableMappings); ++i) { |
| 263 MappingData& item = AvailableMappings[i]; | 258 MappingData& item = AvailableMappings[i]; |
| 264 if (vendor_id == item.vendor_id && product_id == item.product_id) | 259 if (vendor_id == item.vendor_id && product_id == item.product_id) |
| 265 return item.function; | 260 return item.function; |
| 266 } | 261 } |
| 267 return NULL; | 262 return NULL; |
| 268 } | 263 } |
| 269 | 264 |
| 270 } // namespace device | 265 } // namespace device |
| OLD | NEW |