diff options
author | Thomas Martitz <kugel@rockbox.org> | 2014-01-18 23:06:40 +0100 |
---|---|---|
committer | Thomas Martitz <kugel@rockbox.org> | 2014-01-18 23:06:55 +0100 |
commit | 6879af9784f3cfe58741c484d3bdc6f78ac8bb36 (patch) | |
tree | 6f4731a23bdd68e76be9589920580a1725a220f5 /apps/plugins/rockboy/sys_rockbox.c | |
parent | 1e7febe940fed9dbb4e993473255652f5fca4972 (diff) | |
download | rockbox-6879af9784f3cfe58741c484d3bdc6f78ac8bb36.tar.gz rockbox-6879af9784f3cfe58741c484d3bdc6f78ac8bb36.tar.bz2 rockbox-6879af9784f3cfe58741c484d3bdc6f78ac8bb36.zip |
rockbox: Improve button repeat handling.
Change-Id: I1259c43019c51828b2af73f312aee9cf399d57cf
Diffstat (limited to 'apps/plugins/rockboy/sys_rockbox.c')
-rw-r--r-- | apps/plugins/rockboy/sys_rockbox.c | 22 |
1 files changed, 16 insertions, 6 deletions
diff --git a/apps/plugins/rockboy/sys_rockbox.c b/apps/plugins/rockboy/sys_rockbox.c index 54b369d10a..1bf63b7a74 100644 --- a/apps/plugins/rockboy/sys_rockbox.c +++ b/apps/plugins/rockboy/sys_rockbox.c @@ -36,9 +36,8 @@ struct fb fb IBSS_ATTR; extern int debug_trace; -static unsigned int oldbuttonstate; #ifdef HAVE_WHEEL_POSITION -int oldwheel = -1, wheel; +static int oldwheel = -1, wheel; static int wheelmap[8] = { PAD_UP, /* Top */ @@ -52,29 +51,40 @@ static int wheelmap[8] = { }; #endif -int released, pressed; - void ev_poll(void) { event_t ev; + static unsigned int oldbuttonstate; unsigned int buttons = BUTTON_NONE; + unsigned int released, pressed; unsigned int btn; + bool quit = false; - /* loop until all button events are popped off */ do { 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; #if defined(HAVE_SCROLLWHEEL) && !defined(ROCKBOY_SCROLLWHEEL) /* filter out scroll wheel events if not supported */ buttons &= ~(BUTTON_SCROLL_FWD|BUTTON_SCROLL_BACK); #endif } - while (btn != BUTTON_NONE); + while (!quit); released = ~buttons & oldbuttonstate; pressed = buttons & ~oldbuttonstate; + oldbuttonstate = buttons; #if (LCD_WIDTH == 160) && (LCD_HEIGHT == 128) && (LCD_DEPTH == 2) static unsigned int holdbutton; |