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 "platform/heap/Handle.h" | 9 #include "platform/heap/Handle.h" |
10 #include "public/platform/WebGamepad.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; | 15 class WebGamepads; |
16 | 16 |
17 class GamepadDispatcher final : public GarbageCollectedFinalized<GamepadDispatch
er>, public PlatformEventDispatcher, public WebGamepadListener { | 17 class GamepadDispatcher final : public GarbageCollectedFinalized<GamepadDispatch
er>, public PlatformEventDispatcher, public WebGamepadListener { |
18 USING_GARBAGE_COLLECTED_MIXIN(GamepadDispatcher); | 18 USING_GARBAGE_COLLECTED_MIXIN(GamepadDispatcher); |
19 public: | 19 public: |
20 static GamepadDispatcher& instance(); | 20 static GamepadDispatcher& instance(); |
21 ~GamepadDispatcher() override; | 21 ~GamepadDispatcher() override; |
22 | 22 |
23 void sampleGamepads(WebGamepads&); | 23 void sampleGamepads(WebGamepads&); |
24 | 24 |
25 struct ConnectionChange { | 25 struct ConnectionChange { |
| 26 DISALLOW_ALLOCATION(); |
26 WebGamepad pad; | 27 WebGamepad pad; |
27 unsigned index; | 28 unsigned index; |
28 }; | 29 }; |
29 | 30 |
30 const ConnectionChange& latestConnectionChange() const { return m_latestChan
ge; } | 31 const ConnectionChange& latestConnectionChange() const { return m_latestChan
ge; } |
31 | 32 |
32 DECLARE_VIRTUAL_TRACE(); | 33 DECLARE_VIRTUAL_TRACE(); |
33 | 34 |
34 private: | 35 private: |
35 GamepadDispatcher(); | 36 GamepadDispatcher(); |
36 | 37 |
37 // WebGamepadListener | 38 // WebGamepadListener |
38 void didConnectGamepad(unsigned index, const WebGamepad&) override; | 39 void didConnectGamepad(unsigned index, const WebGamepad&) override; |
39 void didDisconnectGamepad(unsigned index, const WebGamepad&) override; | 40 void didDisconnectGamepad(unsigned index, const WebGamepad&) override; |
40 | 41 |
41 // PlatformEventDispatcher | 42 // PlatformEventDispatcher |
42 void startListening() override; | 43 void startListening() override; |
43 void stopListening() override; | 44 void stopListening() override; |
44 | 45 |
45 void dispatchDidConnectOrDisconnectGamepad(unsigned index, const WebGamepad&
, bool connected); | 46 void dispatchDidConnectOrDisconnectGamepad(unsigned index, const WebGamepad&
, bool connected); |
46 | 47 |
47 ConnectionChange m_latestChange; | 48 ConnectionChange m_latestChange; |
48 }; | 49 }; |
49 | 50 |
50 } // namespace blink | 51 } // namespace blink |
51 | 52 |
52 #endif | 53 #endif |
OLD | NEW |