aboutsummaryrefslogtreecommitdiff
path: root/backends/platform/android
diff options
context:
space:
mode:
authordhewg2011-03-17 20:48:44 +0100
committerdhewg2011-03-17 21:01:49 +0100
commit8953581ec9dcde966ec7a5e2e7f2c37a4cf4d109 (patch)
tree66ca6188aaf61b70c824ccd5405115534c16d61b /backends/platform/android
parent563ac93c166f31864c2bcaa9e99e71e2c5882910 (diff)
downloadscummvm-rg350-8953581ec9dcde966ec7a5e2e7f2c37a4cf4d109.tar.gz
scummvm-rg350-8953581ec9dcde966ec7a5e2e7f2c37a4cf4d109.tar.bz2
scummvm-rg350-8953581ec9dcde966ec7a5e2e7f2c37a4cf4d109.zip
ANDROID: Ignore the slop area on all touch scrolls
Prevents initial cursor jumps
Diffstat (limited to 'backends/platform/android')
-rw-r--r--backends/platform/android/android.cpp1
-rw-r--r--backends/platform/android/android.h2
-rw-r--r--backends/platform/android/events.cpp23
-rw-r--r--backends/platform/android/org/inodes/gus/scummvm/ScummVMEvents.java7
4 files changed, 23 insertions, 10 deletions
diff --git a/backends/platform/android/android.cpp b/backends/platform/android/android.cpp
index 483b37310a..cf711301fa 100644
--- a/backends/platform/android/android.cpp
+++ b/backends/platform/android/android.cpp
@@ -122,6 +122,7 @@ OSystem_Android::OSystem_Android(int audio_sample_rate, int audio_buffer_size) :
_shake_offset(0),
_event_queue_lock(createMutex()),
_touch_pt_down(),
+ _touch_pt_scroll(),
_touch_pt_dt(),
_eventScaleX(100),
_eventScaleY(100),
diff --git a/backends/platform/android/android.h b/backends/platform/android/android.h
index 7ff96186f9..839b3f01c1 100644
--- a/backends/platform/android/android.h
+++ b/backends/platform/android/android.h
@@ -209,7 +209,7 @@ private:
Common::Queue<Common::Event> _event_queue;
MutexRef _event_queue_lock;
- Common::Point _touch_pt_down, _touch_pt_dt;
+ Common::Point _touch_pt_down, _touch_pt_scroll, _touch_pt_dt;
int _eventScaleX;
int _eventScaleY;
bool _touchpad_mode;
diff --git a/backends/platform/android/events.cpp b/backends/platform/android/events.cpp
index b8e8d8e69c..cab09e04dd 100644
--- a/backends/platform/android/events.cpp
+++ b/backends/platform/android/events.cpp
@@ -444,13 +444,22 @@ void OSystem_Android::pushEvent(int type, int arg1, int arg2, int arg3,
case JE_DOWN:
_touch_pt_down = getEventManager()->getMousePos();
+ _touch_pt_scroll.x = -1;
+ _touch_pt_scroll.y = -1;
break;
case JE_SCROLL:
e.type = Common::EVENT_MOUSEMOVE;
if (_touchpad_mode) {
- scaleMouse(e.mouse, arg3 - arg1, arg4 - arg2, false);
+ if (_touch_pt_scroll.x == -1 && _touch_pt_scroll.y == -1) {
+ _touch_pt_scroll.x = arg3;
+ _touch_pt_scroll.y = arg4;
+ return;
+ }
+
+ scaleMouse(e.mouse, arg3 - _touch_pt_scroll.x,
+ arg4 - _touch_pt_scroll.y, false);
e.mouse += _touch_pt_down;
clipMouse(e.mouse);
} else {
@@ -520,14 +529,20 @@ void OSystem_Android::pushEvent(int type, int arg1, int arg2, int arg3,
switch (arg3) {
case JACTION_DOWN:
dptype = Common::EVENT_LBUTTONDOWN;
- _touch_pt_dt.x = arg1;
- _touch_pt_dt.y = arg2;
+ _touch_pt_dt.x = -1;
+ _touch_pt_dt.y = -1;
break;
case JACTION_UP:
dptype = Common::EVENT_LBUTTONUP;
break;
+ // held and moved
case JACTION_MULTIPLE:
- // held and moved
+ if (_touch_pt_dt.x == -1 && _touch_pt_dt.y == -1) {
+ _touch_pt_dt.x = arg1;
+ _touch_pt_dt.y = arg2;
+ return;
+ }
+
dptype = Common::EVENT_MOUSEMOVE;
if (_touchpad_mode) {
diff --git a/backends/platform/android/org/inodes/gus/scummvm/ScummVMEvents.java b/backends/platform/android/org/inodes/gus/scummvm/ScummVMEvents.java
index 3d3fdeece4..7507d7e5fc 100644
--- a/backends/platform/android/org/inodes/gus/scummvm/ScummVMEvents.java
+++ b/backends/platform/android/org/inodes/gus/scummvm/ScummVMEvents.java
@@ -31,7 +31,6 @@ public class ScummVMEvents implements
final protected ScummVM _scummvm;
final protected GestureDetector _gd;
final protected int _longPress;
- final protected int _slop;
public ScummVMEvents(Context context, ScummVM scummvm) {
_context = context;
@@ -42,8 +41,6 @@ public class ScummVMEvents implements
_gd.setIsLongpressEnabled(false);
_longPress = ViewConfiguration.getLongPressTimeout();
- _slop = ViewConfiguration.get(context).getScaledTouchSlop();
-
}
final public void sendQuitEvent() {
@@ -167,7 +164,7 @@ public class ScummVMEvents implements
final public boolean onScroll(MotionEvent e1, MotionEvent e2,
float distanceX, float distanceY) {
_scummvm.pushEvent(JE_SCROLL, (int)e1.getX(), (int)e1.getY(),
- (int)e2.getX(), (int)e2.getY(), _slop);
+ (int)e2.getX(), (int)e2.getY(), 0);
return true;
}
@@ -189,7 +186,7 @@ public class ScummVMEvents implements
final public boolean onDoubleTapEvent(MotionEvent e) {
_scummvm.pushEvent(JE_DOUBLE_TAP, (int)e.getX(), (int)e.getY(),
- e.getAction(), _slop, 0);
+ e.getAction(), 0, 0);
return true;
}