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. 4 5#ifndef CONTENT_RENDERER_GAMEPAD_SHARED_MEMORY_READER_H_ 6#define CONTENT_RENDERER_GAMEPAD_SHARED_MEMORY_READER_H_ 7 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" 13 14namespace content { 15 16struct GamepadHardwareBuffer; 17 18class GamepadSharedMemoryReader : public RendererGamepadProvider { 19 public: 20 explicit GamepadSharedMemoryReader(RenderThread* thread); 21 virtual ~GamepadSharedMemoryReader(); 22 23 // RendererGamepadProvider implementation. 24 virtual void SampleGamepads( 25 blink::WebGamepads& gamepads) OVERRIDE; 26 virtual bool OnControlMessageReceived(const IPC::Message& message) OVERRIDE; 27 virtual void Start(blink::WebPlatformEventListener* listener) OVERRIDE; 28 29 protected: 30 // PlatformEventObserver protected methods. 31 virtual void SendStartMessage() OVERRIDE; 32 virtual void SendStopMessage() OVERRIDE; 33 34 private: 35 void OnGamepadConnected(int index, const blink::WebGamepad& gamepad); 36 void OnGamepadDisconnected(int index, const blink::WebGamepad& gamepad); 37 38 base::SharedMemoryHandle renderer_shared_memory_handle_; 39 scoped_ptr<base::SharedMemory> renderer_shared_memory_; 40 GamepadHardwareBuffer* gamepad_hardware_buffer_; 41 42 bool ever_interacted_with_; 43 44 DISALLOW_COPY_AND_ASSIGN(GamepadSharedMemoryReader); 45}; 46 47} // namespace content 48 49#endif // CONTENT_RENDERER_GAMEPAD_SHARED_MEMORY_READER_H_ 50