rockbox: Improve button repeat handling.

Change-Id: I1259c43019c51828b2af73f312aee9cf399d57cf
This commit is contained in:
Thomas Martitz 2014-01-18 23:06:40 +01:00
parent 1e7febe940
commit 6879af9784

View file

@ -36,9 +36,8 @@ struct fb fb IBSS_ATTR;
extern int debug_trace; extern int debug_trace;
static unsigned int oldbuttonstate;
#ifdef HAVE_WHEEL_POSITION #ifdef HAVE_WHEEL_POSITION
int oldwheel = -1, wheel; static int oldwheel = -1, wheel;
static int wheelmap[8] = { static int wheelmap[8] = {
PAD_UP, /* Top */ PAD_UP, /* Top */
@ -52,29 +51,40 @@ static int wheelmap[8] = {
}; };
#endif #endif
int released, pressed;
void ev_poll(void) void ev_poll(void)
{ {
event_t ev; event_t ev;
static unsigned int oldbuttonstate;
unsigned int buttons = BUTTON_NONE; unsigned int buttons = BUTTON_NONE;
unsigned int released, pressed;
unsigned int btn; unsigned int btn;
bool quit = false;
/* loop until all button events are popped off */
do do
{ {
btn = rb->button_get(false); btn = rb->button_get(false);
/* BUTTON_NONE doesn't necessarily mean no button is pressed,
* it just means the button queue became empty for this tick.
* One can only be sure that no button is pressed by
* calling button_status(). */
if (btn == BUTTON_NONE)
{
/* loop only until all button events are popped off */
quit = true;
btn = rb->button_status();
}
buttons |= btn; buttons |= btn;
#if defined(HAVE_SCROLLWHEEL) && !defined(ROCKBOY_SCROLLWHEEL) #if defined(HAVE_SCROLLWHEEL) && !defined(ROCKBOY_SCROLLWHEEL)
/* filter out scroll wheel events if not supported */ /* filter out scroll wheel events if not supported */
buttons &= ~(BUTTON_SCROLL_FWD|BUTTON_SCROLL_BACK); buttons &= ~(BUTTON_SCROLL_FWD|BUTTON_SCROLL_BACK);
#endif #endif
} }
while (btn != BUTTON_NONE); while (!quit);
released = ~buttons & oldbuttonstate; released = ~buttons & oldbuttonstate;
pressed = buttons & ~oldbuttonstate; pressed = buttons & ~oldbuttonstate;
oldbuttonstate = buttons; oldbuttonstate = buttons;
#if (LCD_WIDTH == 160) && (LCD_HEIGHT == 128) && (LCD_DEPTH == 2) #if (LCD_WIDTH == 160) && (LCD_HEIGHT == 128) && (LCD_DEPTH == 2)
static unsigned int holdbutton; static unsigned int holdbutton;