Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1711)

Unified Diff: content/common/gamepad_user_gesture.cc

Issue 10912062: Implement the gamepad API in the IPC proxy (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « content/common/gamepad_user_gesture.h ('k') | content/content_browser.gypi » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/common/gamepad_user_gesture.cc
diff --git a/content/common/gamepad_user_gesture.cc b/content/common/gamepad_user_gesture.cc
new file mode 100644
index 0000000000000000000000000000000000000000..8fa42b5dbb3d9dcf0daef64e80df71367e749b6b
--- /dev/null
+++ b/content/common/gamepad_user_gesture.cc
@@ -0,0 +1,33 @@
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "content/common/gamepad_user_gesture.h"
+
+#include <algorithm>
+
+#include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebGamepads.h"
+
+namespace content {
+
+bool GamepadsHaveUserGesture(const WebKit::WebGamepads& gamepads) {
+ for (unsigned i = 0; i < WebKit::WebGamepads::itemsLengthCap; i++) {
+ const WebKit::WebGamepad& pad = gamepads.items[i];
+
+ // If the device is physically connected, then check the primary 4 buttons
+ // to see if there is currently an intentional user action.
+ if (pad.connected) {
+ const unsigned kPrimaryInteractionButtons = 4;
+ unsigned buttons_to_check = std::min(pad.buttonsLength,
+ kPrimaryInteractionButtons);
+ for (unsigned button_index = 0; button_index < buttons_to_check;
+ button_index++) {
+ if (pad.buttons[button_index] > 0.5f)
+ return true;
+ }
+ }
+ }
+ return false;
+}
+
+} // namespace content
« no previous file with comments | « content/common/gamepad_user_gesture.h ('k') | content/content_browser.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698