From 99a8a40990f0759cf73e568098c603efdb54cd2d Mon Sep 17 00:00:00 2001 From: Eric Linenberg Date: Thu, 5 Sep 2002 22:41:22 +0000 Subject: added button repeat acceleration git-svn-id: svn://svn.rockbox.org/rockbox/trunk@2193 a1c6a512-1295-4272-9138-f99709370657 --- firmware/drivers/button.c | 25 +++++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-) (limited to 'firmware/drivers/button.c') diff --git a/firmware/drivers/button.c b/firmware/drivers/button.c index 36cc0d2598..41d85aba87 100644 --- a/firmware/drivers/button.c +++ b/firmware/drivers/button.c @@ -31,9 +31,17 @@ struct event_queue button_queue; +/* how often we check to see if a button is pressed */ #define POLL_FREQUENCY HZ/20 + +/* how long until repeat kicks in */ #define REPEAT_START 6 -#define REPEAT_INTERVAL 4 + +/* the speed repeat starts at */ +#define REPEAT_INTERVAL_START 8 + +/* speed repeat finishes at */ +#define REPEAT_INTERVAL_FINISH 2 static int repeat_mask = DEFAULT_REPEAT_MASK; static int release_mask = DEFAULT_RELEASE_MASK; @@ -45,6 +53,7 @@ static void button_tick(void) static int tick=0; static int count=0; static int lastbtn=0; + static int repeat_speed=REPEAT_INTERVAL_START; static bool repeat=false; int diff; @@ -69,14 +78,21 @@ static void button_tick(void) { post = true; repeat = false; + repeat_speed = REPEAT_INTERVAL_START; + } else /* repeat? */ { if ( repeat ) { - if ( ! --count ) { + count--; + if (count == 0) { post = true; - count = REPEAT_INTERVAL; + /* yes we have repeat */ + repeat_speed--; + if (repeat_speed < REPEAT_INTERVAL_FINISH) + repeat_speed = REPEAT_INTERVAL_FINISH; + count = repeat_speed; } } else @@ -95,7 +111,8 @@ static void button_tick(void) { post = true; repeat = true; - count = REPEAT_INTERVAL; + /* initial repeat */ + count = REPEAT_INTERVAL_START; } /* If the OFF button is pressed long enough, and we are still alive, then the unit must be -- cgit v1.2.3