Commit 00ebecaf authored by Jinsuk Kim's avatar Jinsuk Kim Committed by Commit Bot

Android: Fix a bug not supporting gamepad

https://crrev.com/c/1135874 left out checking gamepad events
by mistake. This CL fixes it by adding the check against
GenericMotionEvent in the content ui event handler.

Tested on https://html5gamepad.com with a USB gamepad.

Bug: 906347
Change-Id: I2bd0890f2533e70a772dbb0b005d69bf086d1595
Reviewed-on: https://chromium-review.googlesource.com/c/1356727Reviewed-by: default avatarBo <boliu@chromium.org>
Commit-Queue: Jinsuk Kim <jinsukkim@chromium.org>
Cr-Commit-Position: refs/heads/master@{#613268}
parent caa80875
......@@ -17,7 +17,6 @@ import org.chromium.content.browser.webcontents.WebContentsImpl;
import org.chromium.content.browser.webcontents.WebContentsImpl.UserDataFactory;
import org.chromium.content_public.browser.ViewEventSink.InternalAccessDelegate;
import org.chromium.content_public.browser.WebContents;
import org.chromium.device.gamepad.GamepadList;
import org.chromium.ui.base.EventForwarder;
/**
......@@ -61,7 +60,7 @@ public class ContentUiEventHandler implements UserData {
@CalledByNative
private boolean onGenericMotionEvent(MotionEvent event) {
if (GamepadList.onGenericMotionEvent(event)) return true;
if (Gamepad.from(mWebContents).onGenericMotionEvent(event)) return true;
if (JoystickHandler.fromWebContents(mWebContents).onGenericMotionEvent(event)) return true;
if ((event.getSource() & InputDevice.SOURCE_CLASS_POINTER) != 0) {
switch (event.getActionMasked()) {
......@@ -116,7 +115,7 @@ public class ContentUiEventHandler implements UserData {
@CalledByNative
private boolean dispatchKeyEvent(KeyEvent event) {
if (GamepadList.dispatchKeyEvent(event)) return true;
if (Gamepad.from(mWebContents).dispatchKeyEvent(event)) return true;
if (!shouldPropagateKeyEvent(event)) {
return mEventDelegate.super_dispatchKeyEvent(event);
}
......
......@@ -5,6 +5,8 @@
package org.chromium.content.browser;
import android.content.Context;
import android.view.KeyEvent;
import android.view.MotionEvent;
import org.chromium.base.UserData;
import org.chromium.content.browser.webcontents.WebContentsImpl;
......@@ -44,4 +46,12 @@ class Gamepad implements WindowEventObserver, UserData {
public void onDetachedFromWindow() {
GamepadList.onDetachedFromWindow();
}
public boolean onGenericMotionEvent(MotionEvent event) {
return GamepadList.onGenericMotionEvent(event);
}
public boolean dispatchKeyEvent(KeyEvent event) {
return GamepadList.dispatchKeyEvent(event);
}
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment