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

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

Issue 195873019: Gamepad API: add support for connection events (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: and a missing override Created 6 years, 7 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..86a4b17baf336ba98edbf3016edbad0c2244dd54 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,9 +122,36 @@ class CONTENT_EXPORT GamepadProvider :
base::Lock devices_changed_lock_;
bool devices_changed_;
- // When polling_thread_ is running, members below are only to be used
- // from that thread.
+ bool ever_had_user_gesture_;
+
+ class PadState {
+ public:
+ PadState() {
+ SetDisconnected();
+ }
+
+ bool Match(const blink::WebGamepad& pad) const;
+ void SetPad(const blink::WebGamepad& pad);
+ void SetDisconnected();
+ void AsWebGamepad(blink::WebGamepad* pad);
+
+ bool connected() const { return connected_; }
+
+ private:
+ bool connected_;
+ unsigned axes_length_;
+ unsigned buttons_length_;
+ blink::WebUChar id_[blink::WebGamepad::idLengthCap];
+ blink::WebUChar mapping_[blink::WebGamepad::mappingLengthCap];
+ };
+
+ // Used to detect connections and disconnections.
+ scoped_ptr<PadState[]> pad_states_;
+
+ // Only used on the polling thread.
scoped_ptr<GamepadDataFetcher> data_fetcher_;
+
+ base::Lock shared_memory_lock_;
base::SharedMemory gamepad_shared_memory_;
// Polling is done on this background 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