• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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.
4 
5 #ifndef GamepadDispatcher_h
6 #define GamepadDispatcher_h
7 
8 #include "core/frame/DeviceEventDispatcherBase.h"
9 #include "platform/heap/Handle.h"
10 #include "public/platform/WebGamepad.h"
11 #include "public/platform/WebGamepadListener.h"
12 
13 namespace blink {
14 class WebGamepads;
15 }
16 
17 namespace WebCore {
18 
19 class NavigatorGamepad;
20 
21 class GamepadDispatcher : public DeviceEventDispatcherBase, public blink::WebGamepadListener {
22 public:
23     static GamepadDispatcher& instance();
24 
25     void sampleGamepads(blink::WebGamepads&);
26 
27     struct ConnectionChange {
28         blink::WebGamepad pad;
29         unsigned index;
30     };
31 
latestConnectionChange()32     const ConnectionChange& latestConnectionChange() const { return m_latestChange; }
33 
34 private:
35     GamepadDispatcher();
36     virtual ~GamepadDispatcher();
37 
38     // WebGamepadListener
39     virtual void didConnectGamepad(unsigned index, const blink::WebGamepad&) OVERRIDE;
40     virtual void didDisconnectGamepad(unsigned index, const blink::WebGamepad&) OVERRIDE;
41 
42     // DeviceEventDispatcherBase
43     virtual void startListening() OVERRIDE;
44     virtual void stopListening() OVERRIDE;
45 
46     void dispatchDidConnectOrDisconnectGamepad(unsigned index, const blink::WebGamepad&, bool connected);
47 
48     ConnectionChange m_latestChange;
49 };
50 
51 } // namespace WebCore
52 
53 #endif
54