Chromium Code Reviews| 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..342053f231168c7a955f6a41e107822b5e8e7875 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,13 @@ public class KeyboardShortcuts { |
| | (event.isShiftPressed() ? SHIFT : 0); |
| } |
| + private static boolean isGamepadAPIActive(KeyEvent event, ChromeActivity activity) { |
|
jdduke (slow)
2015/08/07 18:19:30
I don't think we need the KeyEvent arg here, do we
|
| + if (activity.getCurrentContentViewCore() != null) { |
| + return activity.getCurrentContentViewCore().isGamepadAccessed(); |
| + } |
| + return false; |
| + } |
| + |
| /** |
| * This should be called from the Activity's dispatchKeyEvent() to handle keyboard shortcuts. |
| * |
| @@ -108,7 +115,8 @@ public class KeyboardShortcuts { |
| if (!event.isCtrlPressed() && !event.isAltPressed() |
| && keyCode != KeyEvent.KEYCODE_F3 |
| && keyCode != KeyEvent.KEYCODE_F5 |
| - && keyCode != KeyEvent.KEYCODE_FORWARD) { |
| + && keyCode != KeyEvent.KEYCODE_FORWARD |
| + && !(KeyEvent.isGamepadButton(keyCode) && !isGamepadAPIActive(event, activity))) { |
|
jdduke (slow)
2015/08/07 18:19:30
This big if statement is getting pretty meaty, hmm
|
| return false; |
| } |
| @@ -146,6 +154,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 +176,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 +202,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 +240,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; |