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