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

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, 11 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 30a5d3eac45087bc0adba8df73c82720af7da65d..70507f5c8240481baa311697c2af46c75f8a99c7 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
@@ -1,4 +1,5 @@
// Copyright 2012 The Chromium Authors. All rights reserved.
+// Copyright (c) 2014, NVIDIA CORPORATION. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -126,6 +127,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.
@@ -504,6 +507,7 @@ public class ContentViewCore
mInsertionHandlePoint = mRenderCoordinates.createNormalizedPoint();
mAccessibilityManager = (AccessibilityManager)
getContext().getSystemService(Context.ACCESSIBILITY_SERVICE);
+ mGamepadList = GamepadList.createInstance(context);
}
/**
@@ -1857,6 +1861,9 @@ public class ContentViewCore
* @see View#dispatchKeyEvent(KeyEvent)
*/
public boolean dispatchKeyEvent(KeyEvent event) {
+ if (mGamepadList.isGamepadAccessed() && mGamepadList.isGamepadEvent(event)) {
+ return mGamepadList.updateForEvent(event);
+ }
if (getContentViewClient().shouldOverrideKeyEvent(event)) {
return mContainerViewInternals.super_dispatchKeyEvent(event);
}
@@ -1866,6 +1873,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.
@@ -1890,6 +1909,9 @@ public class ContentViewCore
* @see View#onGenericMotionEvent(MotionEvent)
*/
public boolean onGenericMotionEvent(MotionEvent event) {
+ if (mGamepadList.isGamepadAccessed() && mGamepadList.isGamepadEvent(event)) {
+ 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