OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 blink::WebGamepadButton AxisToButton(float input) { | 9 blink::WebGamepadButton AxisToButton(float input) { |
10 float value = (input + 1.f) / 2.f; | 10 float value = (input + 1.f) / 2.f; |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
44 // increases clockwise to 1, which is up + left. It's set to a large (> 1.f) | 44 // increases clockwise to 1, which is up + left. It's set to a large (> 1.f) |
45 // number when nothing is depressed, except on start up, sometimes it's 0.0 | 45 // number when nothing is depressed, except on start up, sometimes it's 0.0 |
46 // for no data, rather than the large number. | 46 // for no data, rather than the large number. |
47 if (dir != 0.0f) { | 47 if (dir != 0.0f) { |
48 up = (dir >= -1.f && dir < -0.7f) || (dir >= .95f && dir <= 1.f); | 48 up = (dir >= -1.f && dir < -0.7f) || (dir >= .95f && dir <= 1.f); |
49 right = dir >= -.75f && dir < -.1f; | 49 right = dir >= -.75f && dir < -.1f; |
50 down = dir >= -.2f && dir < .45f; | 50 down = dir >= -.2f && dir < .45f; |
51 left = dir >= .4f && dir <= 1.f; | 51 left = dir >= .4f && dir <= 1.f; |
52 } | 52 } |
53 | 53 |
54 mapped->buttons[kButtonDpadUp].pressed = up; | 54 mapped->buttons[BUTTON_INDEX_DPAD_UP].pressed = up; |
55 mapped->buttons[kButtonDpadUp].value = up ? 1.f : 0.f; | 55 mapped->buttons[BUTTON_INDEX_DPAD_UP].value = up ? 1.f : 0.f; |
56 mapped->buttons[kButtonDpadRight].pressed = right; | 56 mapped->buttons[BUTTON_INDEX_DPAD_RIGHT].pressed = right; |
57 mapped->buttons[kButtonDpadRight].value = right ? 1.f : 0.f; | 57 mapped->buttons[BUTTON_INDEX_DPAD_RIGHT].value = right ? 1.f : 0.f; |
58 mapped->buttons[kButtonDpadDown].pressed = down; | 58 mapped->buttons[BUTTON_INDEX_DPAD_DOWN].pressed = down; |
59 mapped->buttons[kButtonDpadDown].value = down ? 1.f : 0.f; | 59 mapped->buttons[BUTTON_INDEX_DPAD_DOWN].value = down ? 1.f : 0.f; |
60 mapped->buttons[kButtonDpadLeft].pressed = left; | 60 mapped->buttons[BUTTON_INDEX_DPAD_LEFT].pressed = left; |
61 mapped->buttons[kButtonDpadLeft].value = left ? 1.f : 0.f; | 61 mapped->buttons[BUTTON_INDEX_DPAD_LEFT].value = left ? 1.f : 0.f; |
62 } | 62 } |
63 | 63 |
64 } // namespace content | 64 } // namespace content |
OLD | NEW |