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

Side by Side Diff: content/browser/android/gamepad_reader_impl.h

Issue 133943002: Gamepad API support for chrome on android (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Created 6 years, 10 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 unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2014 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_BROWSER_ANDROID_GAMEPAD_READER_H_
6 #define CONTENT_BROWSER_ANDROID_GAMEPAD_READER_H_
7
8 #include <jni.h>
9 #include <string>
10 #include <vector>
11
12 #include "base/android/jni_array.h"
13 #include "base/android/jni_helper.h"
14 #include "base/android/scoped_java_ref.h"
15 #include "base/memory/ref_counted.h"
16 #include "base/memory/singleton.h"
17 #include "third_party/WebKit/public/platform/WebGamepads.h"
18
19 namespace content {
20 using std::string;
21 // This class interacts with JNI and calls GamepadList. It creates a
22 // GamepadsReader java object and pings GamepadList for updates.
23
24 // The simplified flow is:
25 // 1. GamepadDataFetcher runs on a Polling Thread and it tries to fetch data
26 // via low-level data fetcher from the framework for android platform.
27 // 2. GamepadPlatformDataFetcherAndroid access a singleton GamepadsReader
28 // GamepadsReader makes JNI calls and uses singleton GamepadList on the java
29 // side to get the updated gamepad state. We then bounce these updates to the
30 // GamepadProvider which writes to GamepadHardwareBuffer.
31
32 // Note that GamepadsReader is a singleton and there's at most only
33 // one GamepadsReader that has made calls to GamepadList.
34
35 class GamepadsReader {
36 public:
37 // Registers the JNI methods for GamepadsReader.
38 static bool RegisterGamepadsReader(JNIEnv* env);
39 // Returns our singleton.
40 static GamepadsReader* GetInstance();
41
42 // Native methods that are called from GamepadList.
43 void SetGamepadData(JNIEnv* env,
44 jobject obj,
45 int index,
46 bool connected,
47 jstring devicename,
48 int64 timestamp,
49 jfloatArray jaxes,
50 jfloatArray jbuttons);
51
52 void UpdateDeviceCount(JNIEnv* env, jobject obj, int devicecount);
53
54 // Called on Polling thread.
55 void GetGamepadData(blink::WebGamepads* pads);
56
57 // Called to update GamepadList for Gamepad access and release by
58 // low level gamepad data fetcher.
59 void NotifyForGamepadsAccess(bool isaccesspaused);
60
61 private:
62 friend struct DefaultSingletonTraits<GamepadsReader>;
63 GamepadsReader();
64 ~GamepadsReader();
65
66 void CreateJavaObject(JNIEnv* env);
67
68 // Data to fetch into.
69 blink::WebGamepads* gamepads_data_;
70
71 base::android::ScopedJavaGlobalRef<jobject> java_gamepadList_object_;
72 };
73
74 } // namespace content
75
76 #endif // CONTENT_BROWSER_ANDROID_GAMEPAD_READER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698