diff options
author | Eric Linenberg <elinenbe@umich.edu> | 2002-09-05 22:41:22 +0000 |
---|---|---|
committer | Eric Linenberg <elinenbe@umich.edu> | 2002-09-05 22:41:22 +0000 |
commit | 99a8a40990f0759cf73e568098c603efdb54cd2d (patch) | |
tree | cc98a5215840eb4f1229a584c8df576ed639d099 /firmware | |
parent | 6599063a6626357f12db8635ad9801fb5f82e5b9 (diff) | |
download | rockbox-99a8a40990f0759cf73e568098c603efdb54cd2d.tar.gz rockbox-99a8a40990f0759cf73e568098c603efdb54cd2d.zip |
added button repeat acceleration
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@2193 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'firmware')
-rw-r--r-- | firmware/drivers/button.c | 25 |
1 files changed, 21 insertions, 4 deletions
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 @@ | |||
31 | 31 | ||
32 | struct event_queue button_queue; | 32 | struct event_queue button_queue; |
33 | 33 | ||
34 | /* how often we check to see if a button is pressed */ | ||
34 | #define POLL_FREQUENCY HZ/20 | 35 | #define POLL_FREQUENCY HZ/20 |
36 | |||
37 | /* how long until repeat kicks in */ | ||
35 | #define REPEAT_START 6 | 38 | #define REPEAT_START 6 |
36 | #define REPEAT_INTERVAL 4 | 39 | |
40 | /* the speed repeat starts at */ | ||
41 | #define REPEAT_INTERVAL_START 8 | ||
42 | |||
43 | /* speed repeat finishes at */ | ||
44 | #define REPEAT_INTERVAL_FINISH 2 | ||
37 | 45 | ||
38 | static int repeat_mask = DEFAULT_REPEAT_MASK; | 46 | static int repeat_mask = DEFAULT_REPEAT_MASK; |
39 | static int release_mask = DEFAULT_RELEASE_MASK; | 47 | static int release_mask = DEFAULT_RELEASE_MASK; |
@@ -45,6 +53,7 @@ static void button_tick(void) | |||
45 | static int tick=0; | 53 | static int tick=0; |
46 | static int count=0; | 54 | static int count=0; |
47 | static int lastbtn=0; | 55 | static int lastbtn=0; |
56 | static int repeat_speed=REPEAT_INTERVAL_START; | ||
48 | static bool repeat=false; | 57 | static bool repeat=false; |
49 | int diff; | 58 | int diff; |
50 | 59 | ||
@@ -69,14 +78,21 @@ static void button_tick(void) | |||
69 | { | 78 | { |
70 | post = true; | 79 | post = true; |
71 | repeat = false; | 80 | repeat = false; |
81 | repeat_speed = REPEAT_INTERVAL_START; | ||
82 | |||
72 | } | 83 | } |
73 | else /* repeat? */ | 84 | else /* repeat? */ |
74 | { | 85 | { |
75 | if ( repeat ) | 86 | if ( repeat ) |
76 | { | 87 | { |
77 | if ( ! --count ) { | 88 | count--; |
89 | if (count == 0) { | ||
78 | post = true; | 90 | post = true; |
79 | count = REPEAT_INTERVAL; | 91 | /* yes we have repeat */ |
92 | repeat_speed--; | ||
93 | if (repeat_speed < REPEAT_INTERVAL_FINISH) | ||
94 | repeat_speed = REPEAT_INTERVAL_FINISH; | ||
95 | count = repeat_speed; | ||
80 | } | 96 | } |
81 | } | 97 | } |
82 | else | 98 | else |
@@ -95,7 +111,8 @@ static void button_tick(void) | |||
95 | { | 111 | { |
96 | post = true; | 112 | post = true; |
97 | repeat = true; | 113 | repeat = true; |
98 | count = REPEAT_INTERVAL; | 114 | /* initial repeat */ |
115 | count = REPEAT_INTERVAL_START; | ||
99 | } | 116 | } |
100 | /* If the OFF button is pressed long enough, | 117 | /* If the OFF button is pressed long enough, |
101 | and we are still alive, then the unit must be | 118 | and we are still alive, then the unit must be |