diff options
| author | Thomas Martitz <kugel@rockbox.org> | 2014-01-18 19:47:55 +0100 |
|---|---|---|
| committer | Thomas Martitz <kugel@rockbox.org> | 2014-01-18 19:47:55 +0100 |
| commit | c448d7e79c841ef483e685ca785114e5a8b1c535 (patch) | |
| tree | 562928e854ad6f2b1ab6a89ec71441f83bae4b5b /apps/plugins | |
| parent | b31c856b842096e5128a86a8316083190527d467 (diff) | |
| download | rockbox-c448d7e79c841ef483e685ca785114e5a8b1c535.zip rockbox-c448d7e79c841ef483e685ca785114e5a8b1c535.tar.gz rockbox-c448d7e79c841ef483e685ca785114e5a8b1c535.tar.bz2 rockbox-c448d7e79c841ef483e685ca785114e5a8b1c535.tar.xz | |
rockboy: Fix button read method.
The old method simply polled the lastbtn variable in button.c. This approach
does not clear the button event queue which overflows as a result (panic
in the simulator). Use proper APIs to fix that and adopt the
method from the old read_scroll_wheel() function, which reads buttons until
the button queue is empty, for all targets.
Change-Id: Ibf198f6e597e7f51ab4ebcfcae4ebebbe8d7845c
Diffstat (limited to 'apps/plugins')
| -rw-r--r-- | apps/plugins/rockboy/sys_rockbox.c | 38 |
1 files changed, 14 insertions, 24 deletions
diff --git a/apps/plugins/rockboy/sys_rockbox.c b/apps/plugins/rockboy/sys_rockbox.c index faba95e..54b369d 100644 --- a/apps/plugins/rockboy/sys_rockbox.c +++ b/apps/plugins/rockboy/sys_rockbox.c @@ -36,7 +36,7 @@ struct fb fb IBSS_ATTR; extern int debug_trace; -unsigned int oldbuttonstate = 0, newbuttonstate,holdbutton; +static unsigned int oldbuttonstate; #ifdef HAVE_WHEEL_POSITION int oldwheel = -1, wheel; @@ -54,39 +54,30 @@ static int wheelmap[8] = { int released, pressed; - -#ifdef ROCKBOY_SCROLLWHEEL -/* Scrollwheel events are posted directly and not polled by the button - driver - synthesize polling */ -static inline unsigned int read_scroll_wheel(void) +void ev_poll(void) { + event_t ev; + unsigned int buttons = BUTTON_NONE; unsigned int btn; - /* Empty out the button queue and see if any scrollwheel events were - posted */ + /* loop until all button events are popped off */ do { - btn = rb->button_get_w_tmo(0); + btn = rb->button_get(false); 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); - return buttons & (ROCKBOY_SCROLLWHEEL_CC | ROCKBOY_SCROLLWHEEL_CW); -} -#endif - -void ev_poll(void) -{ - event_t ev; - newbuttonstate = rb->button_status(); -#ifdef ROCKBOY_SCROLLWHEEL - newbuttonstate |= read_scroll_wheel(); -#endif - released = ~newbuttonstate & oldbuttonstate; - pressed = newbuttonstate & ~oldbuttonstate; - oldbuttonstate = newbuttonstate; + released = ~buttons & oldbuttonstate; + pressed = buttons & ~oldbuttonstate; + oldbuttonstate = buttons; #if (LCD_WIDTH == 160) && (LCD_HEIGHT == 128) && (LCD_DEPTH == 2) + static unsigned int holdbutton; if (rb->button_hold()&~holdbutton) fb.mode=(fb.mode+1)%4; holdbutton=rb->button_hold(); @@ -374,4 +365,3 @@ void vid_update(int scanline) #endif /* LCD_HEIGHT */ } #endif - |