On 25/07/06, RaeNye <[EMAIL PROTECTED]> wrote:
Actually I thought of a more general event loop scheme.
There's a event queue (may unified with the thread queue, maybe not),
The ADC code pushes "raw" button events, e.g., BUTTON_PLAY or BUTTON_NONE;
Every plugin/menu/gui thing has a get_event() - handle_event() loop, where
usually you'd call handle_default_event().
This function will keep track of special things (e.g, button repeat, button
combos or double-clicks) and will push the ACTION_MENU or ACTION_CANCEL
events into the queue, where translation is controlled by similar structs
with a usually accepted default.
yes, but we still need to somhow define the actions which can be returned..
R.
so ive been playing a bit more and i tihnk it might even work :D (even
on the ipod!)
(i've also neatened it up because it was painful to read before)
Ignore the 4th column, I thought it might be needed, but after playing
around I dont think it is anymore.
ACTION_BACK has been removed as it almost always is the same as
ACTION_LEFT and ACTION_LONGMENU has been added (couldnt tihnk of a
better name, ideally used for the quick menu and not sure whereelse.)
static struct ButtonItem DefaultButtons[] {
/* Each target goes under here, each ACTION must be configured! */
/* REMEMBER To put REPEATS for logical actions */
#if (CONFIG_KEYPAD == IRIVER_H100_PAD)\
|| (CONFIG_KEYPAD == IRIVER_H300_PAD)
/* directions */
{ BUTTON_UP, ACTION_UP, 0, CONTEXT_STD },
{ BUTTON_UP|BUTTON_REPEAT, ACTION_UP, 0, CONTEXT_STD },
{ BUTTON_DOWN, ACTION_DOWN, 0, CONTEXT_STD },
{ BUTTON_DOWN|BUTTON_REPEAT, ACTION_DOWN, 0, CONTEXT_STD },
{ BUTTON_LEFT, ACTION_LEFT, 0, CONTEXT_STD },
{ BUTTON_LEFT|BUTTON_REPEAT, ACTION_LEFT, 0, CONTEXT_STD },
{ BUTTON_RIGHT, ACTION_RIGHT, 0, CONTEXT_STD },
{ BUTTON_RIGHT|BUTTON_REPEAT, ACTION_RIGHT, 0, CONTEXT_STD },
{ BUTTON_ON, ACTION_UNUSED, 0, CONTEXT_STD },
{ BUTTON_ON|BUTTON_UP, ACTION_PGUP, 1, CONTEXT_STD },
{ BUTTON_ON|BUTTON_UP|BUTTON_REPEAT, ACTION_PGUP, 1, CONTEXT_STD },
{ BUTTON_ON|BUTTON_DOWN, ACTION_PGDOWN, 3, CONTEXT_STD },
{ BUTTON_ON|BUTTON_DOWN|BUTTON_REPEAT, ACTION_PGDOWN, 1, CONTEXT_STD },
{ BUTTON_ON|BUTTON_LEFT, ACTION_PGLEFT, 5, CONTEXT_STD },
{ BUTTON_ON|BUTTON_LEFT|BUTTON_REPEAT, ACTION_PGLEFT, 1, CONTEXT_STD },
{ BUTTON_ON|BUTTON_RIGHT, ACTION_PGRIGHT, 7, CONTEXT_STD },
{ BUTTON_ON|BUTTON_RIGHT|BUTTON_REPEAT, ACTION_PGRIGHT, 1, CONTEXT_STD },
/* actions */
{ BUTTON_ON, ACTION_UNUSED, 0, CONTEXT_STD },
{ BUTTON_ON|BUTTON_REL, ACTION_ACCEPT, 1, CONTEXT_STD },
{ BUTTON_SELECT, ACTION_UNUSED, 0, CONTEXT_STD
}, /* SELECT and CONTEXT _PRE */
{ BUTTON_SELECT|BUTTON_REL, ACTION_SELECT, 1, CONTEXT_STD },
{ BUTTON_SELECT|BUTTON_REPEAT, ACTION_CONTEXT, 2, CONTEXT_STD },
{ BUTTON_MODE, ACTION_UNUSED, 0, CONTEXT_STD },
{ BUTTON_MODE|BUTTON_REL, ACTION_MENU, 1, CONTEXT_STD },
{ BUTTON_MODE|BUTTON_REPEAT, ACTION_LONGMENU, 2, CONTEXT_STD },
{ BUTTON_OFF, ACTION_EXIT, 0, CONTEXT_STD },
/* special stuff */
/* Remote Control Buttons */
#elif ((CONFIG_KEYPAD == IPOD_4G_PAD) \
|| (CONFIG_KEYPAD == IPOD_3G_PAD))
/* directions */
{ BUTTON_SCROLL_BACK, ACTION_UP, 0, CONTEXT_STD },
{ BUTTON_SCROLL_FWD, ACTION_DOWN, 0, CONTEXT_STD },
{ BUTTON_LEFT, ACTION_LEFT, 0, CONTEXT_WPS },
{ BUTTON_LEFT|BUTTON_REPEAT, ACTION_LEFT, 0, CONTEXT_WPS },
{ BUTTON_RIGHT, ACTION_RIGHT, 0, CONTEXT_WPS },
{ BUTTON_RIGHT|BUTTON_REPEAT, ACTION_RIGHT, 0, CONTEXT_WPS },
/* actions */
{ BUTTON_PLAY, ACTION_UNUSED, 0, CONTEXT_STD },
{ BUTTON_PLAY|BUTTON_RELEASE, ACTION_ACCEPT, 1, CONTEXT_STD },
{ BUTTON_PLAY|BUTTON_REPEAT, ACTION_EXIT, 2, CONTEXT_STD },
{ BUTTON_SELECT, ACTION_UNUSED, 0, CONTEXT_STD },
{ BUTTON_SELECT|BUTTON_RELEASE, ACTION_SELECT, 1, CONTEXT_STD },
{ BUTTON_SELECT|BUTTON_REPEAT, ACTION_CONTEXT, 2, CONTEXT_STD },
{ BUTTON_MENU, ACTION_UNUSED, 0, CONTEXT_STD },
{ BUTTON_MENU|BUTTON_REL, ACTION_MENU, 1, CONTEXT_STD },
{ BUTTON_MENU|BUTTON_REPEAT, ACTION_LONGMENU,2, CONTEXT_STD },
#else if 0
/* new targets */
#endif /* target button defines */
};
this isnt flawless because the wholething falls over when I tihnk
about the colour chooser window (ipod would want ACTION_UP/DOWN to
adjust the bars where iriver and other would use left/right), but I
still belive that having more generic code in 99% of the ui and having
to fiddle a bit in the last 1% is better than the existing system.
Pretty please will someone comment on the overall idea?