OLD | NEW |
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 #ifndef GamepadDispatcher_h | 5 #ifndef GamepadDispatcher_h |
6 #define GamepadDispatcher_h | 6 #define GamepadDispatcher_h |
7 | 7 |
8 #include "core/frame/PlatformEventDispatcher.h" | 8 #include "core/frame/PlatformEventDispatcher.h" |
| 9 #include "device/gamepad/public/cpp/gamepads.h" |
9 #include "platform/heap/Handle.h" | 10 #include "platform/heap/Handle.h" |
10 #include "public/platform/WebGamepad.h" | |
11 #include "public/platform/WebGamepadListener.h" | 11 #include "public/platform/WebGamepadListener.h" |
12 | 12 |
13 namespace blink { | 13 namespace blink { |
14 | 14 |
15 class WebGamepads; | |
16 | |
17 class GamepadDispatcher final | 15 class GamepadDispatcher final |
18 : public GarbageCollectedFinalized<GamepadDispatcher>, | 16 : public GarbageCollectedFinalized<GamepadDispatcher>, |
19 public PlatformEventDispatcher, | 17 public PlatformEventDispatcher, |
20 public WebGamepadListener { | 18 public WebGamepadListener { |
21 USING_GARBAGE_COLLECTED_MIXIN(GamepadDispatcher); | 19 USING_GARBAGE_COLLECTED_MIXIN(GamepadDispatcher); |
22 | 20 |
23 public: | 21 public: |
24 static GamepadDispatcher& Instance(); | 22 static GamepadDispatcher& Instance(); |
25 ~GamepadDispatcher() override; | 23 ~GamepadDispatcher() override; |
26 | 24 |
27 void SampleGamepads(WebGamepads&); | 25 void SampleGamepads(device::Gamepads&); |
28 | 26 |
29 struct ConnectionChange { | 27 struct ConnectionChange { |
30 DISALLOW_NEW(); | 28 DISALLOW_NEW(); |
31 WebGamepad pad; | 29 device::Gamepad pad; |
32 unsigned index; | 30 unsigned index; |
33 }; | 31 }; |
34 | 32 |
35 const ConnectionChange& LatestConnectionChange() const { | 33 const ConnectionChange& LatestConnectionChange() const { |
36 return latest_change_; | 34 return latest_change_; |
37 } | 35 } |
38 | 36 |
39 DECLARE_VIRTUAL_TRACE(); | 37 DECLARE_VIRTUAL_TRACE(); |
40 | 38 |
41 private: | 39 private: |
42 GamepadDispatcher(); | 40 GamepadDispatcher(); |
43 | 41 |
44 // WebGamepadListener | 42 // WebGamepadListener |
45 void DidConnectGamepad(unsigned index, const WebGamepad&) override; | 43 void DidConnectGamepad(unsigned index, const device::Gamepad&) override; |
46 void DidDisconnectGamepad(unsigned index, const WebGamepad&) override; | 44 void DidDisconnectGamepad(unsigned index, const device::Gamepad&) override; |
47 | 45 |
48 // PlatformEventDispatcher | 46 // PlatformEventDispatcher |
49 void StartListening() override; | 47 void StartListening() override; |
50 void StopListening() override; | 48 void StopListening() override; |
51 | 49 |
52 void DispatchDidConnectOrDisconnectGamepad(unsigned index, | 50 void DispatchDidConnectOrDisconnectGamepad(unsigned index, |
53 const WebGamepad&, | 51 const device::Gamepad&, |
54 bool connected); | 52 bool connected); |
55 | 53 |
56 ConnectionChange latest_change_; | 54 ConnectionChange latest_change_; |
57 }; | 55 }; |
58 | 56 |
59 } // namespace blink | 57 } // namespace blink |
60 | 58 |
61 #endif | 59 #endif |
OLD | NEW |