From 6b8d020876f97a4af01d628ad0de251b103be01c Mon Sep 17 00:00:00 2001 From: Linus Nielsen Feltzing Date: Sat, 24 Jul 2004 20:38:56 +0000 Subject: Now doesn't generate extraneous key-down events when releasing one key in a combo git-svn-id: svn://svn.rockbox.org/rockbox/trunk@4939 a1c6a512-1295-4272-9138-f99709370657 --- firmware/drivers/button.c | 103 +++++++++++++++++++++++----------------------- 1 file changed, 52 insertions(+), 51 deletions(-) diff --git a/firmware/drivers/button.c b/firmware/drivers/button.c index 7e1ab47952..4bbc69f607 100644 --- a/firmware/drivers/button.c +++ b/firmware/drivers/button.c @@ -86,70 +86,71 @@ static void button_tick(void) { queue_post(&button_queue, BUTTON_REL | diff, NULL); } - - if ( btn ) + else { - /* normal keypress */ - if ( btn != lastbtn ) - { - post = true; - repeat = false; - repeat_speed = REPEAT_INTERVAL_START; - - } - else /* repeat? */ + if ( btn ) { - if ( repeat ) + /* normal keypress */ + if ( btn != lastbtn ) { - count--; - if (count == 0) { - post = true; - /* yes we have repeat */ - repeat_speed--; - if (repeat_speed < REPEAT_INTERVAL_FINISH) - repeat_speed = REPEAT_INTERVAL_FINISH; - count = repeat_speed; - - repeat_count++; - - /* Shutdown if we have a device which doesn't shut - down easily with the OFF key */ + post = true; + repeat = false; + repeat_speed = REPEAT_INTERVAL_START; + + } + else /* repeat? */ + { + if ( repeat ) + { + count--; + if (count == 0) { + post = true; + /* yes we have repeat */ + repeat_speed--; + if (repeat_speed < REPEAT_INTERVAL_FINISH) + repeat_speed = REPEAT_INTERVAL_FINISH; + count = repeat_speed; + + repeat_count++; + + /* Shutdown if we have a device which doesn't shut + down easily with the OFF key */ #ifdef HAVE_POWEROFF_ON_PB5 - if(btn == BUTTON_OFF && !charger_inserted() && - repeat_count > POWEROFF_COUNT) - power_off(); + if(btn == BUTTON_OFF && !charger_inserted() && + repeat_count > POWEROFF_COUNT) + power_off(); #endif + } } - } - else - { - if (count++ > REPEAT_START) + else { - post = true; - repeat = true; - repeat_count = 0; - /* initial repeat */ - count = REPEAT_INTERVAL_START; + if (count++ > REPEAT_START) + { + post = true; + repeat = true; + repeat_count = 0; + /* initial repeat */ + count = REPEAT_INTERVAL_START; + } } } + if ( post ) + { + if(repeat) + queue_post(&button_queue, BUTTON_REPEAT | btn, NULL); + else + queue_post(&button_queue, btn, NULL); + backlight_on(); + + reset_poweroff_timer(); + } } - if ( post ) + else { - if(repeat) - queue_post(&button_queue, BUTTON_REPEAT | btn, NULL); - else - queue_post(&button_queue, btn, NULL); - backlight_on(); - - reset_poweroff_timer(); + repeat = false; + count = 0; } } - else - { - repeat = false; - count = 0; - } - lastbtn = btn & ~(BUTTON_REL | BUTTON_REPEAT); tick = 0; } -- cgit v1.2.3