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

Unified Diff: chrome/android/java/src/org/chromium/chrome/browser/KeyboardShortcuts.java

Issue 1276703003: Handle UI operations through gamepad (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 5 years, 4 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 | « no previous file | content/browser/gamepad/gamepad_platform_data_fetcher_android.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/android/java/src/org/chromium/chrome/browser/KeyboardShortcuts.java
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/KeyboardShortcuts.java b/chrome/android/java/src/org/chromium/chrome/browser/KeyboardShortcuts.java
index 54d174547b2b6ea54d36926baf26f0c54990ee6c..8111d1355ddf2e6301061107cb12206e71fe0faf 100644
--- a/chrome/android/java/src/org/chromium/chrome/browser/KeyboardShortcuts.java
+++ b/chrome/android/java/src/org/chromium/chrome/browser/KeyboardShortcuts.java
@@ -34,6 +34,11 @@ public class KeyboardShortcuts {
| (event.isShiftPressed() ? SHIFT : 0);
}
+ private static boolean isGamepadAPIActive(ChromeActivity activity) {
+ ContentViewCore cvc = activity.getCurrentContentViewCore();
+ return (cvc != null) ? cvc.isGamepadAPIActive() : false;
+ }
+
/**
* This should be called from the Activity's dispatchKeyEvent() to handle keyboard shortcuts.
*
@@ -105,7 +110,9 @@ public class KeyboardShortcuts {
boolean isCurrentTabVisible, boolean tabSwitchingEnabled) {
int keyCode = event.getKeyCode();
if (event.getRepeatCount() != 0 || KeyEvent.isModifierKey(keyCode)) return false;
- if (!event.isCtrlPressed() && !event.isAltPressed()
+ if (KeyEvent.isGamepadButton(keyCode)) {
+ if (isGamepadAPIActive(activity)) return false;
+ } else if (!event.isCtrlPressed() && !event.isAltPressed()
&& keyCode != KeyEvent.KEYCODE_F3
&& keyCode != KeyEvent.KEYCODE_F5
&& keyCode != KeyEvent.KEYCODE_FORWARD) {
@@ -146,6 +153,7 @@ public class KeyboardShortcuts {
}
return true;
case ALT | KeyEvent.KEYCODE_F:
+ case KeyEvent.KEYCODE_BUTTON_Y:
activity.onMenuOrKeyboardAction(R.id.show_menu, false);
return true;
}
@@ -167,18 +175,21 @@ public class KeyboardShortcuts {
switch (keyCodeAndMeta) {
case CTRL | KeyEvent.KEYCODE_TAB:
case CTRL | KeyEvent.KEYCODE_PAGE_DOWN:
+ case KeyEvent.KEYCODE_BUTTON_R1:
if (tabSwitchingEnabled && count > 1) {
TabModelUtils.setIndex(curModel, (curModel.index() + 1) % count);
}
return true;
case CTRL | SHIFT | KeyEvent.KEYCODE_TAB:
case CTRL | KeyEvent.KEYCODE_PAGE_UP:
+ case KeyEvent.KEYCODE_BUTTON_L1:
if (tabSwitchingEnabled && count > 1) {
TabModelUtils.setIndex(curModel, (curModel.index() + count - 1) % count);
}
return true;
case CTRL | KeyEvent.KEYCODE_W:
case CTRL | KeyEvent.KEYCODE_F4:
+ case KeyEvent.KEYCODE_BUTTON_B:
TabModelUtils.closeCurrentTab(curModel);
return true;
case CTRL | KeyEvent.KEYCODE_F:
@@ -190,6 +201,7 @@ public class KeyboardShortcuts {
return true;
case CTRL | KeyEvent.KEYCODE_L:
case ALT | KeyEvent.KEYCODE_D:
+ case KeyEvent.KEYCODE_BUTTON_X:
activity.onMenuOrKeyboardAction(R.id.focus_url_bar, false);
return true;
case KeyEvent.KEYCODE_BOOKMARK:
@@ -227,6 +239,7 @@ public class KeyboardShortcuts {
return true;
case ALT | KeyEvent.KEYCODE_DPAD_RIGHT:
case KeyEvent.KEYCODE_FORWARD:
+ case KeyEvent.KEYCODE_BUTTON_START:
tab = activity.getActivityTab();
if (tab != null && tab.canGoForward()) tab.goForward();
return true;
« no previous file with comments | « no previous file | content/browser/gamepad/gamepad_platform_data_fetcher_android.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698