From 237d3c4c4b9d4ae1ee48ab812b83009761811604 Mon Sep 17 00:00:00 2001 From: Jens Arnold Date: Sun, 19 Feb 2006 13:34:12 +0000 Subject: Adaptive button repeat: adapts repeat rate depending on the ability of the application to cope. Avoids afterscroll and similar effects. * Yield while scrolling through lists. git-svn-id: svn://svn.rockbox.org/rockbox/trunk@8738 a1c6a512-1295-4272-9138-f99709370657 --- firmware/drivers/button.c | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) (limited to 'firmware/drivers') diff --git a/firmware/drivers/button.c b/firmware/drivers/button.c index 1cb9472e0f..c4c22641ca 100644 --- a/firmware/drivers/button.c +++ b/firmware/drivers/button.c @@ -365,6 +365,7 @@ static void button_tick(void) static int repeat_speed = REPEAT_INTERVAL_START; static int repeat_count = 0; static bool repeat = false; + static bool post = false; int diff; int btn; @@ -381,7 +382,6 @@ static void button_tick(void) /* only poll every X ticks */ if ( ++tick >= POLL_FREQUENCY ) { - bool post = false; btn = button_read(); /* Find out if a key has been released */ @@ -406,7 +406,8 @@ static void button_tick(void) { if ( repeat ) { - count--; + if (!post) + count--; if (count == 0) { post = true; /* yes we have repeat */ @@ -458,9 +459,18 @@ static void button_tick(void) if ( post ) { if (repeat) - queue_post(&button_queue, BUTTON_REPEAT | btn, NULL); + { + if (queue_empty(&button_queue)) + { + queue_post(&button_queue, BUTTON_REPEAT | btn, NULL); + post = false; + } + } else + { queue_post(&button_queue, btn, NULL); + post = false; + } #ifdef HAVE_REMOTE_LCD if(btn & BUTTON_REMOTE) remote_backlight_on(); -- cgit v1.2.3