forked from len0rd/rockbox
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
This commit is contained in:
parent
1b45b130dc
commit
237d3c4c4b
5 changed files with 52 additions and 11 deletions
|
|
@ -604,6 +604,7 @@ unsigned gui_synclist_do_button(struct gui_synclist * lists, unsigned button)
|
||||||
#endif
|
#endif
|
||||||
gui_synclist_select_previous(lists);
|
gui_synclist_select_previous(lists);
|
||||||
gui_synclist_draw(lists);
|
gui_synclist_draw(lists);
|
||||||
|
yield();
|
||||||
return LIST_PREV;
|
return LIST_PREV;
|
||||||
|
|
||||||
case LIST_NEXT:
|
case LIST_NEXT:
|
||||||
|
|
@ -619,6 +620,7 @@ unsigned gui_synclist_do_button(struct gui_synclist * lists, unsigned button)
|
||||||
#endif
|
#endif
|
||||||
gui_synclist_select_next(lists);
|
gui_synclist_select_next(lists);
|
||||||
gui_synclist_draw(lists);
|
gui_synclist_draw(lists);
|
||||||
|
yield();
|
||||||
return LIST_NEXT;
|
return LIST_NEXT;
|
||||||
|
|
||||||
#ifdef LIST_PGRIGHT
|
#ifdef LIST_PGRIGHT
|
||||||
|
|
|
||||||
|
|
@ -365,6 +365,7 @@ static void button_tick(void)
|
||||||
static int repeat_speed = REPEAT_INTERVAL_START;
|
static int repeat_speed = REPEAT_INTERVAL_START;
|
||||||
static int repeat_count = 0;
|
static int repeat_count = 0;
|
||||||
static bool repeat = false;
|
static bool repeat = false;
|
||||||
|
static bool post = false;
|
||||||
int diff;
|
int diff;
|
||||||
int btn;
|
int btn;
|
||||||
|
|
||||||
|
|
@ -381,7 +382,6 @@ static void button_tick(void)
|
||||||
/* only poll every X ticks */
|
/* only poll every X ticks */
|
||||||
if ( ++tick >= POLL_FREQUENCY )
|
if ( ++tick >= POLL_FREQUENCY )
|
||||||
{
|
{
|
||||||
bool post = false;
|
|
||||||
btn = button_read();
|
btn = button_read();
|
||||||
|
|
||||||
/* Find out if a key has been released */
|
/* Find out if a key has been released */
|
||||||
|
|
@ -406,7 +406,8 @@ static void button_tick(void)
|
||||||
{
|
{
|
||||||
if ( repeat )
|
if ( repeat )
|
||||||
{
|
{
|
||||||
count--;
|
if (!post)
|
||||||
|
count--;
|
||||||
if (count == 0) {
|
if (count == 0) {
|
||||||
post = true;
|
post = true;
|
||||||
/* yes we have repeat */
|
/* yes we have repeat */
|
||||||
|
|
@ -458,9 +459,18 @@ static void button_tick(void)
|
||||||
if ( post )
|
if ( post )
|
||||||
{
|
{
|
||||||
if (repeat)
|
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
|
else
|
||||||
|
{
|
||||||
queue_post(&button_queue, btn, NULL);
|
queue_post(&button_queue, btn, NULL);
|
||||||
|
post = false;
|
||||||
|
}
|
||||||
#ifdef HAVE_REMOTE_LCD
|
#ifdef HAVE_REMOTE_LCD
|
||||||
if(btn & BUTTON_REMOTE)
|
if(btn & BUTTON_REMOTE)
|
||||||
remote_backlight_on();
|
remote_backlight_on();
|
||||||
|
|
|
||||||
|
|
@ -39,7 +39,6 @@ static int btn = 0; /* Hopefully keeps track of currently pressed keys... */
|
||||||
|
|
||||||
void button_event(int key, bool pressed)
|
void button_event(int key, bool pressed)
|
||||||
{
|
{
|
||||||
bool post = false;
|
|
||||||
int new_btn = 0;
|
int new_btn = 0;
|
||||||
int diff = 0;
|
int diff = 0;
|
||||||
static int count = 0;
|
static int count = 0;
|
||||||
|
|
@ -47,6 +46,7 @@ void button_event(int key, bool pressed)
|
||||||
static int repeat_speed = REPEAT_INTERVAL_START;
|
static int repeat_speed = REPEAT_INTERVAL_START;
|
||||||
static int repeat_count = 0;
|
static int repeat_count = 0;
|
||||||
static bool repeat = false;
|
static bool repeat = false;
|
||||||
|
static bool post = false;
|
||||||
|
|
||||||
switch (key)
|
switch (key)
|
||||||
{
|
{
|
||||||
|
|
@ -175,7 +175,8 @@ void button_event(int key, bool pressed)
|
||||||
{
|
{
|
||||||
if ( repeat )
|
if ( repeat )
|
||||||
{
|
{
|
||||||
count--;
|
if (!post)
|
||||||
|
count--;
|
||||||
if (count == 0)
|
if (count == 0)
|
||||||
{
|
{
|
||||||
post = true;
|
post = true;
|
||||||
|
|
@ -203,9 +204,18 @@ void button_event(int key, bool pressed)
|
||||||
if ( post )
|
if ( post )
|
||||||
{
|
{
|
||||||
if(repeat)
|
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
|
else
|
||||||
|
{
|
||||||
queue_post(&button_queue, btn, NULL);
|
queue_post(&button_queue, btn, NULL);
|
||||||
|
post = false;
|
||||||
|
}
|
||||||
|
|
||||||
#ifdef HAVE_REMOTE_LCD
|
#ifdef HAVE_REMOTE_LCD
|
||||||
if(btn & BUTTON_REMOTE)
|
if(btn & BUTTON_REMOTE)
|
||||||
|
|
|
||||||
|
|
@ -40,7 +40,6 @@ static int btn = 0; /* Hopefully keeps track of currently pressed keys... */
|
||||||
|
|
||||||
void button_event(int key, bool pressed)
|
void button_event(int key, bool pressed)
|
||||||
{
|
{
|
||||||
bool post = false;
|
|
||||||
int new_btn = 0;
|
int new_btn = 0;
|
||||||
int diff = 0;
|
int diff = 0;
|
||||||
static int count = 0;
|
static int count = 0;
|
||||||
|
|
@ -48,6 +47,7 @@ void button_event(int key, bool pressed)
|
||||||
static int repeat_speed = REPEAT_INTERVAL_START;
|
static int repeat_speed = REPEAT_INTERVAL_START;
|
||||||
static int repeat_count = 0;
|
static int repeat_count = 0;
|
||||||
static bool repeat = false;
|
static bool repeat = false;
|
||||||
|
static bool post = false;
|
||||||
|
|
||||||
switch (key)
|
switch (key)
|
||||||
{
|
{
|
||||||
|
|
@ -176,7 +176,8 @@ void button_event(int key, bool pressed)
|
||||||
{
|
{
|
||||||
if ( repeat )
|
if ( repeat )
|
||||||
{
|
{
|
||||||
count--;
|
if (!post)
|
||||||
|
count--;
|
||||||
if (count == 0)
|
if (count == 0)
|
||||||
{
|
{
|
||||||
post = true;
|
post = true;
|
||||||
|
|
@ -204,9 +205,18 @@ void button_event(int key, bool pressed)
|
||||||
if ( post )
|
if ( post )
|
||||||
{
|
{
|
||||||
if(repeat)
|
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
|
else
|
||||||
|
{
|
||||||
queue_post(&button_queue, btn, NULL);
|
queue_post(&button_queue, btn, NULL);
|
||||||
|
post = false;
|
||||||
|
}
|
||||||
|
|
||||||
#ifdef HAVE_REMOTE_LCD
|
#ifdef HAVE_REMOTE_LCD
|
||||||
if(btn & BUTTON_REMOTE)
|
if(btn & BUTTON_REMOTE)
|
||||||
|
|
|
||||||
|
|
@ -55,13 +55,13 @@ static void button_tick(void)
|
||||||
static int repeat_speed = REPEAT_INTERVAL_START;
|
static int repeat_speed = REPEAT_INTERVAL_START;
|
||||||
static int repeat_count = 0;
|
static int repeat_count = 0;
|
||||||
static bool repeat = false;
|
static bool repeat = false;
|
||||||
|
static bool post = false;
|
||||||
int diff;
|
int diff;
|
||||||
int btn;
|
int btn;
|
||||||
|
|
||||||
/* only poll every X ticks */
|
/* only poll every X ticks */
|
||||||
if ( ++tick >= POLL_FREQUENCY )
|
if ( ++tick >= POLL_FREQUENCY )
|
||||||
{
|
{
|
||||||
bool post = false;
|
|
||||||
button_read();
|
button_read();
|
||||||
btn = button_state;
|
btn = button_state;
|
||||||
|
|
||||||
|
|
@ -115,9 +115,18 @@ static void button_tick(void)
|
||||||
if ( post )
|
if ( post )
|
||||||
{
|
{
|
||||||
if (repeat)
|
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
|
else
|
||||||
|
{
|
||||||
queue_post(&button_queue, btn, NULL);
|
queue_post(&button_queue, btn, NULL);
|
||||||
|
post = false;
|
||||||
|
}
|
||||||
#ifdef HAVE_REMOTE_LCD
|
#ifdef HAVE_REMOTE_LCD
|
||||||
if(btn & BUTTON_REMOTE)
|
if(btn & BUTTON_REMOTE)
|
||||||
remote_backlight_on();
|
remote_backlight_on();
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue