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