| 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 DEVICE_GAMEPAD_GAMEPAD_STANDARD_MAPPINGS_H_ | 5 #ifndef DEVICE_GAMEPAD_GAMEPAD_STANDARD_MAPPINGS_H_ |
| 6 #define DEVICE_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 "third_party/WebKit/public/platform/WebGamepad.h" | 9 #include "device/gamepad/public/cpp/gamepad.h" |
| 10 | 10 |
| 11 namespace device { | 11 namespace device { |
| 12 | 12 |
| 13 typedef void (*GamepadStandardMappingFunction)( | 13 typedef void (*GamepadStandardMappingFunction)(const Gamepad& original, |
| 14 const blink::WebGamepad& original, | 14 Gamepad* mapped); |
| 15 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. |
| (...skipping 30 matching lines...) Expand all Loading... |
| 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 GamepadButton AxisToButton(float input); |
| 67 blink::WebGamepadButton AxisNegativeAsButton(float input); | 66 GamepadButton AxisNegativeAsButton(float input); |
| 68 blink::WebGamepadButton AxisPositiveAsButton(float input); | 67 GamepadButton AxisPositiveAsButton(float input); |
| 69 blink::WebGamepadButton ButtonFromButtonAndAxis(blink::WebGamepadButton button, | 68 GamepadButton ButtonFromButtonAndAxis(GamepadButton button, float axis); |
| 70 float axis); | 69 GamepadButton NullButton(); |
| 71 blink::WebGamepadButton NullButton(); | 70 void DpadFromAxis(Gamepad* mapped, float dir); |
| 72 void DpadFromAxis(blink::WebGamepad* mapped, float dir); | |
| 73 | 71 |
| 74 } // namespace device | 72 } // namespace device |
| 75 | 73 |
| 76 #endif // DEVICE_GAMEPAD_GAMEPAD_STANDARD_MAPPINGS_H_ | 74 #endif // DEVICE_GAMEPAD_GAMEPAD_STANDARD_MAPPINGS_H_ |
| OLD | NEW |