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 CONTENT_SHELL_RENDERER_TEST_RUNNER_GAMEPAD_CONTROLLER_H_ | 5 #ifndef CONTENT_SHELL_RENDERER_TEST_RUNNER_GAMEPAD_CONTROLLER_H_ |
6 #define CONTENT_SHELL_RENDERER_TEST_RUNNER_GAMEPAD_CONTROLLER_H_ | 6 #define CONTENT_SHELL_RENDERER_TEST_RUNNER_GAMEPAD_CONTROLLER_H_ |
7 | 7 |
8 #include <map> | 8 #include <map> |
9 | 9 |
10 #include "base/memory/weak_ptr.h" | 10 #include "base/memory/weak_ptr.h" |
(...skipping 16 matching lines...) Expand all Loading... |
27 GamepadController(); | 27 GamepadController(); |
28 virtual ~GamepadController(); | 28 virtual ~GamepadController(); |
29 | 29 |
30 void Reset(); | 30 void Reset(); |
31 void Install(blink::WebFrame* frame); | 31 void Install(blink::WebFrame* frame); |
32 void SetDelegate(WebTestDelegate* delegate); | 32 void SetDelegate(WebTestDelegate* delegate); |
33 | 33 |
34 // RendererGamepadProvider implementation. | 34 // RendererGamepadProvider implementation. |
35 virtual void SampleGamepads( | 35 virtual void SampleGamepads( |
36 blink::WebGamepads& gamepads) OVERRIDE; | 36 blink::WebGamepads& gamepads) OVERRIDE; |
37 virtual bool OnControlMessageReceived(const IPC::Message& msg) OVERRIDE; | 37 virtual void SetGamepadListener( |
38 virtual void SendStartMessage() OVERRIDE; | 38 blink::WebGamepadListener* listener) OVERRIDE; |
39 virtual void SendStopMessage() OVERRIDE; | |
40 | 39 |
41 private: | 40 private: |
42 friend class GamepadControllerBindings; | 41 friend class GamepadControllerBindings; |
43 | 42 |
44 // TODO(b.kelemen): for historical reasons Connect just initializes the | 43 // TODO(b.kelemen): for historical reasons Connect just initializes the |
45 // object. The 'gamepadconnected' event will be dispatched via | 44 // object. The 'gamepadconnected' event will be dispatched via |
46 // DispatchConnected. Tests for connected events need to first connect(), | 45 // DispatchConnected. Tests for connected events need to first connect(), |
47 // then set the gamepad data and finally call dispatchConnected(). | 46 // then set the gamepad data and finally call dispatchConnected(). |
48 // We should consider renaming Connect to Init and DispatchConnected to | 47 // We should consider renaming Connect to Init and DispatchConnected to |
49 // Connect and at the same time updating all the gamepad tests. | 48 // Connect and at the same time updating all the gamepad tests. |
50 void Connect(int index); | 49 void Connect(int index); |
51 void DispatchConnected(int index); | 50 void DispatchConnected(int index); |
52 | 51 |
53 void Disconnect(int index); | 52 void Disconnect(int index); |
54 void SetId(int index, const std::string& src); | 53 void SetId(int index, const std::string& src); |
55 void SetButtonCount(int index, int buttons); | 54 void SetButtonCount(int index, int buttons); |
56 void SetButtonData(int index, int button, double data); | 55 void SetButtonData(int index, int button, double data); |
57 void SetAxisCount(int index, int axes); | 56 void SetAxisCount(int index, int axes); |
58 void SetAxisData(int index, int axis, double data); | 57 void SetAxisData(int index, int axis, double data); |
59 | 58 |
60 blink::WebGamepads gamepads_; | 59 blink::WebGamepads gamepads_; |
61 | 60 |
| 61 blink::WebGamepadListener* listener_; |
| 62 |
62 // Mapping from gamepad index to connection state. | 63 // Mapping from gamepad index to connection state. |
63 std::map<int, bool> pending_changes_; | 64 std::map<int, bool> pending_changes_; |
64 | 65 |
65 base::WeakPtrFactory<GamepadController> weak_factory_; | 66 base::WeakPtrFactory<GamepadController> weak_factory_; |
66 | 67 |
67 DISALLOW_COPY_AND_ASSIGN(GamepadController); | 68 DISALLOW_COPY_AND_ASSIGN(GamepadController); |
68 }; | 69 }; |
69 | 70 |
70 } // namespace content | 71 } // namespace content |
71 | 72 |
72 #endif // CONTENT_SHELL_RENDERER_TEST_RUNNER_GAMEPAD_CONTROLLER_H_ | 73 #endif // CONTENT_SHELL_RENDERER_TEST_RUNNER_GAMEPAD_CONTROLLER_H_ |
OLD | NEW |