OLD | NEW |
(Empty) | |
| 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. |
| 4 |
| 5 #include "content/common/gamepad_user_gesture.h" |
| 6 |
| 7 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebGamepads.
h" |
| 8 |
| 9 namespace content { |
| 10 |
| 11 bool GamepadsHaveUserGesture(const WebKit::WebGamepads& gamepads) { |
| 12 bool has_user_gesture = false; |
| 13 for (unsigned i = 0; i < WebKit::WebGamepads::itemsLengthCap; i++) { |
| 14 const WebKit::WebGamepad& pad = gamepads.items[i]; |
| 15 |
| 16 // If the device is physically connected, then check the primary 4 buttons |
| 17 // to see if there is currently an intentional user action. |
| 18 if (pad.connected) { |
| 19 const int kPrimaryInteractionButtons = 4; |
| 20 for (int button_index = 0; button_index < kPrimaryInteractionButtons; |
| 21 button_index++) { |
| 22 if (pad.buttons[button_index] > 0.5f) |
| 23 return true; |
| 24 } |
| 25 } |
| 26 } |
| 27 return false; |
| 28 } |
| 29 |
| 30 } // namespace content |
OLD | NEW |