| 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 virtual ~GamepadDispatcher(); | 21 ~GamepadDispatcher() override; |
| 22 | 22 |
| 23 void sampleGamepads(WebGamepads&); | 23 void sampleGamepads(WebGamepads&); |
| 24 | 24 |
| 25 struct ConnectionChange { | 25 struct ConnectionChange { |
| 26 WebGamepad pad; | 26 WebGamepad pad; |
| 27 unsigned index; | 27 unsigned index; |
| 28 }; | 28 }; |
| 29 | 29 |
| 30 const ConnectionChange& latestConnectionChange() const { return m_latestChan
ge; } | 30 const ConnectionChange& latestConnectionChange() const { return m_latestChan
ge; } |
| 31 | 31 |
| 32 DECLARE_VIRTUAL_TRACE(); | 32 DECLARE_VIRTUAL_TRACE(); |
| 33 | 33 |
| 34 private: | 34 private: |
| 35 GamepadDispatcher(); | 35 GamepadDispatcher(); |
| 36 | 36 |
| 37 // WebGamepadListener | 37 // WebGamepadListener |
| 38 virtual void didConnectGamepad(unsigned index, const WebGamepad&) override; | 38 void didConnectGamepad(unsigned index, const WebGamepad&) override; |
| 39 virtual void didDisconnectGamepad(unsigned index, const WebGamepad&) overrid
e; | 39 void didDisconnectGamepad(unsigned index, const WebGamepad&) override; |
| 40 | 40 |
| 41 // PlatformEventDispatcher | 41 // PlatformEventDispatcher |
| 42 virtual void startListening() override; | 42 void startListening() override; |
| 43 virtual void stopListening() override; | 43 void stopListening() override; |
| 44 | 44 |
| 45 void dispatchDidConnectOrDisconnectGamepad(unsigned index, const WebGamepad&
, bool connected); | 45 void dispatchDidConnectOrDisconnectGamepad(unsigned index, const WebGamepad&
, bool connected); |
| 46 | 46 |
| 47 ConnectionChange m_latestChange; | 47 ConnectionChange m_latestChange; |
| 48 }; | 48 }; |
| 49 | 49 |
| 50 } // namespace blink | 50 } // namespace blink |
| 51 | 51 |
| 52 #endif | 52 #endif |
| OLD | NEW |