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

Side by Side Diff: third_party/WebKit/Source/modules/gamepad/GamepadDispatcher.cpp

Issue 2808093006: [Device Service] Move Gamepad Blink headers to be part of the Gamepad client library (Closed)
Patch Set: clean up code Created 3 years, 8 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
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "modules/gamepad/GamepadDispatcher.h" 5 #include "modules/gamepad/GamepadDispatcher.h"
6 6
7 #include "modules/gamepad/NavigatorGamepad.h" 7 #include "modules/gamepad/NavigatorGamepad.h"
8 #include "public/platform/Platform.h" 8 #include "public/platform/Platform.h"
9 9
10 namespace blink { 10 namespace blink {
11 11
12 GamepadDispatcher& GamepadDispatcher::Instance() { 12 GamepadDispatcher& GamepadDispatcher::Instance() {
13 DEFINE_STATIC_LOCAL(GamepadDispatcher, gamepad_dispatcher, 13 DEFINE_STATIC_LOCAL(GamepadDispatcher, gamepad_dispatcher,
14 (new GamepadDispatcher)); 14 (new GamepadDispatcher));
15 return gamepad_dispatcher; 15 return gamepad_dispatcher;
16 } 16 }
17 17
18 void GamepadDispatcher::SampleGamepads(WebGamepads& gamepads) { 18 void GamepadDispatcher::SampleGamepads(device::Gamepads& gamepads) {
19 Platform::Current()->SampleGamepads(gamepads); 19 Platform::Current()->SampleGamepads(gamepads);
20 } 20 }
21 21
22 GamepadDispatcher::GamepadDispatcher() {} 22 GamepadDispatcher::GamepadDispatcher() {}
23 23
24 GamepadDispatcher::~GamepadDispatcher() {} 24 GamepadDispatcher::~GamepadDispatcher() {}
25 25
26 DEFINE_TRACE(GamepadDispatcher) { 26 DEFINE_TRACE(GamepadDispatcher) {
27 PlatformEventDispatcher::Trace(visitor); 27 PlatformEventDispatcher::Trace(visitor);
28 } 28 }
29 29
30 void GamepadDispatcher::DidConnectGamepad(unsigned index, 30 void GamepadDispatcher::DidConnectGamepad(unsigned index,
31 const WebGamepad& gamepad) { 31 const device::Gamepad& gamepad) {
32 DispatchDidConnectOrDisconnectGamepad(index, gamepad, true); 32 DispatchDidConnectOrDisconnectGamepad(index, gamepad, true);
33 } 33 }
34 34
35 void GamepadDispatcher::DidDisconnectGamepad(unsigned index, 35 void GamepadDispatcher::DidDisconnectGamepad(unsigned index,
36 const WebGamepad& gamepad) { 36 const device::Gamepad& gamepad) {
37 DispatchDidConnectOrDisconnectGamepad(index, gamepad, false); 37 DispatchDidConnectOrDisconnectGamepad(index, gamepad, false);
38 } 38 }
39 39
40 void GamepadDispatcher::DispatchDidConnectOrDisconnectGamepad( 40 void GamepadDispatcher::DispatchDidConnectOrDisconnectGamepad(
41 unsigned index, 41 unsigned index,
42 const WebGamepad& gamepad, 42 const device::Gamepad& gamepad,
43 bool connected) { 43 bool connected) {
44 ASSERT(index < WebGamepads::kItemsLengthCap); 44 DCHECK(index < device::Gamepads::kItemsLengthCap);
mattreynolds 2017/04/13 01:53:34 DCHECK_LT
juncai 2017/04/13 23:55:52 The linker doesn't like DCHECK_LT(index, device::G
45 ASSERT(connected == gamepad.connected); 45 DCHECK_EQ(connected, gamepad.connected);
46 46
47 latest_change_.pad = gamepad; 47 latest_change_.pad = gamepad;
48 latest_change_.index = index; 48 latest_change_.index = index;
49 NotifyControllers(); 49 NotifyControllers();
50 } 50 }
51 51
52 void GamepadDispatcher::StartListening() { 52 void GamepadDispatcher::StartListening() {
53 Platform::Current()->StartListening(kWebPlatformEventTypeGamepad, this); 53 Platform::Current()->StartListening(kWebPlatformEventTypeGamepad, this);
54 } 54 }
55 55
56 void GamepadDispatcher::StopListening() { 56 void GamepadDispatcher::StopListening() {
57 Platform::Current()->StopListening(kWebPlatformEventTypeGamepad); 57 Platform::Current()->StopListening(kWebPlatformEventTypeGamepad);
58 } 58 }
59 59
60 } // namespace blink 60 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698