From fe772405beb9e49e5c83c885763628985f81fc5f Mon Sep 17 00:00:00 2001 From: Dave Chapman Date: Sat, 19 Nov 2005 03:19:12 +0000 Subject: [PATCH] iPod: First attempt to implement sensible button mappings. Changes to all targets to replace a small number of references to raw button codes (BUTTON_???) with their abstract equivalents. git-svn-id: svn://svn.rockbox.org/rockbox/trunk@7983 a1c6a512-1295-4272-9138-f99709370657 --- apps/bookmark.c | 17 +----------- apps/bookmark.h | 25 ++++++++++++++++++ apps/gui/gwps.h | 32 +++++++++++------------ apps/gui/list.h | 7 ++--- apps/gui/select.h | 12 ++++----- apps/plugins/databox/databox.c | 4 +-- apps/recorder/keyboard.c | 48 +++++++++++++++++++++++----------- apps/settings.h | 9 ++++--- apps/tree.c | 6 +---- apps/tree.h | 23 +++++++++------- 10 files changed, 106 insertions(+), 77 deletions(-) diff --git a/apps/bookmark.c b/apps/bookmark.c index c42f466283..c01567848a 100644 --- a/apps/bookmark.c +++ b/apps/bookmark.c @@ -473,7 +473,7 @@ bool bookmark_autoload(const char* file) switch(key) { #ifdef HAVE_LCD_BITMAP - case BUTTON_DOWN: + case BOOKMARK_DOWN: return bookmark_load(global_bookmark_file_name, false); #endif case SETTINGS_OK: @@ -567,21 +567,6 @@ static int get_bookmark_count(const char* bookmark_file_name) } -#if CONFIG_KEYPAD == ONDIO_PAD -#define BOOKMARK_SELECT_PRE BUTTON_RIGHT -#define BOOKMARK_SELECT (BUTTON_RIGHT | BUTTON_REL) -#define BOOKMARK_DELETE (BUTTON_RIGHT | BUTTON_REPEAT) - -#elif (CONFIG_KEYPAD == IRIVER_H100_PAD) || \ - (CONFIG_KEYPAD == IRIVER_H300_PAD) -#define BOOKMARK_SELECT BUTTON_SELECT -#define BOOKMARK_DELETE (BUTTON_ON | BUTTON_SELECT) - -#else /* player, recorder, gmini */ -#define BOOKMARK_SELECT BUTTON_PLAY -#define BOOKMARK_DELETE (BUTTON_ON | BUTTON_PLAY) -#endif - /* ----------------------------------------------------------------------- */ /* This displays a the bookmarks in a file and allows the user to */ /* select one to play. */ diff --git a/apps/bookmark.h b/apps/bookmark.h index 16f4e5609f..6d281700f4 100644 --- a/apps/bookmark.h +++ b/apps/bookmark.h @@ -21,6 +21,31 @@ #include +#if CONFIG_KEYPAD == ONDIO_PAD +#define BOOKMARK_SELECT_PRE BUTTON_RIGHT +#define BOOKMARK_SELECT (BUTTON_RIGHT | BUTTON_REL) +#define BOOKMARK_DELETE (BUTTON_RIGHT | BUTTON_REPEAT) +#define BOOKMARK_DOWN BUTTON_DOWN + +#elif (CONFIG_KEYPAD == IRIVER_H100_PAD) || \ + (CONFIG_KEYPAD == IRIVER_H300_PAD) +#define BOOKMARK_SELECT BUTTON_SELECT +#define BOOKMARK_DELETE (BUTTON_ON | BUTTON_SELECT) +#define BOOKMARK_DOWN BUTTON_DOWN + +#elif (CONFIG_KEYPAD == IPOD_4G_PAD) || \ + (CONFIG_KEYPAD == IPOD_NANO_PAD) +#define BOOKMARK_SELECT BUTTON_SELECT +#define BOOKMARK_DELETE (BUTTON_RIGHT | BUTTON_REPEAT) +#define BOOKMARK_DOWN BUTTON_SCROLL_FWD + +#else /* player, recorder, gmini */ +#define BOOKMARK_SELECT BUTTON_PLAY +#define BOOKMARK_DELETE (BUTTON_ON | BUTTON_PLAY) +#define BOOKMARK_DOWN BUTTON_DOWN + +#endif + bool bookmark_load_menu(void); bool bookmark_autobookmark(void); bool bookmark_create_menu(void); diff --git a/apps/gui/gwps.h b/apps/gui/gwps.h index d8cc6a78c0..5c2bd925ab 100644 --- a/apps/gui/gwps.h +++ b/apps/gui/gwps.h @@ -170,25 +170,25 @@ #define WPS_KEYLOCK (BUTTON_MENU | BUTTON_DOWN) #define WPS_ID3 (BUTTON_MENU | BUTTON_ON) -#elif (CONFIG_KEYPAD == IPOD_4G_PAD) || (CONFIG_KEYPAD == IPOD_NANO_PAD) +#elif (CONFIG_KEYPAD == IPOD_4G_PAD) || \ +(CONFIG_KEYPAD == IPOD_NANO_PAD) /* TODO: Check WPS button assignments */ -#define WPS_NEXT (BUTTON_RIGHT | BUTTON_REL) -#define WPS_NEXT_PRE BUTTON_RIGHT -#define WPS_PREV (BUTTON_LEFT | BUTTON_REL) -#define WPS_PREV_PRE BUTTON_LEFT -#define WPS_FFWD (BUTTON_RIGHT | BUTTON_REPEAT) -#define WPS_REW (BUTTON_LEFT | BUTTON_REPEAT) -#define WPS_INCVOL BUTTON_UP -#define WPS_DECVOL BUTTON_DOWN -#define WPS_PAUSE BUTTON_OFF -/* #define WPS_MENU iPod can't have both main menu and context menu in wps */ -#define WPS_BROWSE (BUTTON_MENU | BUTTON_REL) -#define WPS_BROWSE_PRE BUTTON_MENU -#define WPS_KEYLOCK (BUTTON_MENU | BUTTON_DOWN) -#define WPS_EXIT (BUTTON_OFF | BUTTON_REPEAT) -#define WPS_CONTEXT (BUTTON_MENU | BUTTON_REPEAT) +#define WPS_NEXT (BUTTON_NEXT | BUTTON_REL) +#define WPS_NEXT_PRE BUTTON_PREV +#define WPS_PREV (BUTTON_PREV | BUTTON_REL) +#define WPS_PREV_PRE BUTTON_PREV +#define WPS_FFWD (BUTTON_NEXT | BUTTON_REPEAT) +#define WPS_REW (BUTTON_PREV | BUTTON_REPEAT) +#define WPS_INCVOL BUTTON_SCROLL_FWD +#define WPS_DECVOL BUTTON_SCROLL_BACK +#define WPS_PAUSE BUTTON_PLAY | BUTTON_REL +#define WPS_MENU (BUTTON_MENU | BUTTON_REL) +#define WPS_BROWSE (BUTTON_SELECT | BUTTON_REL) +#define WPS_BROWSE_PRE BUTTON_SELECT +#define WPS_EXIT (BUTTON_PLAY | BUTTON_REPEAT) +#define WPS_CONTEXT (BUTTON_SELECT | BUTTON_REPEAT) #endif diff --git a/apps/gui/list.h b/apps/gui/list.h index 3e5b38e5b1..5ba7983e0d 100644 --- a/apps/gui/list.h +++ b/apps/gui/list.h @@ -65,9 +65,10 @@ #define LIST_NEXT BUTTON_DOWN #define LIST_PREV BUTTON_UP -#elif (CONFIG_KEYPAD == IPOD_4G_PAD) || (CONFIG_KEYPAD == IPOD_NANO_PAD) -#define LIST_NEXT BUTTON_DOWN -#define LIST_PREV BUTTON_UP +#elif (CONFIG_KEYPAD == IPOD_4G_PAD) || \ + (CONFIG_KEYPAD == IPOD_NANO_PAD) +#define LIST_NEXT BUTTON_SCROLL_FWD +#define LIST_PREV BUTTON_SCROLL_BACK #elif CONFIG_KEYPAD == GMINI100_PAD #define LIST_NEXT BUTTON_DOWN diff --git a/apps/gui/select.h b/apps/gui/select.h index 0b67552b00..bc14af4a24 100644 --- a/apps/gui/select.h +++ b/apps/gui/select.h @@ -53,13 +53,13 @@ #define SELECT_CANCEL BUTTON_STOP #define SELECT_CANCEL2 BUTTON_MENU -#elif (CONFIG_KEYPAD == IPOD_4G_PAD) || (CONFIG_KEYPAD == IPOD_NANO_PAD) -#define SELECT_INC BUTTON_UP -#define SELECT_DEC BUTTON_DOWN -#define SELECT_OK BUTTON_RIGHT -#define SELECT_OK2 BUTTON_LEFT +#elif (CONFIG_KEYPAD == IPOD_4G_PAD) || \ + (CONFIG_KEYPAD == IPOD_NANO_PAD) +#define SELECT_INC BUTTON_SCROLL_FWD +#define SELECT_DEC BUTTON_SCROLL_BACK +#define SELECT_OK BUTTON_SELECT +#define SELECT_OK2 BUTTON_RIGHT #define SELECT_CANCEL BUTTON_MENU -#define SELECT_CANCEL2 BUTTON_OFF #elif CONFIG_KEYPAD == ONDIO_PAD #define SELECT_INC BUTTON_UP diff --git a/apps/plugins/databox/databox.c b/apps/plugins/databox/databox.c index cd51f32a49..c2a33b7331 100644 --- a/apps/plugins/databox/databox.c +++ b/apps/plugins/databox/databox.c @@ -30,8 +30,8 @@ #define DBX_SELECT BUTTON_MENU #define DBX_STOP BUTTON_OFF #elif (CONFIG_KEYPAD == IPOD_4G_PAD) || (CONFIG_KEYPAD == IPOD_NANO_PAD) -#define DBX_SELECT BUTTON_MENU -#define DBX_STOP BUTTON_OFF +#define DBX_SELECT BUTTON_SELECT +#define DBX_STOP BUTTON_MENU #elif CONFIG_KEYPAD == PLAYER_PAD #define DBX_SELECT BUTTON_PLAY #define DBX_STOP BUTTON_STOP diff --git a/apps/recorder/keyboard.c b/apps/recorder/keyboard.c index 65178a97b4..5ff340b596 100644 --- a/apps/recorder/keyboard.c +++ b/apps/recorder/keyboard.c @@ -54,6 +54,10 @@ #define KBD_DONE (BUTTON_ON | BUTTON_REL) #define KBD_ABORT BUTTON_OFF #define KBD_BACKSPACE BUTTON_REC +#define KBD_LEFT BUTTON_LEFT +#define KBD_RIGHT BUTTON_RIGHT +#define KBD_UP BUTTON_UP +#define KBD_DOWN BUTTON_DOWN #elif CONFIG_KEYPAD == RECORDER_PAD #define KBD_CURSOR_RIGHT (BUTTON_ON | BUTTON_RIGHT) @@ -63,6 +67,10 @@ #define KBD_DONE BUTTON_F2 #define KBD_ABORT BUTTON_OFF #define KBD_BACKSPACE BUTTON_F3 +#define KBD_LEFT BUTTON_LEFT +#define KBD_RIGHT BUTTON_RIGHT +#define KBD_UP BUTTON_UP +#define KBD_DOWN BUTTON_DOWN #elif CONFIG_KEYPAD == ONDIO_PAD /* restricted Ondio keypad */ #define KBD_MODES /* Ondio uses 2 modes, picker and line edit */ @@ -70,6 +78,10 @@ #define KBD_SELECT_PRE BUTTON_MENU #define KBD_DONE (BUTTON_MENU | BUTTON_REPEAT) #define KBD_ABORT BUTTON_OFF +#define KBD_LEFT BUTTON_LEFT +#define KBD_RIGHT BUTTON_RIGHT +#define KBD_UP BUTTON_UP +#define KBD_DOWN BUTTON_DOWN #elif CONFIG_KEYPAD == GMINI100_PAD #define KBD_CURSOR_RIGHT (BUTTON_MENU | BUTTON_RIGHT) @@ -80,17 +92,23 @@ #define KBD_DONE (BUTTON_PLAY | BUTTON_REPEAT) #define KBD_ABORT BUTTON_OFF #define KBD_BACKSPACE (BUTTON_MENU | BUTTON_PLAY) +#define KBD_LEFT BUTTON_LEFT +#define KBD_RIGHT BUTTON_RIGHT +#define KBD_UP BUTTON_UP +#define KBD_DOWN BUTTON_DOWN #elif (CONFIG_KEYPAD == IPOD_4G_PAD) || (CONFIG_KEYPAD == IPOD_NANO_PAD) -/* TODO: Check keyboard.c button mappings - this is a copy of Ondio */ - -#define KBD_MODES /* Ondio uses 2 modes, picker and line edit */ -#define KBD_SELECT (BUTTON_MENU | BUTTON_REL) /* backspace in line edit */ -#define KBD_SELECT_PRE BUTTON_MENU -#define KBD_DONE (BUTTON_MENU | BUTTON_REPEAT) -#define KBD_ABORT BUTTON_OFF +#define KBD_MODES /* iPod uses 2 modes, picker and line edit */ +#define KBD_SELECT (BUTTON_SELECT | BUTTON_REL) /* backspace in line edit */ +#define KBD_SELECT_PRE BUTTON_SELECT +#define KBD_DONE (BUTTON_SELECT | BUTTON_REPEAT) +#define KBD_ABORT BUTTON_MENU +#define KBD_LEFT BUTTON_PREV +#define KBD_RIGHT BUTTON_NEXT +#define KBD_UP BUTTON_SCROLL_BACK +#define KBD_DOWN BUTTON_SCROLL_FWD #endif @@ -252,8 +270,8 @@ int kbd_input(char* text, int buflen) break; #endif - case BUTTON_RIGHT: - case BUTTON_RIGHT | BUTTON_REPEAT: + case KBD_RIGHT: + case KBD_RIGHT | BUTTON_REPEAT: #ifdef KBD_MODES if (line_edit) /* right doubles as cursor_right in line_edit */ { @@ -282,8 +300,8 @@ int kbd_input(char* text, int buflen) } break; - case BUTTON_LEFT: - case BUTTON_LEFT | BUTTON_REPEAT: + case KBD_LEFT: + case KBD_LEFT | BUTTON_REPEAT: #ifdef KBD_MODES if (line_edit) /* left doubles as cursor_left in line_edit */ { @@ -312,8 +330,8 @@ int kbd_input(char* text, int buflen) } break; - case BUTTON_DOWN: - case BUTTON_DOWN | BUTTON_REPEAT: + case KBD_DOWN: + case KBD_DOWN | BUTTON_REPEAT: #ifdef KBD_MODES if (line_edit) { @@ -336,8 +354,8 @@ int kbd_input(char* text, int buflen) kbd_spellchar(line[y][x]); break; - case BUTTON_UP: - case BUTTON_UP | BUTTON_REPEAT: + case KBD_UP: + case KBD_UP | BUTTON_REPEAT: #ifdef KBD_MODES if (line_edit) { diff --git a/apps/settings.h b/apps/settings.h index 04f6da667e..c41ee1d8e3 100644 --- a/apps/settings.h +++ b/apps/settings.h @@ -79,10 +79,11 @@ #define SETTINGS_CANCEL BUTTON_OFF #define SETTINGS_CANCEL2 BUTTON_MENU -#elif (CONFIG_KEYPAD == IPOD_4G_PAD) || (CONFIG_KEYPAD == IPOD_NANO_PAD) -#define SETTINGS_INC BUTTON_RIGHT -#define SETTINGS_DEC BUTTON_LEFT -#define SETTINGS_OK BUTTON_PLAY +#elif (CONFIG_KEYPAD == IPOD_4G_PAD) || \ + (CONFIG_KEYPAD == IPOD_NANO_PAD) +#define SETTINGS_INC BUTTON_SCROLL_FWD +#define SETTINGS_DEC BUTTON_SCROLL_BACK +#define SETTINGS_OK BUTTON_SELECT #define SETTINGS_CANCEL BUTTON_MENU #endif diff --git a/apps/tree.c b/apps/tree.c index 89a8522743..f484463d2d 100644 --- a/apps/tree.c +++ b/apps/tree.c @@ -997,11 +997,7 @@ static bool add_dir(char* dirname, int len, int fd) DIRCACHED* dir; /* check for user abort */ -#ifdef BUTTON_STOP - if (button_get(false) == BUTTON_STOP) -#else - if (button_get(false) == BUTTON_OFF) -#endif + if (button_get(false) == TREE_ABORT) return true; dir = opendir_cached(dirname); diff --git a/apps/tree.h b/apps/tree.h index aa7571acdc..74b33fa635 100644 --- a/apps/tree.h +++ b/apps/tree.h @@ -30,6 +30,7 @@ #define TREE_NEXT BUTTON_DOWN #define TREE_PREV BUTTON_UP #define TREE_EXIT BUTTON_LEFT +#define TREE_ABORT BUTTON_OFF #define TREE_ENTER BUTTON_RIGHT #define TREE_RUN (BUTTON_SELECT | BUTTON_REL) #define TREE_RUN_PRE BUTTON_SELECT @@ -63,6 +64,7 @@ #define TREE_NEXT BUTTON_DOWN #define TREE_PREV BUTTON_UP #define TREE_EXIT BUTTON_LEFT +#define TREE_ABORT BUTTON_OFF #define TREE_ENTER BUTTON_RIGHT #define TREE_RUN (BUTTON_PLAY | BUTTON_REL) #define TREE_RUN_PRE BUTTON_PLAY @@ -86,6 +88,7 @@ #define TREE_NEXT BUTTON_RIGHT #define TREE_PREV BUTTON_LEFT #define TREE_EXIT BUTTON_STOP +#define TREE_ABORT BUTTON_STOP #define TREE_RUN (BUTTON_PLAY | BUTTON_REL) #define TREE_RUN_PRE BUTTON_PLAY #define TREE_MENU BUTTON_MENU @@ -104,6 +107,7 @@ #define TREE_NEXT BUTTON_DOWN #define TREE_PREV BUTTON_UP #define TREE_EXIT BUTTON_LEFT +#define TREE_ABORT BUTTON_OFF #define TREE_RUN (BUTTON_RIGHT | BUTTON_REL) #define TREE_RUN_PRE BUTTON_RIGHT #define TREE_MENU (BUTTON_MENU | BUTTON_REPEAT) @@ -130,22 +134,21 @@ #define TREE_CONTEXT2 (BUTTON_ON | BUTTON_PLAY) #define TREE_POWER_BTN BUTTON_ON -#elif (CONFIG_KEYPAD == IPOD_4G_PAD) || (CONFIG_KEYPAD == IPOD_NANO_PAD) +#elif (CONFIG_KEYPAD == IPOD_4G_PAD) || \ + (CONFIG_KEYPAD == IPOD_NANO_PAD) -/* TODO: Check Tree button assignments */ - -#define TREE_NEXT BUTTON_DOWN -#define TREE_PREV BUTTON_UP +#define TREE_NEXT BUTTON_SCROLL_FWD +#define TREE_PREV BUTTON_SCROLL_BACK #define TREE_EXIT BUTTON_LEFT -#define TREE_RUN (BUTTON_RIGHT | BUTTON_REL) -#define TREE_RUN_PRE BUTTON_RIGHT +#define TREE_ABORT BUTTON_LEFT +#define TREE_ENTER BUTTON_RIGHT +#define TREE_RUN (BUTTON_SELECT | BUTTON_REL) +#define TREE_RUN_PRE BUTTON_SELECT #define TREE_MENU (BUTTON_MENU | BUTTON_REPEAT) #define TREE_MENU_PRE BUTTON_MENU #define TREE_WPS (BUTTON_MENU | BUTTON_REL) #define TREE_WPS_PRE BUTTON_MENU -#define TREE_CONTEXT (BUTTON_RIGHT | BUTTON_REPEAT) -#define TREE_POWER_BTN BUTTON_OFF - +#define TREE_CONTEXT (BUTTON_SELECT | BUTTON_REPEAT) #endif