aboutsummaryrefslogtreecommitdiff
path: root/backends
diff options
context:
space:
mode:
authorLauri Härsilä2012-10-21 06:29:36 +0300
committerLauri Härsilä2012-10-21 06:29:36 +0300
commitfc15e1c207c64e64eda6eb9e0e1b3a6e0f462c1d (patch)
treeada69439e57e268c9fe9e90eaef077d3e88b548d /backends
parentb25ed0a02f22aa1bcee826c6843870b299b0c1ed (diff)
downloadscummvm-rg350-fc15e1c207c64e64eda6eb9e0e1b3a6e0f462c1d.tar.gz
scummvm-rg350-fc15e1c207c64e64eda6eb9e0e1b3a6e0f462c1d.tar.bz2
scummvm-rg350-fc15e1c207c64e64eda6eb9e0e1b3a6e0f462c1d.zip
ANDROID: Fixed tapping touchpad not sending left clicks
Diffstat (limited to 'backends')
-rw-r--r--backends/platform/android/org/scummvm/scummvm/MouseHelper.java95
-rw-r--r--backends/platform/android/org/scummvm/scummvm/ScummVMEvents.java2
2 files changed, 6 insertions, 91 deletions
diff --git a/backends/platform/android/org/scummvm/scummvm/MouseHelper.java b/backends/platform/android/org/scummvm/scummvm/MouseHelper.java
index ae30bcd1da..999815593f 100644
--- a/backends/platform/android/org/scummvm/scummvm/MouseHelper.java
+++ b/backends/platform/android/org/scummvm/scummvm/MouseHelper.java
@@ -7,91 +7,6 @@ import android.view.View;
/**
* Contains helper methods for mouse/hover events that were introduced in Android 4.0.
- *
- * Mouse (hover) events seem to be a bit arbitrary, so here's couple of scenarios:
- *
- *
- * 1. Galaxy Note 2 (4.1) + stylus:
- * Tool type: TOOL_TYPE_STYLUS
- *
- * Key: 238 ACTION_DOWN (once)
- * Key: 238 ACTION_UP (once)
- * Hover: ACTION_HOVER_ENTER (once)
- * Hover: ACTION_HOVER_MOVE (multiple, while hovering)
- *
- * touch screen with the pen:
- * Hover: ACTION_HOVER_EXIT, ButtonState: 0 (once)
- * Touch: ACTION_DOWN, ButtonState: 0 (once)
- * Touch: ACTION_MOVE, ButtonState: 0 (multiple, while pressing)
- * Touch: ACTION_UP, ButtonState: 0 (once)
- * Hover: ACTION_HOVER_ENTER (once)
- *
- * press the stylus button while hovering:
- * Hover: ACTION_HOVER_MOVE, ButtonState: 2 (multiple, while pressing button)
- * Hover: ACTION_HOVER_MOVE, ButtonState: 0 (multiple, after release)
- *
- *
- * 2. Galaxy Note 2 (4.1) + mouse (usb):
- * Tool type: TOOL_TYPE_MOUSE
- *
- * Hover: ACTION_HOVER_ENTER (once)
- * Hover: ACTION_HOVER_MOVE (multiple, while hovering)
- *
- * press left button:
- * Hover: ACTION_HOVER_EXIT, ButtonState: 1 (once)
- * Touch: ACTION_DOWN, ButtonState: 1 (once)
- * Touch: ACTION_MOVE, ButtonState: 1 (multiple, while pressing)
- * Touch: ACTION_UP, ButtonState: 0 (once)
- * Hover: ACTION_HOVER_ENTER, ButtonState: 0 (once)
- *
- * press right button:
- * Key: KEYCODE_BACK, ACTION_DOWN
- * Hover: ACTION_HOVER_MOVE, ButtonState: 2 (multiple, while pressing button)
- * Hover: ACTION_HOVER_MOVE, ButtonState: 0 (once)
- * Key: KEYCODE_BACK, ACTION_UP
- *
- *
- * 3. Asus eeePad Transformer Prime running CyanogenMod 10 (Android 4.1) + mouse (usb):
- * Tool type: TOOL_TYPE_MOUSE
- *
- * Hover: ACTION_HOVER_ENTER (once)
- * Hover: ACTION_HOVER_MOVE (multiple, while hovering)
- *
- * press left button:
- * Hover: ACTION_HOVER_EXIT, ButtonState: 1 (once)
- * Touch: ACTION_DOWN, ButtonState: 1 (once)
- * Touch: ACTION_MOVE, ButtonState: 1 (multiple, while pressing)
- * Touch: ACTION_UP, ButtonState: 0 (once)
- * Hover: ACTION_HOVER_ENTER, ButtonState: 0 (once)
- *
- * press right button:
- * Hover: ACTION_HOVER_EXIT, ButtonState: 2 (once)
- * Touch: ACTION_DOWN, ButtonState: 2 (once)
- * Touch: ACTION_MOVE, ButtonState: 2 (multiple, while pressing)
- * Touch: ACTION_UP, ButtonState: 0 (once)
- * Hover: ACTION_HOVER_ENTER, ButtonState: 0 (once)
- *
- *
- * 4. Asus eeePad Transformer Prime running CyanogenMod 10 (Android 4.1) + touchpad:
- * Tool type: TOOL_TYPE_FINGER
- *
- * Hover: ACTION_HOVER_ENTER (once)
- * Hover: ACTION_HOVER_MOVE (multiple, while hovering)
- *
- * press left button:
- * Hover: ACTION_HOVER_EXIT, ButtonState: 1 (once)
- * Touch: ACTION_DOWN, ButtonState: 1 (once)
- * Touch: ACTION_MOVE, ButtonState: 1 (multiple, while pressing)
- * Touch: ACTION_UP, ButtonState: 0 (once)
- * Hover: ACTION_HOVER_ENTER, ButtonState: 0 (once)
- *
- * press right button:
- * Hover: ACTION_HOVER_EXIT, ButtonState: 2 (once)
- * Touch: ACTION_DOWN, ButtonState: 2 (once)
- * Touch: ACTION_MOVE, ButtonState: 2 (multiple, while pressing)
- * Touch: ACTION_UP, ButtonState: 0 (once)
- * Hover: ACTION_HOVER_ENTER, ButtonState: 0 (once)
- *
*/
public class MouseHelper {
private View.OnHoverListener _listener;
@@ -126,7 +41,7 @@ public class MouseHelper {
return new View.OnHoverListener() {
@Override
public boolean onHover(View view, MotionEvent e) {
- return onTouch(e, true);
+ return onMouseEvent(e, true);
}
};
}
@@ -153,16 +68,16 @@ public class MouseHelper {
((sources & InputDevice.SOURCE_TOUCHPAD) == InputDevice.SOURCE_TOUCHPAD);
}
- public boolean onTouch(MotionEvent e, boolean hover) {
+ public boolean onMouseEvent(MotionEvent e, boolean hover) {
_scummvm.pushEvent(ScummVMEvents.JE_MOUSE_MOVE, (int)e.getX(), (int)e.getY(), 0, 0, 0);
int buttonState = e.getButtonState();
boolean lmbDown = (buttonState & MotionEvent.BUTTON_PRIMARY) == MotionEvent.BUTTON_PRIMARY;
- if (e.getToolType(0) == MotionEvent.TOOL_TYPE_STYLUS) {
- // when using stylus, ButtonState is 0
- lmbDown = !hover;
+ if (!hover && e.getAction() != MotionEvent.ACTION_UP && buttonState == 0) {
+ // On some device types, ButtonState is 0 even when tapping on the touchpad or using the stylus on the screen etc.
+ lmbDown = true;
}
if (lmbDown) {
diff --git a/backends/platform/android/org/scummvm/scummvm/ScummVMEvents.java b/backends/platform/android/org/scummvm/scummvm/ScummVMEvents.java
index 45c1f8bcb5..5f51ffac6c 100644
--- a/backends/platform/android/org/scummvm/scummvm/ScummVMEvents.java
+++ b/backends/platform/android/org/scummvm/scummvm/ScummVMEvents.java
@@ -193,7 +193,7 @@ public class ScummVMEvents implements
boolean isMouse = MouseHelper.isMouse(e);
if (isMouse) {
// mouse button is pressed
- return _mouseHelper.onTouch(e, false);
+ return _mouseHelper.onMouseEvent(e, false);
}
}