diff options
author | Maurus Cuelenaere <mcuelenaere@gmail.com> | 2010-08-16 20:12:10 +0000 |
---|---|---|
committer | Maurus Cuelenaere <mcuelenaere@gmail.com> | 2010-08-16 20:12:10 +0000 |
commit | 5068891477a7890bef94092fd184f7b30aa17b9d (patch) | |
tree | 5c51141221c2e444143a0bae42fb8b82bb348c69 | |
parent | 934a5a5808c7a0b0dff469ad2c3a523e78a4ef4b (diff) | |
download | rockbox-5068891477a7890bef94092fd184f7b30aa17b9d.tar.gz rockbox-5068891477a7890bef94092fd184f7b30aa17b9d.zip |
Android port: simplify sending touch events from Java->C
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@27833 a1c6a512-1295-4272-9138-f99709370657
-rw-r--r-- | android/src/org/rockbox/RockboxFramebuffer.java | 19 | ||||
-rw-r--r-- | firmware/target/hosted/android/button-android.c | 21 |
2 files changed, 16 insertions, 24 deletions
diff --git a/android/src/org/rockbox/RockboxFramebuffer.java b/android/src/org/rockbox/RockboxFramebuffer.java index 1734b4fab1..6d11e1af14 100644 --- a/android/src/org/rockbox/RockboxFramebuffer.java +++ b/android/src/org/rockbox/RockboxFramebuffer.java | |||
@@ -80,20 +80,22 @@ public class RockboxFramebuffer extends View | |||
80 | 80 | ||
81 | public boolean onTouchEvent(MotionEvent me) | 81 | public boolean onTouchEvent(MotionEvent me) |
82 | { | 82 | { |
83 | int x = (int) me.getX(); | ||
84 | int y = (int) me.getY(); | ||
85 | |||
83 | switch (me.getAction()) | 86 | switch (me.getAction()) |
84 | { | 87 | { |
85 | case MotionEvent.ACTION_CANCEL: | 88 | case MotionEvent.ACTION_CANCEL: |
86 | case MotionEvent.ACTION_UP: | 89 | case MotionEvent.ACTION_UP: |
87 | touchHandler(0); | 90 | touchHandler(false, x, y); |
88 | break; | 91 | return true; |
89 | case MotionEvent.ACTION_MOVE: | 92 | case MotionEvent.ACTION_MOVE: |
90 | case MotionEvent.ACTION_DOWN: | 93 | case MotionEvent.ACTION_DOWN: |
91 | touchHandler(1); | 94 | touchHandler(true, x, y); |
92 | break; | 95 | return true; |
93 | |||
94 | } | 96 | } |
95 | pixelHandler((int)me.getX(), (int)me.getY()); | 97 | |
96 | return true; | 98 | return false; |
97 | } | 99 | } |
98 | 100 | ||
99 | public boolean onKeyDown(int keyCode, KeyEvent event) | 101 | public boolean onKeyDown(int keyCode, KeyEvent event) |
@@ -118,7 +120,6 @@ public class RockboxFramebuffer extends View | |||
118 | } | 120 | } |
119 | 121 | ||
120 | public native void set_lcd_active(int active); | 122 | public native void set_lcd_active(int active); |
121 | public native void pixelHandler(int x, int y); | 123 | public native void touchHandler(boolean down, int x, int y); |
122 | public native void touchHandler(int down); | ||
123 | public native boolean buttonHandler(int keycode, boolean state); | 124 | public native boolean buttonHandler(int keycode, boolean state); |
124 | } | 125 | } |
diff --git a/firmware/target/hosted/android/button-android.c b/firmware/target/hosted/android/button-android.c index 50e347e714..a7ac9baec8 100644 --- a/firmware/target/hosted/android/button-android.c +++ b/firmware/target/hosted/android/button-android.c | |||
@@ -39,31 +39,22 @@ static enum { | |||
39 | } last_state = STATE_UNKNOWN; | 39 | } last_state = STATE_UNKNOWN; |
40 | 40 | ||
41 | /* | 41 | /* |
42 | * this writes in an interrupt-like fashion the last pixel coordinates | ||
43 | * that the user pressed on the screen */ | ||
44 | JNIEXPORT void JNICALL | ||
45 | Java_org_rockbox_RockboxFramebuffer_pixelHandler(JNIEnv*env, jobject this, | ||
46 | int x, int y) | ||
47 | { | ||
48 | (void)env; | ||
49 | (void)this; | ||
50 | last_x = x; | ||
51 | last_y = y; | ||
52 | } | ||
53 | |||
54 | /* | ||
55 | * this notifies us in an interrupt-like fashion whether the user just | 42 | * this notifies us in an interrupt-like fashion whether the user just |
56 | * began or stopped the touch action */ | 43 | * began or stopped the touch action + where (pixel coordinates) */ |
57 | JNIEXPORT void JNICALL | 44 | JNIEXPORT void JNICALL |
58 | Java_org_rockbox_RockboxFramebuffer_touchHandler(JNIEnv*env, jobject this, | 45 | Java_org_rockbox_RockboxFramebuffer_touchHandler(JNIEnv*env, jobject this, |
59 | int down) | 46 | bool down, int x, int y) |
60 | { | 47 | { |
61 | (void)env; | 48 | (void)env; |
62 | (void)this; | 49 | (void)this; |
50 | |||
63 | if (down) | 51 | if (down) |
64 | last_state = STATE_DOWN; | 52 | last_state = STATE_DOWN; |
65 | else | 53 | else |
66 | last_state = STATE_UP; | 54 | last_state = STATE_UP; |
55 | |||
56 | last_x = x; | ||
57 | last_y = y; | ||
67 | } | 58 | } |
68 | 59 | ||
69 | /* | 60 | /* |