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 | |
parent | 1e7febe940fed9dbb4e993473255652f5fca4972 (diff) | |
download | rockbox-6879af9784f3cfe58741c484d3bdc6f78ac8bb36.tar.gz rockbox-6879af9784f3cfe58741c484d3bdc6f78ac8bb36.zip |
rockbox: Improve button repeat handling.
Change-Id: I1259c43019c51828b2af73f312aee9cf399d57cf
Diffstat (limited to 'apps/plugins')
-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; | |||
36 | 36 | ||
37 | extern int debug_trace; | 37 | extern int debug_trace; |
38 | 38 | ||
39 | static unsigned int oldbuttonstate; | ||
40 | #ifdef HAVE_WHEEL_POSITION | 39 | #ifdef HAVE_WHEEL_POSITION |
41 | int oldwheel = -1, wheel; | 40 | static int oldwheel = -1, wheel; |
42 | 41 | ||
43 | static int wheelmap[8] = { | 42 | static int wheelmap[8] = { |
44 | PAD_UP, /* Top */ | 43 | PAD_UP, /* Top */ |
@@ -52,29 +51,40 @@ static int wheelmap[8] = { | |||
52 | }; | 51 | }; |
53 | #endif | 52 | #endif |
54 | 53 | ||
55 | int released, pressed; | ||
56 | |||
57 | void ev_poll(void) | 54 | void ev_poll(void) |
58 | { | 55 | { |
59 | event_t ev; | 56 | event_t ev; |
60 | 57 | ||
58 | static unsigned int oldbuttonstate; | ||
61 | unsigned int buttons = BUTTON_NONE; | 59 | unsigned int buttons = BUTTON_NONE; |
60 | unsigned int released, pressed; | ||
62 | unsigned int btn; | 61 | unsigned int btn; |
62 | bool quit = false; | ||
63 | 63 | ||
64 | /* loop until all button events are popped off */ | ||
65 | do | 64 | do |
66 | { | 65 | { |
67 | btn = rb->button_get(false); | 66 | btn = rb->button_get(false); |
67 | /* BUTTON_NONE doesn't necessarily mean no button is pressed, | ||
68 | * it just means the button queue became empty for this tick. | ||
69 | * One can only be sure that no button is pressed by | ||
70 | * calling button_status(). */ | ||
71 | if (btn == BUTTON_NONE) | ||
72 | { | ||
73 | /* loop only until all button events are popped off */ | ||
74 | quit = true; | ||
75 | btn = rb->button_status(); | ||
76 | } | ||
68 | buttons |= btn; | 77 | buttons |= btn; |
69 | #if defined(HAVE_SCROLLWHEEL) && !defined(ROCKBOY_SCROLLWHEEL) | 78 | #if defined(HAVE_SCROLLWHEEL) && !defined(ROCKBOY_SCROLLWHEEL) |
70 | /* filter out scroll wheel events if not supported */ | 79 | /* filter out scroll wheel events if not supported */ |
71 | buttons &= ~(BUTTON_SCROLL_FWD|BUTTON_SCROLL_BACK); | 80 | buttons &= ~(BUTTON_SCROLL_FWD|BUTTON_SCROLL_BACK); |
72 | #endif | 81 | #endif |
73 | } | 82 | } |
74 | while (btn != BUTTON_NONE); | 83 | while (!quit); |
75 | 84 | ||
76 | released = ~buttons & oldbuttonstate; | 85 | released = ~buttons & oldbuttonstate; |
77 | pressed = buttons & ~oldbuttonstate; | 86 | pressed = buttons & ~oldbuttonstate; |
87 | |||
78 | oldbuttonstate = buttons; | 88 | oldbuttonstate = buttons; |
79 | #if (LCD_WIDTH == 160) && (LCD_HEIGHT == 128) && (LCD_DEPTH == 2) | 89 | #if (LCD_WIDTH == 160) && (LCD_HEIGHT == 128) && (LCD_DEPTH == 2) |
80 | static unsigned int holdbutton; | 90 | static unsigned int holdbutton; |