From f160b1e69ffd8c0af1dafe95d7eee54f40145248 Mon Sep 17 00:00:00 2001 From: jdgordon Date: Sun, 24 Oct 2010 12:35:53 +0000 Subject: [PATCH] Fix android hardware button handling so it actually works. git-svn-id: svn://svn.rockbox.org/rockbox/trunk@28345 a1c6a512-1295-4272-9138-f99709370657 --- firmware/target/hosted/android/button-android.c | 18 +++++++++++------- 1 file 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; } -- 2.11.4.GIT