blob: 1fb8f1fb0f82f4aa3e3fe48a1942b5488006dbf9 [file] [log] [blame]
[email protected]4324e612011-12-01 00:01:381// 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.
4
[email protected]0a8d4275e2013-01-04 22:21:265#ifndef CONTENT_RENDERER_GAMEPAD_SHARED_MEMORY_READER_H_
6#define CONTENT_RENDERER_GAMEPAD_SHARED_MEMORY_READER_H_
[email protected]4324e612011-12-01 00:01:387
dchengcedca5612016-04-09 01:40:158#include <memory>
9
avi1023d012015-12-25 02:39:1410#include "base/macros.h"
[email protected]8bac37b2013-07-18 19:13:5611#include "base/memory/shared_memory.h"
[email protected]0ff736562014-05-09 09:09:4712#include "content/common/gamepad_messages.h"
[email protected]078780b2014-06-20 16:57:0613#include "content/public/renderer/renderer_gamepad_provider.h"
[email protected]5c30b5e02013-05-30 03:46:0814#include "third_party/WebKit/public/platform/WebGamepads.h"
[email protected]4324e612011-12-01 00:01:3815
16namespace content {
17
18struct GamepadHardwareBuffer;
19
[email protected]9c41b462014-08-19 15:51:3420class GamepadSharedMemoryReader : public RendererGamepadProvider {
[email protected]4324e612011-12-01 00:01:3821 public:
[email protected]9c41b462014-08-19 15:51:3422 explicit GamepadSharedMemoryReader(RenderThread* thread);
dcheng6d18e402014-10-21 12:32:5223 ~GamepadSharedMemoryReader() override;
[email protected]0ff736562014-05-09 09:09:4724
[email protected]078780b2014-06-20 16:57:0625 // RendererGamepadProvider implementation.
dcheng6d18e402014-10-21 12:32:5226 void SampleGamepads(blink::WebGamepads& gamepads) override;
27 bool OnControlMessageReceived(const IPC::Message& message) override;
28 void Start(blink::WebPlatformEventListener* listener) override;
[email protected]9c41b462014-08-19 15:51:3429
30 protected:
31 // PlatformEventObserver protected methods.
dcheng6d18e402014-10-21 12:32:5232 void SendStartMessage() override;
33 void SendStopMessage() override;
[email protected]4324e612011-12-01 00:01:3834
35 private:
[email protected]0ff736562014-05-09 09:09:4736 void OnGamepadConnected(int index, const blink::WebGamepad& gamepad);
37 void OnGamepadDisconnected(int index, const blink::WebGamepad& gamepad);
38
[email protected]4324e612011-12-01 00:01:3839 base::SharedMemoryHandle renderer_shared_memory_handle_;
dchengcedca5612016-04-09 01:40:1540 std::unique_ptr<base::SharedMemory> renderer_shared_memory_;
[email protected]4324e612011-12-01 00:01:3841 GamepadHardwareBuffer* gamepad_hardware_buffer_;
42
[email protected]00c0d042012-09-10 07:06:3943 bool ever_interacted_with_;
[email protected]9c41b462014-08-19 15:51:3444
45 DISALLOW_COPY_AND_ASSIGN(GamepadSharedMemoryReader);
[email protected]4324e612011-12-01 00:01:3846};
47
[email protected]93df81e2012-08-10 22:22:4648} // namespace content
[email protected]4324e612011-12-01 00:01:3849
[email protected]0a8d4275e2013-01-04 22:21:2650#endif // CONTENT_RENDERER_GAMEPAD_SHARED_MEMORY_READER_H_