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

Unified Diff: content/public/android/java/src/org/chromium/content/browser/ContentViewCore.java

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 side-by-side diff with in-line comments
Download patch
Index: content/public/android/java/src/org/chromium/content/browser/ContentViewCore.java
diff --git a/content/public/android/java/src/org/chromium/content/browser/ContentViewCore.java b/content/public/android/java/src/org/chromium/content/browser/ContentViewCore.java
index 7921262064b3b3a91f7fa48be457f97fc2e933f7..a3116345d523c1c4bdbb458055d290d4ec3a16fe 100644
--- a/content/public/android/java/src/org/chromium/content/browser/ContentViewCore.java
+++ b/content/public/android/java/src/org/chromium/content/browser/ContentViewCore.java
@@ -129,6 +129,8 @@ public class ContentViewCore
// expects HashSet (no bindings for interfaces).
private final HashSet<Object> mRetainedJavaScriptObjects = new HashSet<Object>();
+ private GamepadList mGamepadList;
+
/**
* Interface that consumers of {@link ContentViewCore} must implement to allow the proper
* dispatching of view methods through the containing view.
@@ -481,6 +483,7 @@ public class ContentViewCore
getContext().getSystemService(Context.ACCESSIBILITY_SERVICE);
mGestureStateListeners = new ObserverList<GestureStateListener>();
mGestureStateListenersIterator = mGestureStateListeners.rewindableIterator();
+ mGamepadList = GamepadList.createInstance(context);
}
/**
@@ -1829,6 +1832,9 @@ public class ContentViewCore
* @see View#dispatchKeyEvent(KeyEvent)
*/
public boolean dispatchKeyEvent(KeyEvent event) {
+ if (mGamepadList.isGamepadAccessed() && mGamepadList.isGamepadEvent(event)) {
kbalazs 2014/02/20 00:48:24 I would move both checks to the callee and remove
+ return mGamepadList.updateForEvent(event);
+ }
if (getContentViewClient().shouldOverrideKeyEvent(event)) {
return mContainerViewInternals.super_dispatchKeyEvent(event);
}
@@ -1838,6 +1844,18 @@ public class ContentViewCore
return mContainerViewInternals.super_dispatchKeyEvent(event);
}
+ public void onPause() {
+ if (mGamepadList != null) {
+ mGamepadList.onPause();
+ }
+ }
+
+ public void onResume() {
+ if (mGamepadList != null) {
+ mGamepadList.onResume();
+ }
+ }
+
/**
* @see View#onHoverEvent(MotionEvent)
* Mouse move events are sent on hover enter, hover move and hover exit.
@@ -1862,6 +1880,9 @@ public class ContentViewCore
* @see View#onGenericMotionEvent(MotionEvent)
*/
public boolean onGenericMotionEvent(MotionEvent event) {
+ if (mGamepadList.isGamepadAccessed() && mGamepadList.isGamepadEvent(event)) {
kbalazs 2014/02/20 00:48:24 Ditto.
+ return mGamepadList.updateForEvent(event);
+ }
if ((event.getSource() & InputDevice.SOURCE_CLASS_POINTER) != 0) {
switch (event.getAction()) {
case MotionEvent.ACTION_SCROLL:

Powered by Google App Engine
This is Rietveld 408576698