Bug 849845 - Map Gamepad L1/R1 to back/forward on Android. r=kats

This commit is contained in:
Chris Lord 2013-03-13 02:58:41 +00:00
parent ca835e6d03
commit 4e6228dc58

View File

@ -326,9 +326,12 @@ abstract public class BrowserApp extends GeckoApp
return false;
}
// Toggle/focus the address bar on gamepad-y button.
if (keyCode == KeyEvent.KEYCODE_BUTTON_Y &&
// Gamepad support only exists in API-level >= 9
if (Build.VERSION.SDK_INT >= 9 &&
(event.getSource() & InputDevice.SOURCE_GAMEPAD) == InputDevice.SOURCE_GAMEPAD) {
switch (keyCode) {
case KeyEvent.KEYCODE_BUTTON_Y:
// Toggle/focus the address bar on gamepad-y button.
if (mBrowserToolbar.isVisible()) {
if (mDynamicToolbarEnabled &&
Boolean.FALSE.equals(mAboutHomeShowing)) {
@ -343,8 +346,16 @@ abstract public class BrowserApp extends GeckoApp
mBrowserToolbar.animateVisibility(true, 0);
mBrowserToolbar.requestFocusFromTouch();
}
return true;
case KeyEvent.KEYCODE_BUTTON_L1:
// Go back on L1
Tabs.getInstance().getSelectedTab().doBack();
return true;
case KeyEvent.KEYCODE_BUTTON_R1:
// Go forward on R1
Tabs.getInstance().getSelectedTab().doForward();
return true;
}
}
return false;