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
3 // found in the LICENSE file.
5 #ifndef CONTENT_RENDERER_GAMEPAD_SHARED_MEMORY_READER_H_
6 #define CONTENT_RENDERER_GAMEPAD_SHARED_MEMORY_READER_H_
8 #include "base/memory/scoped_ptr.h"
9 #include "base/memory/shared_memory.h"
10 #include "content/common/gamepad_messages.h"
11 #include "content/public/renderer/renderer_gamepad_provider.h"
12 #include "third_party/WebKit/public/platform/WebGamepads.h"
16 struct GamepadHardwareBuffer
;
18 class GamepadSharedMemoryReader
: public RendererGamepadProvider
{
20 explicit GamepadSharedMemoryReader(RenderThread
* thread
);
21 ~GamepadSharedMemoryReader() override
;
23 // RendererGamepadProvider implementation.
24 void SampleGamepads(blink::WebGamepads
& gamepads
) override
;
25 bool OnControlMessageReceived(const IPC::Message
& message
) override
;
26 void Start(blink::WebPlatformEventListener
* listener
) override
;
29 // PlatformEventObserver protected methods.
30 void SendStartMessage() override
;
31 void SendStopMessage() override
;
34 void OnGamepadConnected(int index
, const blink::WebGamepad
& gamepad
);
35 void OnGamepadDisconnected(int index
, const blink::WebGamepad
& gamepad
);
37 base::SharedMemoryHandle renderer_shared_memory_handle_
;
38 scoped_ptr
<base::SharedMemory
> renderer_shared_memory_
;
39 GamepadHardwareBuffer
* gamepad_hardware_buffer_
;
41 bool ever_interacted_with_
;
43 DISALLOW_COPY_AND_ASSIGN(GamepadSharedMemoryReader
);
46 } // namespace content
48 #endif // CONTENT_RENDERER_GAMEPAD_SHARED_MEMORY_READER_H_