1
0
Fork 0
forked from len0rd/rockbox

added button repeat acceleration

git-svn-id: svn://svn.rockbox.org/rockbox/trunk@2193 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
Eric Linenberg 2002-09-05 22:41:22 +00:00
parent 6599063a66
commit 99a8a40990

View file

@ -31,9 +31,17 @@
struct event_queue button_queue; struct event_queue button_queue;
/* how often we check to see if a button is pressed */
#define POLL_FREQUENCY HZ/20 #define POLL_FREQUENCY HZ/20
/* how long until repeat kicks in */
#define REPEAT_START 6 #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 repeat_mask = DEFAULT_REPEAT_MASK;
static int release_mask = DEFAULT_RELEASE_MASK; static int release_mask = DEFAULT_RELEASE_MASK;
@ -45,6 +53,7 @@ static void button_tick(void)
static int tick=0; static int tick=0;
static int count=0; static int count=0;
static int lastbtn=0; static int lastbtn=0;
static int repeat_speed=REPEAT_INTERVAL_START;
static bool repeat=false; static bool repeat=false;
int diff; int diff;
@ -69,14 +78,21 @@ static void button_tick(void)
{ {
post = true; post = true;
repeat = false; repeat = false;
repeat_speed = REPEAT_INTERVAL_START;
} }
else /* repeat? */ else /* repeat? */
{ {
if ( repeat ) if ( repeat )
{ {
if ( ! --count ) { count--;
if (count == 0) {
post = true; 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 else
@ -95,7 +111,8 @@ static void button_tick(void)
{ {
post = true; post = true;
repeat = true; repeat = true;
count = REPEAT_INTERVAL; /* initial repeat */
count = REPEAT_INTERVAL_START;
} }
/* If the OFF button is pressed long enough, /* If the OFF button is pressed long enough,
and we are still alive, then the unit must be and we are still alive, then the unit must be