Add remote control support to tree and menu. Move defines from wps.c to wps.h


git-svn-id: svn://svn.rockbox.org/rockbox/trunk@6692 a1c6a512-1295-4272-9138-f99709370657
diff --git a/apps/menu.c b/apps/menu.c
index 04e0bb2..126d29f 100644
--- a/apps/menu.c
+++ b/apps/menu.c
@@ -317,6 +317,9 @@
         
         switch( key ) {
             case MENU_PREV:
+#ifdef MENU_RC_PREV
+            case MENU_RC_PREV:
+#endif
             case MENU_PREV | BUTTON_REPEAT:
                 if (menus[m].cursor) {
                     /* keep the cursor at 1/3 of the screen */
@@ -336,6 +339,9 @@
                 break;
 
             case MENU_NEXT:
+#ifdef MENU_RC_NEXT
+            case MENU_RC_NEXT:
+#endif
             case MENU_NEXT | BUTTON_REPEAT:
                 if (menus[m].cursor < menus[m].itemcount-1) {
                     /* keep the cursor at 2/3 of the screen */
@@ -357,6 +363,9 @@
 #ifdef MENU_ENTER2
             case MENU_ENTER2:
 #endif
+#ifdef MENU_RC_ENTER
+            case MENU_RC_ENTER:
+#endif
                 /* Erase current display state */
                 lcd_clear_display();
                 return menus[m].cursor;
@@ -368,6 +377,9 @@
 #ifdef MENU_EXIT3
             case MENU_EXIT3:
 #endif
+#ifdef MENU_RC_EXIT
+            case MENU_RC_EXIT:
+#endif
                 lcd_stop_scroll();
                 exit = true;
                 break;
diff --git a/apps/menu.h b/apps/menu.h
index 046153b..d142d5a 100644
--- a/apps/menu.h
+++ b/apps/menu.h
@@ -31,6 +31,11 @@
 #define MENU_ENTER  BUTTON_RIGHT
 #define MENU_ENTER2 BUTTON_SELECT
 
+#define MENU_RC_NEXT   BUTTON_RC_FF
+#define MENU_RC_PREV   BUTTON_RC_REW
+#define MENU_RC_EXIT   BUTTON_RC_STOP
+#define MENU_RC_ENTER  BUTTON_RC_ON
+
 #elif CONFIG_KEYPAD == RECORDER_PAD
 #define MENU_NEXT   BUTTON_DOWN
 #define MENU_PREV   BUTTON_UP
@@ -40,6 +45,11 @@
 #define MENU_ENTER  BUTTON_RIGHT
 #define MENU_ENTER2 BUTTON_PLAY
 
+#define MENU_RC_NEXT   BUTTON_RC_RIGHT
+#define MENU_RC_PREV   BUTTON_RC_LEFT
+#define MENU_RC_EXIT   BUTTON_RC_STOP
+#define MENU_RC_ENTER  BUTTON_RC_PLAY
+
 #elif CONFIG_KEYPAD == PLAYER_PAD
 #define MENU_NEXT  BUTTON_RIGHT
 #define MENU_PREV  BUTTON_LEFT
@@ -47,6 +57,11 @@
 #define MENU_EXIT2 BUTTON_MENU
 #define MENU_ENTER BUTTON_PLAY
 
+#define MENU_RC_NEXT   BUTTON_RC_RIGHT
+#define MENU_RC_PREV   BUTTON_RC_LEFT
+#define MENU_RC_EXIT   BUTTON_RC_STOP
+#define MENU_RC_ENTER  BUTTON_RC_PLAY
+
 #elif CONFIG_KEYPAD == ONDIO_PAD
 #define MENU_NEXT  BUTTON_DOWN
 #define MENU_PREV  BUTTON_UP
diff --git a/apps/tree.c b/apps/tree.c
index e9a648e..da0e54c 100644
--- a/apps/tree.c
+++ b/apps/tree.c
@@ -992,6 +992,9 @@
 #endif
 
             case TREE_MENU:
+#ifdef TREE_RC_MENU
+            case TREE_RC_MENU:
+#endif
 #ifdef TREE_MENU_PRE
                 if (lastbutton != TREE_MENU_PRE)
                     break;
diff --git a/apps/tree.h b/apps/tree.h
index c3ab60c..5db786d 100644
--- a/apps/tree.h
+++ b/apps/tree.h
@@ -40,6 +40,13 @@
 #define TREE_CONTEXT2  (BUTTON_ON | BUTTON_SELECT)
 #define TREE_POWER_BTN BUTTON_ON
 
+#define TREE_RC_NEXT   BUTTON_RC_FF
+#define TREE_RC_PREV   BUTTON_RC_REW
+#define TREE_RC_EXIT   BUTTON_RC_STOP
+#define TREE_RC_ENTER  BUTTON_RC_ON
+#define TREE_RC_RUN    BUTTON_RC_ON
+#define TREE_RC_MENU   BUTTON_RC_MENU
+
 #elif CONFIG_KEYPAD == RECORDER_PAD
 #define TREE_NEXT      BUTTON_DOWN
 #define TREE_PREV      BUTTON_UP
diff --git a/apps/wps.c b/apps/wps.c
index 94978b3..d702282 100644
--- a/apps/wps.c
+++ b/apps/wps.c
@@ -62,119 +62,6 @@
 static struct mp3entry* nid3 = NULL;
 static char current_track_path[MAX_PATH+1];
 
-/* button definitions */
-#if CONFIG_KEYPAD == IRIVER_H100_PAD
-#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_ON
-#define WPS_MENU       (BUTTON_MODE | BUTTON_REL)
-#define WPS_MENU_PRE   BUTTON_MODE
-#define WPS_BROWSE     (BUTTON_SELECT | BUTTON_REL)
-#define WPS_BROWSE_PRE BUTTON_SELECT
-#define WPS_EXIT       BUTTON_OFF
-#define WPS_KEYLOCK    (BUTTON_MODE | BUTTON_DOWN)
-#define WPS_ID3        (BUTTON_MODE | BUTTON_ON)
-
-#define WPS_RC_NEXT    BUTTON_RC_FF
-#define WPS_RC_PREV    BUTTON_RC_REW
-#define WPS_RC_PAUSE   BUTTON_RC_ON
-#define WPS_RC_INCVOL  BUTTON_RC_VOL_UP
-#define WPS_RC_DECVOL  BUTTON_RC_VOL_DOWN
-#define WPS_RC_EXIT    BUTTON_RC_STOP
-
-
-#elif CONFIG_KEYPAD == RECORDER_PAD
-#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_PLAY
-#define WPS_MENU       (BUTTON_F1 | BUTTON_REL)
-#define WPS_MENU_PRE   BUTTON_F1
-#define WPS_BROWSE     (BUTTON_ON | BUTTON_REL)
-#define WPS_BROWSE_PRE BUTTON_ON
-#define WPS_EXIT       BUTTON_OFF
-#define WPS_KEYLOCK    (BUTTON_F1 | BUTTON_DOWN)
-#define WPS_ID3        (BUTTON_F1 | BUTTON_ON)
-
-#define WPS_RC_NEXT    BUTTON_RC_RIGHT
-#define WPS_RC_PREV    BUTTON_RC_LEFT
-#define WPS_RC_PAUSE   BUTTON_RC_PLAY
-#define WPS_RC_INCVOL  BUTTON_RC_VOL_UP
-#define WPS_RC_DECVOL  BUTTON_RC_VOL_DOWN
-#define WPS_RC_EXIT    BUTTON_RC_STOP
-
-#elif CONFIG_KEYPAD == PLAYER_PAD
-#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_MENU | BUTTON_RIGHT)
-#define WPS_DECVOL     (BUTTON_MENU | BUTTON_LEFT)
-#define WPS_PAUSE      BUTTON_PLAY
-#define WPS_MENU       (BUTTON_MENU | BUTTON_REL)
-#define WPS_MENU_PRE   BUTTON_MENU
-#define WPS_BROWSE     (BUTTON_ON | BUTTON_REL)
-#define WPS_BROWSE_PRE BUTTON_ON
-#define WPS_EXIT       BUTTON_STOP
-#define WPS_KEYLOCK    (BUTTON_MENU | BUTTON_STOP)
-#define WPS_ID3        (BUTTON_MENU | BUTTON_ON)
-
-#define WPS_RC_NEXT    BUTTON_RC_RIGHT
-#define WPS_RC_PREV    BUTTON_RC_LEFT
-#define WPS_RC_PAUSE   BUTTON_RC_PLAY
-#define WPS_RC_INCVOL  BUTTON_RC_VOL_UP
-#define WPS_RC_DECVOL  BUTTON_RC_VOL_DOWN
-#define WPS_RC_EXIT    BUTTON_RC_STOP
-
-#elif CONFIG_KEYPAD == ONDIO_PAD
-#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       (BUTTON_MENU | BUTTON_REPEAT)
-#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)
-
-#elif CONFIG_KEYPAD == GMINI100_PAD
-#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_PLAY
-#define WPS_MENU       (BUTTON_MENU | BUTTON_REL)
-#define WPS_MENU_PRE   BUTTON_MENU
-#define WPS_BROWSE     (BUTTON_ON | BUTTON_REL)
-#define WPS_BROWSE_PRE BUTTON_ON
-#define WPS_EXIT       BUTTON_OFF
-#define WPS_KEYLOCK    (BUTTON_MENU | BUTTON_DOWN)
-#define WPS_ID3        (BUTTON_MENU | BUTTON_ON)
-
-#endif
-
 /* set volume
    return true if screen restore is needed
    return false otherwise
diff --git a/apps/wps.h b/apps/wps.h
index f218fdd..668f9f6 100644
--- a/apps/wps.h
+++ b/apps/wps.h
@@ -21,6 +21,119 @@
 #include "id3.h"
 #include "playlist.h" 
 
+/* button definitions */
+#if CONFIG_KEYPAD == IRIVER_H100_PAD
+#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_ON
+#define WPS_MENU       (BUTTON_MODE | BUTTON_REL)
+#define WPS_MENU_PRE   BUTTON_MODE
+#define WPS_BROWSE     (BUTTON_SELECT | BUTTON_REL)
+#define WPS_BROWSE_PRE BUTTON_SELECT
+#define WPS_EXIT       BUTTON_OFF
+#define WPS_KEYLOCK    (BUTTON_MODE | BUTTON_DOWN)
+#define WPS_ID3        (BUTTON_MODE | BUTTON_ON)
+
+#define WPS_RC_NEXT    BUTTON_RC_FF
+#define WPS_RC_PREV    BUTTON_RC_REW
+#define WPS_RC_PAUSE   BUTTON_RC_ON
+#define WPS_RC_INCVOL  BUTTON_RC_VOL_UP
+#define WPS_RC_DECVOL  BUTTON_RC_VOL_DOWN
+#define WPS_RC_EXIT    BUTTON_RC_STOP
+
+
+#elif CONFIG_KEYPAD == RECORDER_PAD
+#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_PLAY
+#define WPS_MENU       (BUTTON_F1 | BUTTON_REL)
+#define WPS_MENU_PRE   BUTTON_F1
+#define WPS_BROWSE     (BUTTON_ON | BUTTON_REL)
+#define WPS_BROWSE_PRE BUTTON_ON
+#define WPS_EXIT       BUTTON_OFF
+#define WPS_KEYLOCK    (BUTTON_F1 | BUTTON_DOWN)
+#define WPS_ID3        (BUTTON_F1 | BUTTON_ON)
+
+#define WPS_RC_NEXT    BUTTON_RC_RIGHT
+#define WPS_RC_PREV    BUTTON_RC_LEFT
+#define WPS_RC_PAUSE   BUTTON_RC_PLAY
+#define WPS_RC_INCVOL  BUTTON_RC_VOL_UP
+#define WPS_RC_DECVOL  BUTTON_RC_VOL_DOWN
+#define WPS_RC_EXIT    BUTTON_RC_STOP
+
+#elif CONFIG_KEYPAD == PLAYER_PAD
+#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_MENU | BUTTON_RIGHT)
+#define WPS_DECVOL     (BUTTON_MENU | BUTTON_LEFT)
+#define WPS_PAUSE      BUTTON_PLAY
+#define WPS_MENU       (BUTTON_MENU | BUTTON_REL)
+#define WPS_MENU_PRE   BUTTON_MENU
+#define WPS_BROWSE     (BUTTON_ON | BUTTON_REL)
+#define WPS_BROWSE_PRE BUTTON_ON
+#define WPS_EXIT       BUTTON_STOP
+#define WPS_KEYLOCK    (BUTTON_MENU | BUTTON_STOP)
+#define WPS_ID3        (BUTTON_MENU | BUTTON_ON)
+
+#define WPS_RC_NEXT    BUTTON_RC_RIGHT
+#define WPS_RC_PREV    BUTTON_RC_LEFT
+#define WPS_RC_PAUSE   BUTTON_RC_PLAY
+#define WPS_RC_INCVOL  BUTTON_RC_VOL_UP
+#define WPS_RC_DECVOL  BUTTON_RC_VOL_DOWN
+#define WPS_RC_EXIT    BUTTON_RC_STOP
+
+#elif CONFIG_KEYPAD == ONDIO_PAD
+#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       (BUTTON_MENU | BUTTON_REPEAT)
+#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)
+
+#elif CONFIG_KEYPAD == GMINI100_PAD
+#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_PLAY
+#define WPS_MENU       (BUTTON_MENU | BUTTON_REL)
+#define WPS_MENU_PRE   BUTTON_MENU
+#define WPS_BROWSE     (BUTTON_ON | BUTTON_REL)
+#define WPS_BROWSE_PRE BUTTON_ON
+#define WPS_EXIT       BUTTON_OFF
+#define WPS_KEYLOCK    (BUTTON_MENU | BUTTON_DOWN)
+#define WPS_ID3        (BUTTON_MENU | BUTTON_ON)
+
+#endif
+
 extern bool keys_locked;
 extern bool wps_time_countup;
 
@@ -34,3 +147,4 @@
 #endif
 
 #endif
+