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 class WebGamepads; | |
15 } | |
16 | |
17 namespace blink { | |
18 | 14 |
19 class NavigatorGamepad; | 15 class NavigatorGamepad; |
| 16 class WebGamepads; |
20 | 17 |
21 class GamepadDispatcher : public PlatformEventDispatcher, public blink::WebGamep
adListener { | 18 class GamepadDispatcher : public PlatformEventDispatcher, public WebGamepadListe
ner { |
22 public: | 19 public: |
23 static GamepadDispatcher& instance(); | 20 static GamepadDispatcher& instance(); |
24 | 21 |
25 void sampleGamepads(blink::WebGamepads&); | 22 void sampleGamepads(WebGamepads&); |
26 | 23 |
27 struct ConnectionChange { | 24 struct ConnectionChange { |
28 blink::WebGamepad pad; | 25 WebGamepad pad; |
29 unsigned index; | 26 unsigned index; |
30 }; | 27 }; |
31 | 28 |
32 const ConnectionChange& latestConnectionChange() const { return m_latestChan
ge; } | 29 const ConnectionChange& latestConnectionChange() const { return m_latestChan
ge; } |
33 | 30 |
34 private: | 31 private: |
35 GamepadDispatcher(); | 32 GamepadDispatcher(); |
36 virtual ~GamepadDispatcher(); | 33 virtual ~GamepadDispatcher(); |
37 | 34 |
38 // WebGamepadListener | 35 // WebGamepadListener |
39 virtual void didConnectGamepad(unsigned index, const blink::WebGamepad&) OVE
RRIDE; | 36 virtual void didConnectGamepad(unsigned index, const WebGamepad&) OVERRIDE; |
40 virtual void didDisconnectGamepad(unsigned index, const blink::WebGamepad&)
OVERRIDE; | 37 virtual void didDisconnectGamepad(unsigned index, const WebGamepad&) OVERRID
E; |
41 | 38 |
42 // PlatformEventDispatcher | 39 // PlatformEventDispatcher |
43 virtual void startListening() OVERRIDE; | 40 virtual void startListening() OVERRIDE; |
44 virtual void stopListening() OVERRIDE; | 41 virtual void stopListening() OVERRIDE; |
45 | 42 |
46 void dispatchDidConnectOrDisconnectGamepad(unsigned index, const blink::WebG
amepad&, bool connected); | 43 void dispatchDidConnectOrDisconnectGamepad(unsigned index, const WebGamepad&
, bool connected); |
47 | 44 |
48 ConnectionChange m_latestChange; | 45 ConnectionChange m_latestChange; |
49 }; | 46 }; |
50 | 47 |
51 } // namespace blink | 48 } // namespace blink |
52 | 49 |
53 #endif | 50 #endif |
OLD | NEW |