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 #ifndef CONTENT_BROWSER_GAMEPAD_GAMEPAD_STANDARD_MAPPINGS_H_ | 5 #ifndef DEVICE_GAMEPAD_GAMEPAD_STANDARD_MAPPINGS_H_ |
6 #define CONTENT_BROWSER_GAMEPAD_GAMEPAD_STANDARD_MAPPINGS_H_ | 6 #define DEVICE_GAMEPAD_GAMEPAD_STANDARD_MAPPINGS_H_ |
7 | 7 |
8 #include "base/strings/string_piece.h" | 8 #include "base/strings/string_piece.h" |
9 #include "content/common/gamepad_hardware_buffer.h" | 9 #include "third_party/WebKit/public/platform/WebGamepad.h" |
10 | 10 namespace device { |
scottmg
2016/06/23 17:27:19
\n before
| |
11 namespace content { | |
12 | 11 |
13 typedef void (*GamepadStandardMappingFunction)( | 12 typedef void (*GamepadStandardMappingFunction)( |
14 const blink::WebGamepad& original, | 13 const blink::WebGamepad& original, |
15 blink::WebGamepad* mapped); | 14 blink::WebGamepad* mapped); |
16 | 15 |
17 GamepadStandardMappingFunction GetGamepadStandardMappingFunction( | 16 GamepadStandardMappingFunction GetGamepadStandardMappingFunction( |
18 const base::StringPiece& vendor_id, | 17 const base::StringPiece& vendor_id, |
19 const base::StringPiece& product_id); | 18 const base::StringPiece& product_id); |
20 | 19 |
21 // This defines our canonical mapping order for gamepad-like devices. If these | 20 // This defines our canonical mapping order for gamepad-like devices. If these |
22 // items cannot all be satisfied, it is a case-by-case judgement as to whether | 21 // items cannot all be satisfied, it is a case-by-case judgement as to whether |
23 // it is better to leave the device unmapped, or to partially map it. In | 22 // it is better to leave the device unmapped, or to partially map it. In |
24 // general, err towards leaving it *unmapped* so that content can handle | 23 // general, err towards leaving it *unmapped* so that content can handle |
25 // appropriately. | 24 // appropriately. |
26 | 25 |
27 // A Java counterpart will be generated for this enum. | 26 // A Java counterpart will be generated for this enum. |
28 // GENERATED_JAVA_ENUM_PACKAGE: org.chromium.content.browser.input | 27 // GENERATED_JAVA_ENUM_PACKAGE: org.chromium.device.gamepad |
29 // GENERATED_JAVA_PREFIX_TO_STRIP: BUTTON_INDEX_ | 28 // GENERATED_JAVA_PREFIX_TO_STRIP: BUTTON_INDEX_ |
30 enum CanonicalButtonIndex { | 29 enum CanonicalButtonIndex { |
31 BUTTON_INDEX_PRIMARY, | 30 BUTTON_INDEX_PRIMARY, |
32 BUTTON_INDEX_SECONDARY, | 31 BUTTON_INDEX_SECONDARY, |
33 BUTTON_INDEX_TERTIARY, | 32 BUTTON_INDEX_TERTIARY, |
34 BUTTON_INDEX_QUATERNARY, | 33 BUTTON_INDEX_QUATERNARY, |
35 BUTTON_INDEX_LEFT_SHOULDER, | 34 BUTTON_INDEX_LEFT_SHOULDER, |
36 BUTTON_INDEX_RIGHT_SHOULDER, | 35 BUTTON_INDEX_RIGHT_SHOULDER, |
37 BUTTON_INDEX_LEFT_TRIGGER, | 36 BUTTON_INDEX_LEFT_TRIGGER, |
38 BUTTON_INDEX_RIGHT_TRIGGER, | 37 BUTTON_INDEX_RIGHT_TRIGGER, |
39 BUTTON_INDEX_BACK_SELECT, | 38 BUTTON_INDEX_BACK_SELECT, |
40 BUTTON_INDEX_START, | 39 BUTTON_INDEX_START, |
41 BUTTON_INDEX_LEFT_THUMBSTICK, | 40 BUTTON_INDEX_LEFT_THUMBSTICK, |
42 BUTTON_INDEX_RIGHT_THUMBSTICK, | 41 BUTTON_INDEX_RIGHT_THUMBSTICK, |
43 BUTTON_INDEX_DPAD_UP, | 42 BUTTON_INDEX_DPAD_UP, |
44 BUTTON_INDEX_DPAD_DOWN, | 43 BUTTON_INDEX_DPAD_DOWN, |
45 BUTTON_INDEX_DPAD_LEFT, | 44 BUTTON_INDEX_DPAD_LEFT, |
46 BUTTON_INDEX_DPAD_RIGHT, | 45 BUTTON_INDEX_DPAD_RIGHT, |
47 BUTTON_INDEX_META, | 46 BUTTON_INDEX_META, |
48 BUTTON_INDEX_COUNT | 47 BUTTON_INDEX_COUNT |
49 }; | 48 }; |
50 | 49 |
51 // A Java counterpart will be generated for this enum. | 50 // A Java counterpart will be generated for this enum. |
52 // GENERATED_JAVA_ENUM_PACKAGE: org.chromium.content.browser.input | 51 // GENERATED_JAVA_ENUM_PACKAGE: org.chromium.device.gamepad |
53 // GENERATED_JAVA_PREFIX_TO_STRIP: AXIS_INDEX_ | 52 // GENERATED_JAVA_PREFIX_TO_STRIP: AXIS_INDEX_ |
54 enum CanonicalAxisIndex { | 53 enum CanonicalAxisIndex { |
55 AXIS_INDEX_LEFT_STICK_X, | 54 AXIS_INDEX_LEFT_STICK_X, |
56 AXIS_INDEX_LEFT_STICK_Y, | 55 AXIS_INDEX_LEFT_STICK_Y, |
57 AXIS_INDEX_RIGHT_STICK_X, | 56 AXIS_INDEX_RIGHT_STICK_X, |
58 AXIS_INDEX_RIGHT_STICK_Y, | 57 AXIS_INDEX_RIGHT_STICK_Y, |
59 AXIS_INDEX_COUNT | 58 AXIS_INDEX_COUNT |
60 }; | 59 }; |
61 | 60 |
62 // Matches XInput's trigger deadzone | 61 // Matches XInput's trigger deadzone |
63 const float kDefaultButtonPressedThreshold = 30.f/255.f; | 62 const float kDefaultButtonPressedThreshold = 30.f / 255.f; |
64 | 63 |
65 // Common mapping functions | 64 // Common mapping functions |
66 blink::WebGamepadButton AxisToButton(float input); | 65 blink::WebGamepadButton AxisToButton(float input); |
67 blink::WebGamepadButton AxisNegativeAsButton(float input); | 66 blink::WebGamepadButton AxisNegativeAsButton(float input); |
68 blink::WebGamepadButton AxisPositiveAsButton(float input); | 67 blink::WebGamepadButton AxisPositiveAsButton(float input); |
69 blink::WebGamepadButton ButtonFromButtonAndAxis( | 68 blink::WebGamepadButton ButtonFromButtonAndAxis(blink::WebGamepadButton button, |
70 blink::WebGamepadButton button, float axis); | 69 float axis); |
71 blink::WebGamepadButton NullButton(); | 70 blink::WebGamepadButton NullButton(); |
72 void DpadFromAxis(blink::WebGamepad* mapped, float dir); | 71 void DpadFromAxis(blink::WebGamepad* mapped, float dir); |
73 | 72 |
74 } // namespace content | 73 } // namespace device |
75 | 74 |
76 #endif // CONTENT_BROWSER_GAMEPAD_GAMEPAD_STANDARD_MAPPINGS_H_ | 75 #endif // DEVICE_GAMEPAD_GAMEPAD_STANDARD_MAPPINGS_H_ |
OLD | NEW |