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
3 // found in the LICENSE file.
5 #ifndef CONTENT_BROWSER_GAMEPAD_GAMEPAD_STANDARD_MAPPINGS_H_
6 #define CONTENT_BROWSER_GAMEPAD_GAMEPAD_STANDARD_MAPPINGS_H_
8 #include "base/strings/string_piece.h"
9 #include "content/common/gamepad_hardware_buffer.h"
13 typedef void (*GamepadStandardMappingFunction
)(
14 const blink::WebGamepad
& original
,
15 blink::WebGamepad
* mapped
);
17 GamepadStandardMappingFunction
GetGamepadStandardMappingFunction(
18 const base::StringPiece
& vendor_id
,
19 const base::StringPiece
& product_id
);
21 // 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
23 // 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
27 enum CanonicalButtonIndex
{
38 kButtonLeftThumbstick
,
39 kButtonRightThumbstick
,
48 enum CanonicalAxisIndex
{
56 // Matches XInput's trigger deadzone
57 const float kDefaultButtonPressedThreshold
= 30.f
/255.f
;
59 // Common mapping functions
60 blink::WebGamepadButton
AxisToButton(float input
);
61 blink::WebGamepadButton
AxisNegativeAsButton(float input
);
62 blink::WebGamepadButton
AxisPositiveAsButton(float input
);
63 blink::WebGamepadButton
ButtonFromButtonAndAxis(
64 blink::WebGamepadButton button
, float axis
);
65 void DpadFromAxis(blink::WebGamepad
* mapped
, float dir
);
67 } // namespace content
69 #endif // CONTENT_BROWSER_GAMEPAD_GAMEPAD_STANDARD_MAPPINGS_H_