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

Side by Side Diff: device/gamepad/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 | « device/gamepad/gamepad_user_gesture.h ('k') | device/gamepad/raw_input_data_fetcher_win.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 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 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/common/gamepad_user_gesture.h" 5 #include "device/gamepad/gamepad_user_gesture.h"
6 6
7 #include <math.h> 7 #include <math.h>
8 8
9 #include <algorithm> 9 #include <algorithm>
10 10
11 #include "third_party/WebKit/public/platform/WebGamepads.h" 11 #include "third_party/WebKit/public/platform/WebGamepads.h"
12 12
13 namespace { 13 namespace {
14 // A big enough deadzone to detect accidental presses. 14 // A big enough deadzone to detect accidental presses.
15 const float kAxisMoveAmountThreshold = 0.5; 15 const float kAxisMoveAmountThreshold = 0.5;
16 } 16 }
17 17
18 namespace content { 18 namespace device {
19 19
20 bool GamepadsHaveUserGesture(const blink::WebGamepads& gamepads) { 20 bool GamepadsHaveUserGesture(const blink::WebGamepads& gamepads) {
21 for (unsigned int i = 0; i < blink::WebGamepads::itemsLengthCap; i++) { 21 for (unsigned int i = 0; i < blink::WebGamepads::itemsLengthCap; i++) {
22 const blink::WebGamepad& pad = gamepads.items[i]; 22 const blink::WebGamepad& pad = gamepads.items[i];
23 23
24 // If the device is physically connected, then check the buttons and axes 24 // If the device is physically connected, then check the buttons and axes
25 // to see if there is currently an intentional user action. 25 // to see if there is currently an intentional user action.
26 if (pad.connected) { 26 if (pad.connected) {
27 for (unsigned int button_index = 0; button_index < pad.buttonsLength; 27 for (unsigned int button_index = 0; button_index < pad.buttonsLength;
28 button_index++) { 28 button_index++) {
29 if (pad.buttons[button_index].pressed) 29 if (pad.buttons[button_index].pressed)
30 return true; 30 return true;
31 } 31 }
32 32
33 for (unsigned int axes_index = 0; axes_index < pad.axesLength; 33 for (unsigned int axes_index = 0; axes_index < pad.axesLength;
34 axes_index++) { 34 axes_index++) {
35 if (fabs(pad.axes[axes_index]) > kAxisMoveAmountThreshold) 35 if (fabs(pad.axes[axes_index]) > kAxisMoveAmountThreshold)
36 return true; 36 return true;
37 } 37 }
38 } 38 }
39 } 39 }
40 return false; 40 return false;
41 } 41 }
42 42
43 } // namespace content 43 } // namespace device
OLDNEW
« no previous file with comments | « device/gamepad/gamepad_user_gesture.h ('k') | device/gamepad/raw_input_data_fetcher_win.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698