OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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_RENDERER_GAMEPAD_SHARED_MEMORY_READER_H_ | 5 #ifndef CONTENT_RENDERER_GAMEPAD_SHARED_MEMORY_READER_H_ |
6 #define CONTENT_RENDERER_GAMEPAD_SHARED_MEMORY_READER_H_ | 6 #define CONTENT_RENDERER_GAMEPAD_SHARED_MEMORY_READER_H_ |
7 | 7 |
8 #include <memory> | 8 #include <memory> |
9 | 9 |
10 #include "base/macros.h" | 10 #include "base/macros.h" |
11 #include "content/public/renderer/renderer_gamepad_provider.h" | 11 #include "content/public/renderer/renderer_gamepad_provider.h" |
12 #include "device/base/synchronization/shared_memory_seqlock_buffer.h" | 12 #include "device/base/synchronization/shared_memory_seqlock_buffer.h" |
| 13 #include "device/gamepad/public/cpp/gamepads.h" |
13 #include "device/gamepad/public/interfaces/gamepad.mojom.h" | 14 #include "device/gamepad/public/interfaces/gamepad.mojom.h" |
14 #include "mojo/public/cpp/bindings/binding.h" | 15 #include "mojo/public/cpp/bindings/binding.h" |
15 #include "mojo/public/cpp/system/buffer.h" | 16 #include "mojo/public/cpp/system/buffer.h" |
16 #include "third_party/WebKit/public/platform/WebGamepads.h" | |
17 | 17 |
18 namespace content { | 18 namespace content { |
19 | 19 |
20 typedef device::SharedMemorySeqLockBuffer<blink::WebGamepads> | 20 typedef device::SharedMemorySeqLockBuffer<device::Gamepads> |
21 GamepadHardwareBuffer; | 21 GamepadHardwareBuffer; |
22 | 22 |
23 class GamepadSharedMemoryReader : public RendererGamepadProvider, | 23 class GamepadSharedMemoryReader : public RendererGamepadProvider, |
24 public device::mojom::GamepadObserver { | 24 public device::mojom::GamepadObserver { |
25 public: | 25 public: |
26 explicit GamepadSharedMemoryReader(RenderThread* thread); | 26 explicit GamepadSharedMemoryReader(RenderThread* thread); |
27 ~GamepadSharedMemoryReader() override; | 27 ~GamepadSharedMemoryReader() override; |
28 | 28 |
29 // RendererGamepadProvider implementation. | 29 // RendererGamepadProvider implementation. |
30 void SampleGamepads(blink::WebGamepads& gamepads) override; | 30 void SampleGamepads(device::Gamepads& gamepads) override; |
31 void Start(blink::WebPlatformEventListener* listener) override; | 31 void Start(blink::WebPlatformEventListener* listener) override; |
32 | 32 |
33 protected: | 33 protected: |
34 // PlatformEventObserver protected methods. | 34 // PlatformEventObserver protected methods. |
35 void SendStartMessage() override; | 35 void SendStartMessage() override; |
36 void SendStopMessage() override; | 36 void SendStopMessage() override; |
37 | 37 |
38 private: | 38 private: |
39 // device::mojom::GamepadObserver methods. | 39 // device::mojom::GamepadObserver methods. |
40 void GamepadConnected(int index, const blink::WebGamepad& gamepad) override; | 40 void GamepadConnected(int index, const device::Gamepad& gamepad) override; |
41 void GamepadDisconnected(int index, | 41 void GamepadDisconnected(int index, const device::Gamepad& gamepad) override; |
42 const blink::WebGamepad& gamepad) override; | |
43 | 42 |
44 mojo::ScopedSharedBufferHandle renderer_shared_buffer_handle_; | 43 mojo::ScopedSharedBufferHandle renderer_shared_buffer_handle_; |
45 mojo::ScopedSharedBufferMapping renderer_shared_buffer_mapping_; | 44 mojo::ScopedSharedBufferMapping renderer_shared_buffer_mapping_; |
46 GamepadHardwareBuffer* gamepad_hardware_buffer_; | 45 GamepadHardwareBuffer* gamepad_hardware_buffer_; |
47 | 46 |
48 bool ever_interacted_with_; | 47 bool ever_interacted_with_; |
49 | 48 |
50 mojo::Binding<device::mojom::GamepadObserver> binding_; | 49 mojo::Binding<device::mojom::GamepadObserver> binding_; |
51 device::mojom::GamepadMonitorPtr gamepad_monitor_; | 50 device::mojom::GamepadMonitorPtr gamepad_monitor_; |
52 | 51 |
53 DISALLOW_COPY_AND_ASSIGN(GamepadSharedMemoryReader); | 52 DISALLOW_COPY_AND_ASSIGN(GamepadSharedMemoryReader); |
54 }; | 53 }; |
55 | 54 |
56 } // namespace content | 55 } // namespace content |
57 | 56 |
58 #endif // CONTENT_RENDERER_GAMEPAD_SHARED_MEMORY_READER_H_ | 57 #endif // CONTENT_RENDERER_GAMEPAD_SHARED_MEMORY_READER_H_ |
OLD | NEW |