diff --git a/android/src/org/ppsspp/ppsspp/NativeActivity.java b/android/src/org/ppsspp/ppsspp/NativeActivity.java index 9a412bfee0..95823381ab 100644 --- a/android/src/org/ppsspp/ppsspp/NativeActivity.java +++ b/android/src/org/ppsspp/ppsspp/NativeActivity.java @@ -134,8 +134,15 @@ public abstract class NativeActivity extends Activity { public static final int REQUEST_CODE_CAMERA_PERMISSION = 3; public static final int REQUEST_CODE_MICROPHONE_PERMISSION = 4; + // Once we received a "modern" mouse event, we stop listening to old style mouse + // button events. public static boolean useModernMouseEvents = false; + // Workaround for bizarre behavior on Pocophone where we get modern events + // for the left mouse button, but wacky BACK keyboard event with source == mouse + // for the right mouse button. + public static boolean useModernMouseEventsB2 = false; + // Functions for the app activity to override to change behaviour. public native void registerCallbacks(); @@ -985,8 +992,9 @@ public abstract class NativeActivity extends Activity { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB_MR1) { Log.i(TAG, "key event" + event.getSource()); if (NativeSurfaceView.isFromSource(event, InputDevice.SOURCE_MOUSE)) { - Log.i(TAG, "Forwarding key event from mouse"); - if (event.getKeyCode() == KeyEvent.KEYCODE_BACK && !useModernMouseEvents) { + Log.i(TAG, "Forwarding key event from mouse: " + event.getKeyCode()); + Log.i(TAG, "usemodernb2: " + useModernMouseEventsB2); + if (event.getKeyCode() == KeyEvent.KEYCODE_BACK && !useModernMouseEventsB2) { // Probably a right click switch (event.getAction()) { case KeyEvent.ACTION_DOWN: @@ -1094,6 +1102,9 @@ public abstract class NativeActivity extends Activity { sendMouseDelta(dx, dy); } switch (event.getAction()) { + case MotionEvent.ACTION_MOVE: + Log.i(TAG, "Erroneous move event"); // should be in touch events + return true; case MotionEvent.ACTION_HOVER_MOVE: Log.i(TAG, "Action Hover Move"); // process the mouse hover movement... @@ -1115,6 +1126,9 @@ public abstract class NativeActivity extends Activity { case MotionEvent.ACTION_BUTTON_PRESS: { Log.i(TAG, "action button press: button: " + button); useModernMouseEvents = true; + if (button > 1) { + useModernMouseEventsB2 = true; + } NativeApp.mouse(event.getX(), event.getY(), button, 1); return true; } diff --git a/android/src/org/ppsspp/ppsspp/NativeGLView.java b/android/src/org/ppsspp/ppsspp/NativeGLView.java index 6b049e135d..8e8418a183 100644 --- a/android/src/org/ppsspp/ppsspp/NativeGLView.java +++ b/android/src/org/ppsspp/ppsspp/NativeGLView.java @@ -61,7 +61,6 @@ public class NativeGLView extends GLSurfaceView implements SensorEventListener, return ev.getToolType(pointer); } - @TargetApi(Build.VERSION_CODES.ICE_CREAM_SANDWICH_MR1) private void onMouseEventMotion(final MotionEvent ev) { switch (ev.getActionMasked()) { diff --git a/android/src/org/ppsspp/ppsspp/NativeSurfaceView.java b/android/src/org/ppsspp/ppsspp/NativeSurfaceView.java index 6cf6b44079..c0f9c23506 100644 --- a/android/src/org/ppsspp/ppsspp/NativeSurfaceView.java +++ b/android/src/org/ppsspp/ppsspp/NativeSurfaceView.java @@ -114,10 +114,6 @@ public class NativeSurfaceView extends SurfaceView implements SensorEventListene public boolean onTouchEvent(final MotionEvent ev) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH_MR1 && isFromSource(ev, InputDevice.SOURCE_MOUSE)) { // This is where workable mouse support arrived. - // Also, skip processing if useModernMouseEvents is on. - if (NativeActivity.useModernMouseEvents) { - return true; - } onMouseEventMotion(ev); return true; }