| OLD | NEW |
| 1 // Copyright (c) 2015 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2015 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_data_fetcher.h" | 5 #include "device/gamepad/gamepad_data_fetcher.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 #include <string.h> | 8 #include <string.h> |
| 9 | 9 |
| 10 #include <cmath> |
| 11 |
| 10 #include "base/logging.h" | 12 #include "base/logging.h" |
| 11 #include "build/build_config.h" | 13 #include "build/build_config.h" |
| 12 | 14 |
| 13 namespace { | 15 namespace { |
| 14 | 16 |
| 15 #if !defined(OS_ANDROID) | 17 #if !defined(OS_ANDROID) |
| 16 const float kMinAxisResetValue = 0.1f; | 18 const float kMinAxisResetValue = 0.1f; |
| 17 #endif | 19 #endif |
| 18 | 20 |
| 19 } // namespace | 21 } // namespace |
| 20 | 22 |
| 21 namespace content { | 23 namespace device { |
| 22 | 24 |
| 23 using blink::WebGamepad; | 25 using blink::WebGamepad; |
| 24 using blink::WebGamepads; | 26 using blink::WebGamepads; |
| 25 | 27 |
| 26 #if !defined(OS_ANDROID) | 28 #if !defined(OS_ANDROID) |
| 27 void GamepadDataFetcher::MapAndSanitizeGamepadData( | 29 void GamepadDataFetcher::MapAndSanitizeGamepadData(PadState* pad_state, |
| 28 PadState* pad_state, WebGamepad* pad) { | 30 WebGamepad* pad) { |
| 29 DCHECK(pad_state); | 31 DCHECK(pad_state); |
| 30 DCHECK(pad); | 32 DCHECK(pad); |
| 31 | 33 |
| 32 if (!pad_state->data.connected) { | 34 if (!pad_state->data.connected) { |
| 33 memset(pad, 0, sizeof(WebGamepad)); | 35 memset(pad, 0, sizeof(WebGamepad)); |
| 34 return; | 36 return; |
| 35 } | 37 } |
| 36 | 38 |
| 37 // Copy the current state to the output buffer, using the mapping | 39 // Copy the current state to the output buffer, using the mapping |
| 38 // function, if there is one available. | 40 // function, if there is one available. |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 75 } else { | 77 } else { |
| 76 pad->buttons[button].pressed = false; | 78 pad->buttons[button].pressed = false; |
| 77 pad->buttons[button].value = 0.0f; | 79 pad->buttons[button].value = 0.0f; |
| 78 } | 80 } |
| 79 } | 81 } |
| 80 } | 82 } |
| 81 } | 83 } |
| 82 } | 84 } |
| 83 #endif | 85 #endif |
| 84 | 86 |
| 85 } // namespace content | 87 } // namespace device |
| OLD | NEW |