Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(736)

Unified Diff: content/browser/gamepad/gamepad_provider.h

Issue 200873002: Gamepad API: add support for connection events (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « content/browser/gamepad/gamepad_consumer.h ('k') | content/browser/gamepad/gamepad_provider.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/browser/gamepad/gamepad_provider.h
diff --git a/content/browser/gamepad/gamepad_provider.h b/content/browser/gamepad/gamepad_provider.h
index 5f10f137a14ed8311b94a25d7242fa9596ef227f..e9e200ae27b491994155018ecfddad2cbeca7acc 100644
--- a/content/browser/gamepad/gamepad_provider.h
+++ b/content/browser/gamepad/gamepad_provider.h
@@ -17,6 +17,7 @@
#include "base/synchronization/lock.h"
#include "base/system_monitor/system_monitor.h"
#include "content/common/content_export.h"
+#include "third_party/WebKit/public/platform/WebGamepads.h"
namespace base {
class MessageLoopProxy;
@@ -43,6 +44,8 @@ class CONTENT_EXPORT GamepadProvider :
base::SharedMemoryHandle GetSharedMemoryHandleForProcess(
base::ProcessHandle renderer_process);
+ void GetCurrentGamepadData(blink::WebGamepads* data);
+
// Pause and resume the background polling thread. Can be called from any
// thread.
void Pause();
@@ -70,6 +73,13 @@ class CONTENT_EXPORT GamepadProvider :
void DoPoll();
void ScheduleDoPoll();
+ void OnGamepadConnectionChange(bool connected,
+ int index,
+ const blink::WebGamepad& pad);
+ void DispatchGamepadConnectionChange(bool connected,
+ int index,
+ const blink::WebGamepad& pad);
+
GamepadHardwareBuffer* SharedMemoryAsHardwareBuffer();
// Checks the gamepad state to see if the user has interacted with it.
@@ -112,11 +122,31 @@ class CONTENT_EXPORT GamepadProvider :
base::Lock devices_changed_lock_;
bool devices_changed_;
+ bool ever_had_user_gesture_;
+
+ struct PadState {
+ PadState() : connected(false) {}
+ bool Match(const blink::WebGamepad& pad) const;
+ void SetPad(const blink::WebGamepad& pad);
+ void SetDisconnected();
+ void AsWebGamepad(blink::WebGamepad* pad);
+
+ bool connected;
+ unsigned axes_length;
+ unsigned buttons_length;
+ blink::WebUChar id[blink::WebGamepad::idLengthCap];
+ blink::WebUChar mapping[blink::WebGamepad::mappingLengthCap];
+ };
+
+ scoped_ptr<PadState[]> pad_states_;
+
// When polling_thread_ is running, members below are only to be used
// from that thread.
scoped_ptr<GamepadDataFetcher> data_fetcher_;
base::SharedMemory gamepad_shared_memory_;
+ base::Lock shared_memory_lock_;
+
// Polling is done on this background thread.
scoped_ptr<base::Thread> polling_thread_;
« no previous file with comments | « content/browser/gamepad/gamepad_consumer.h ('k') | content/browser/gamepad/gamepad_provider.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698