summaryrefslogtreecommitdiffstats
path: root/firmware/target/hosted
diff options
context:
space:
mode:
authorJonathan Gordon <rockbox@jdgordon.info>2010-10-24 12:35:53 +0000
committerJonathan Gordon <rockbox@jdgordon.info>2010-10-24 12:35:53 +0000
commit48e900ffe27849539384d784b2f332797a5c49bc (patch)
tree3a1acd2aeb5dce5c753ecabdc6667a142a06571c /firmware/target/hosted
parent7da04a0819047eb755824ef74edd23f56c5f4aed (diff)
downloadrockbox-48e900ffe27849539384d784b2f332797a5c49bc.tar.gz
rockbox-48e900ffe27849539384d784b2f332797a5c49bc.tar.bz2
rockbox-48e900ffe27849539384d784b2f332797a5c49bc.zip
Fix android hardware button handling so it actually works.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@28345 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'firmware/target/hosted')
-rw-r--r--firmware/target/hosted/android/button-android.c18
1 files changed, 11 insertions, 7 deletions
diff --git a/firmware/target/hosted/android/button-android.c b/firmware/target/hosted/android/button-android.c
index a7ac9baec8..c072e3e38b 100644
--- a/firmware/target/hosted/android/button-android.c
+++ b/firmware/target/hosted/android/button-android.c
@@ -31,12 +31,13 @@
static int last_y, last_x;
static int last_btns;
+static long last_button_tick;
static enum {
STATE_UNKNOWN,
STATE_UP,
STATE_DOWN,
-} last_state = STATE_UNKNOWN;
+} last_touch_state = STATE_UNKNOWN;
/*
* this notifies us in an interrupt-like fashion whether the user just
@@ -49,9 +50,9 @@ Java_org_rockbox_RockboxFramebuffer_touchHandler(JNIEnv*env, jobject this,
(void)this;
if (down)
- last_state = STATE_DOWN;
+ last_touch_state = STATE_DOWN;
else
- last_state = STATE_UP;
+ last_touch_state = STATE_UP;
last_x = x;
last_y = y;
@@ -73,15 +74,16 @@ Java_org_rockbox_RockboxFramebuffer_buttonHandler(JNIEnv*env, jobject this,
return false;
if (state)
+ {
last_btns |= button;
- else
- last_btns &= ~button;
-
+ last_button_tick = current_tick;
+ }
return true;
}
void button_init_device(void)
{
+ last_button_tick = 0;
}
int button_read_device(int *data)
@@ -94,8 +96,10 @@ int button_read_device(int *data)
* touchscreen_to_pixels() */
int touch = touchscreen_to_pixels(last_x, last_y, data);
- if (last_state == STATE_DOWN)
+ if (last_touch_state == STATE_DOWN)
btn |= touch;
+ if (TIME_AFTER(current_tick, last_button_tick+5))
+ last_btns = 0;
return btn;
}