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

Side by Side Diff: content/common/gamepad_user_gesture.cc

Issue 2081583002: Migrating majority of gamepad from content/browser/ to device/ (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Final tweaks Created 4 years, 5 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 unified diff | Download patch
« no previous file with comments | « content/common/gamepad_user_gesture.h ('k') | content/content_browser.gypi » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(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 <math.h>
8
9 #include <algorithm>
10
11 #include "third_party/WebKit/public/platform/WebGamepads.h"
12
13 namespace {
14 // A big enough deadzone to detect accidental presses.
15 const float kAxisMoveAmountThreshold = 0.5;
16 }
17
18 namespace content {
19
20 bool GamepadsHaveUserGesture(const blink::WebGamepads& gamepads) {
21 for (unsigned int i = 0; i < blink::WebGamepads::itemsLengthCap; i++) {
22 const blink::WebGamepad& pad = gamepads.items[i];
23
24 // If the device is physically connected, then check the buttons and axes
25 // to see if there is currently an intentional user action.
26 if (pad.connected) {
27 for (unsigned int button_index = 0; button_index < pad.buttonsLength;
28 button_index++) {
29 if (pad.buttons[button_index].pressed)
30 return true;
31 }
32
33 for (unsigned int axes_index = 0; axes_index < pad.axesLength;
34 axes_index++) {
35 if (fabs(pad.axes[axes_index]) > kAxisMoveAmountThreshold)
36 return true;
37 }
38 }
39 }
40 return false;
41 }
42
43 } // namespace content
OLDNEW
« 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