summaryrefslogtreecommitdiff
path: root/firmware/drivers/button.c
diff options
context:
space:
mode:
authorEric Linenberg <elinenbe@umich.edu>2002-09-05 22:41:22 +0000
committerEric Linenberg <elinenbe@umich.edu>2002-09-05 22:41:22 +0000
commit99a8a40990f0759cf73e568098c603efdb54cd2d (patch)
treecc98a5215840eb4f1229a584c8df576ed639d099 /firmware/drivers/button.c
parent6599063a6626357f12db8635ad9801fb5f82e5b9 (diff)
downloadrockbox-99a8a40990f0759cf73e568098c603efdb54cd2d.zip
rockbox-99a8a40990f0759cf73e568098c603efdb54cd2d.tar.gz
rockbox-99a8a40990f0759cf73e568098c603efdb54cd2d.tar.bz2
rockbox-99a8a40990f0759cf73e568098c603efdb54cd2d.tar.xz
added button repeat acceleration
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@2193 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'firmware/drivers/button.c')
-rw-r--r--firmware/drivers/button.c25
1 files changed, 21 insertions, 4 deletions
diff --git a/firmware/drivers/button.c b/firmware/drivers/button.c
index 36cc0d2..41d85ab 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