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
3 // found in the LICENSE file.
5 #ifndef GamepadDispatcher_h
6 #define GamepadDispatcher_h
8 #include "core/frame/PlatformEventDispatcher.h"
9 #include "platform/heap/Handle.h"
10 #include "public/platform/WebGamepad.h"
11 #include "public/platform/WebGamepadListener.h"
17 class GamepadDispatcher final : public GarbageCollectedFinalized<GamepadDispatcher>, public PlatformEventDispatcher, public WebGamepadListener {
18 USING_GARBAGE_COLLECTED_MIXIN(GamepadDispatcher);
20 static GamepadDispatcher& instance();
21 virtual ~GamepadDispatcher();
23 void sampleGamepads(WebGamepads&);
25 struct ConnectionChange {
30 const ConnectionChange& latestConnectionChange() const { return m_latestChange; }
32 virtual void trace(Visitor*) override;
38 virtual void didConnectGamepad(unsigned index, const WebGamepad&) override;
39 virtual void didDisconnectGamepad(unsigned index, const WebGamepad&) override;
41 // PlatformEventDispatcher
42 virtual void startListening() override;
43 virtual void stopListening() override;
45 void dispatchDidConnectOrDisconnectGamepad(unsigned index, const WebGamepad&, bool connected);
47 ConnectionChange m_latestChange;