From c448d7e79c841ef483e685ca785114e5a8b1c535 Mon Sep 17 00:00:00 2001 From: Thomas Martitz Date: Sat, 18 Jan 2014 19:47:55 +0100 Subject: 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 --- apps/plugins/rockboy/sys_rockbox.c | 38 ++++++++++++++------------------------ 1 file changed, 14 insertions(+), 24 deletions(-) (limited to 'apps/plugins/rockboy') diff --git a/apps/plugins/rockboy/sys_rockbox.c b/apps/plugins/rockboy/sys_rockbox.c index faba95ea68..54b369d10a 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 - -- cgit v1.2.3