--- rockbox.svn/android/src/org/rockbox/RockboxFramebuffer.java 2011-01-30 00:53:07.000000000 -0600 +++ rockbox.fixes/android/src/org/rockbox/RockboxFramebuffer.java 2011-01-30 01:21:27.000000000 -0600 @@ -44,6 +44,7 @@ private MediaButtonReceiver media_monitor; private final DisplayMetrics metrics; private final ViewConfiguration view_config; + private int wasKeypressed = 0; public RockboxFramebuffer(Context c, int lcd_width, int lcd_height, ByteBuffer native_fb) @@ -102,11 +103,17 @@ public boolean onKeyDown(int keyCode, KeyEvent event) { - return buttonHandler(keyCode, true); + if (wasKeypressed == 0) /* only lets one press through at a time. */ + { + wasKeypressed = 1; + return buttonHandler(keyCode, true); + } + return true; } public boolean onKeyUp(int keyCode, KeyEvent event) { + wasKeypressed = 0; return buttonHandler(keyCode, false); } diff -Naur rockbox.svn/firmware/target/hosted/android/app/button-application.c rockbox.clean/firmware/target/hosted/android/app/button-application.c --- rockbox.svn/firmware/target/hosted/android/app/button-application.c 2011-01-27 04:37:48.000000000 -0600 +++ rockbox.clean/firmware/target/hosted/android/app/button-application.c 2011-01-29 10:24:37.000000000 -0600 @@ -39,6 +39,14 @@ return BUTTON_MENU; case KEYCODE_DPAD_CENTER: return BUTTON_DPAD_CENTER; + case KEYCODE_DPAD_UP: + return BUTTON_DPAD_UP; + case KEYCODE_DPAD_DOWN: + return BUTTON_DPAD_DOWN; + case KEYCODE_DPAD_LEFT: + return BUTTON_DPAD_LEFT; + case KEYCODE_DPAD_RIGHT: + return BUTTON_DPAD_RIGHT; default: return BUTTON_NONE; } @@ -64,25 +72,4 @@ return 0; } } - -unsigned dpad_to_button(int keyboard_key) -{ - switch (keyboard_key) - { - /* These buttons only post a single release event. - * doing otherwise will cause action.c to lock up waiting for - * a release (because android sends press/unpress to us too quickly - */ - case KEYCODE_DPAD_UP: - return BUTTON_DPAD_UP|BUTTON_REL; - case KEYCODE_DPAD_DOWN: - return BUTTON_DPAD_DOWN|BUTTON_REL; - case KEYCODE_DPAD_LEFT: - return BUTTON_DPAD_LEFT|BUTTON_REL; - case KEYCODE_DPAD_RIGHT: - return BUTTON_DPAD_RIGHT|BUTTON_REL; - default: - return BUTTON_NONE; - } -} - + diff -Naur rockbox.svn/firmware/target/hosted/android/button-android.c rockbox.clean/firmware/target/hosted/android/button-android.c --- rockbox.svn/firmware/target/hosted/android/button-android.c 2011-01-27 04:37:48.000000000 -0600 +++ rockbox.clean/firmware/target/hosted/android/button-android.c 2011-01-29 10:38:57.000000000 -0600 @@ -69,37 +69,32 @@ unsigned button = 0; - if (!state) + if (state) /* on key press */ { - button = multimedia_to_button((int)keycode); - if (!button) - button = dpad_to_button((int)keycode); - if (button) - queue_post(&button_queue, button, 0); + button = multimedia_to_button(keycode); /* is it a media key? */ + if (!button) /* if it was not a media key it might be a key we use */ + { + button = key_to_button(keycode); /* is it a key we use? */ + if (button == BUTTON_NONE) /* if key is BUTTON_NONE exit */ + { + last_btns = 0; /* clear and pass last button so touch stays sane */ + return false; /* we did not handle the key press */ + } + queue_post(&button_queue, button, 0); /* if we made it here post key to queue */ + } + last_btns = button; /* pass last button so touch stays sane */ + return true; /* yes we handle it */ } - if (!button) - { - button = key_to_button(keycode); - } - - if (button == BUTTON_NONE) + if (!state) /* on key release */ { - last_btns = button; - return false; + last_btns = 0; /* clear and pass last button so touch stays sane */ + queue_post(&button_queue, BUTTON_REL, 0); /* put a button release in the buffer */ + return true; /* yes we handled it */ } - if (state) - { - last_btns |= button; - } - else - { - last_btns &= (~button); - return false; - } - - return true; + return false; /* we did not handle a press or release, suppresses a warning */ + } void button_init_device(void)