Index: apps/action.h
===================================================================
--- apps/action.h	(Revision 12574)
+++ apps/action.h	(Arbeitskopie)
@@ -119,6 +119,9 @@
     ACTION_WPS_ABSETA_PREVDIR, /* these should be safe to put together seen as */
     ACTION_WPS_ABSETB_NEXTDIR, /* you shouldnt want to change dir in ab-mode */
     ACTION_WPSAB_RESET,
+    ACTION_WPS_USER1, /* optional, for user-settable button */
+    ACTION_WPS_USER2, /* optional, for user-settable button */
+    ACTION_WPS_USER3, /* optional, for user-settable button */
     
     /* list and tree page up/down */    
     ACTION_LISTTREE_PGUP,/* optional */
@@ -132,6 +135,9 @@
     ACTION_TREE_PGRIGHT,/* optional */
     ACTION_TREE_STOP,
     ACTION_TREE_WPS,
+    ACTION_TREE_USER1, /* optional, for user-settable button */
+    ACTION_TREE_USER2, /* optional, for user-settable button */
+    ACTION_TREE_USER3, /* optional, for user-settable button */
     
     /* radio */
     ACTION_FM_MENU,
Index: apps/recorder/recording.h
===================================================================
--- apps/recorder/recording.h	(Revision 12574)
+++ apps/recorder/recording.h	(Arbeitskopie)
@@ -25,6 +25,9 @@
 char *rec_create_filename(char *buf);
 int rec_create_directory(void);
 
+/* If true, start recording automatically when recording_sreen() is entered */
+extern bool recording_start_automatic;
+
 #if CONFIG_CODEC == SWCODEC
 /* handles device powerup and sets audio source */
 void rec_set_source(int source, unsigned flags);
Index: apps/recorder/recording.c
===================================================================
--- apps/recorder/recording.c	(Revision 12574)
+++ apps/recorder/recording.c	(Arbeitskopie)
@@ -745,6 +745,8 @@
     }
 }
 
+bool recording_start_automatic = false;
+
 bool recording_screen(bool no_source)
 {
     long button;
@@ -933,6 +935,14 @@
                 have_recorded = true;
             }
             last_audio_stat = audio_stat;
+        } 
+
+
+        if (recording_start_automatic)
+        {
+            /* simulate a button press */
+            button = ACTION_REC_PAUSE;
+            recording_start_automatic = false;
         }
 
         switch(button)
Index: apps/tree.c
===================================================================
--- apps/tree.c	(Revision 12574)
+++ apps/tree.c	(Arbeitskopie)
@@ -53,6 +53,7 @@
 #include "plugin.h"
 #include "power.h"
 #include "action.h"
+#include "user_action.h"
 #include "talk.h"
 #include "filetypes.h"
 #include "misc.h"
@@ -711,6 +712,24 @@
                 return GO_TO_ROOT;
                 break;
 
+                /* Rincewind Code */
+                /* user-settable actions, used only for rec-button on irivers Hxx currently */
+            case ACTION_TREE_USER1:
+            case ACTION_TREE_USER2:
+            case ACTION_TREE_USER3:
+                /* break if user has set action for this button == none */
+                if (user_action_none(button))
+                    break;
+                static int user_action_ret;
+                if (*tc.dirfilter < NUM_FILTER_MODES)
+                {
+                    user_action_ret = user_action(button);
+                    if (user_action_ret != GO_TO_PREVIOUS && user_action_ret != GO_TO_FILEBROWSER)
+                        return user_action_ret;
+                    restore = true;
+                }
+                break;
+
             case ACTION_TREE_WPS:
                 return GO_TO_PREVIOUS_MUSIC;
                 break;
Index: apps/lang/english.lang
===================================================================
--- apps/lang/english.lang	(Revision 12574)
+++ apps/lang/english.lang	(Arbeitskopie)
@@ -10182,6 +10182,146 @@
   </voice>
 </phrase>
 <phrase>
+  id: LANG_BUTTON_CONFIG
+  desc: in system menu
+  user:
+  <source>
+    *: "Button Config"
+  </source>
+  <dest>
+    *: "Button Config"
+  </dest>
+  <voice>
+    *: "Button Config"
+  </voice>
+</phrase>
+<phrase>
+  id: LANG_REC_BUTTON_SHORT
+  desc: in button config menu
+  user:
+  <source>
+    *: "Action on short press REC"
+  </source>
+  <dest>
+    *: "Action on short press REC"
+  </dest>
+  <voice>
+    *: "Action on short press Rec"
+  </voice>
+</phrase>
+<phrase>
+  id: LANG_REC_BUTTON_LONG
+  desc: in button config menu
+  user:
+  <source>
+    *: "Action on long press REC"
+  </source>
+  <dest>
+    *: "Action on long press REC"
+  </dest>
+  <voice>
+    *: "Action on long press Rec"
+  </voice>
+</phrase>
+<phrase>
+  id: LANG_REC_BUTTON_PLAY
+  desc: in button config menu
+  user:
+  <source>
+    *: "Action on PLAY + REC"
+  </source>
+  <dest>
+    *: "Action on PLAY + REC"
+  </dest>
+  <voice>
+    *: "Action on Play and Rec"
+  </voice>
+</phrase>
+<phrase>
+  id: LANG_BT_NONE
+  desc: option for Rec button config
+  user:
+  <source>
+    *: "none"
+  </source>
+  <dest>
+    *: "none"
+  </dest>
+  <voice>
+    *: "none"
+  </voice>
+</phrase>
+<phrase>
+  id: LANG_BT_PLAYLIST
+  desc: option for Rec button config
+  user:
+  <source>
+    *: "Current playlist"
+  </source>
+  <dest>
+    *: "Current playlist"
+  </dest>
+  <voice>
+    *: "Current playlist"
+  </voice>
+</phrase>
+<phrase>
+  id: LANG_BT_PLUGINS
+  desc: option for Rec button config
+  user:
+  <source>
+    *: "Plugins"
+  </source>
+  <dest>
+    *: "Plugins"
+  </dest>
+  <voice>
+    *: "Plugins"
+  </voice>
+</phrase>
+<phrase>
+  id: LANG_BT_THEMES
+  desc: option for Rec button config
+  user:
+  <source>
+    *: "Themes"
+  </source>
+  <dest>
+    *: "Themes"
+  </dest>
+  <voice>
+    *: "Themes"
+  </voice>
+</phrase>
+<phrase>
+  id: LANG_BT_RECORDING
+  desc: option for Rec button config
+  user:
+  <source>
+    *: "Recording Screen"
+  </source>
+  <dest>
+    *: "Recording Screen"
+  </dest>
+  <voice>
+    *: "Recording Screen"
+  </voice>
+</phrase>
+<phrase>
+  id: LANG_BT_INSTANT_REC
+  desc: option for Rec button config
+  user:
+  <source>
+    *: "Start recording instantly"
+  </source>
+  <dest>
+    *: "Start recording instantly"
+  </dest>
+  <voice>
+    *: "Start recording instantly"
+  </voice>
+</phrase>
+<phrase>
   id: LANG_BITRATE
   desc: bits-kilobits per unit time
   user:
Index: apps/gui/gwps.c
===================================================================
--- apps/gui/gwps.c	(Revision 12574)
+++ apps/gui/gwps.c	(Arbeitskopie)
@@ -27,6 +27,7 @@
 #include "font.h"
 #include "backlight.h"
 #include "action.h"
+#include "user_action.h"
 #include "kernel.h"
 #include "tree.h"
 #include "debug.h"
@@ -254,6 +255,38 @@
                 restore = true;
                 break;
 
+                /* Rincewind Code */
+                /* user-setteble actions, used only for rec-button on irivers Hxx currently */
+            case ACTION_WPS_USER1:
+            case ACTION_WPS_USER2:
+            case ACTION_WPS_USER3:
+                /* break if user has set action for this button == none */
+                if (user_action_none(button))
+                    break;
+                
+                FOR_NB_SCREENS(i)
+                    gui_wps[i].display->stop_scroll();
+#ifdef HAVE_LCD_COLOR
+                show_main_backdrop();
+#endif
+                action_signalscreenchange();
+                static int user_action_ret;
+                user_action_ret = user_action(button);
+                if (user_action_ret != GO_TO_PREVIOUS && user_action_ret != GO_TO_PREVIOUS_MUSIC && user_action_ret != GO_TO_WPS)
+                    return user_action_ret;
+
+#ifdef HAVE_LCD_COLOR
+                show_wps_backdrop();
+#endif
+#ifdef HAVE_LCD_BITMAP
+                FOR_NB_SCREENS(i)
+                {
+                    gui_wps_set_margin(&gui_wps[i]);
+                }
+#endif
+                restore = true;
+                break;                
+
             case ACTION_WPS_BROWSE:
 #ifdef HAVE_LCD_CHARCELLS
                 status_set_record(false);
Index: apps/settings.h
===================================================================
--- apps/settings.h	(Revision 12574)
+++ apps/settings.h	(Arbeitskopie)
@@ -436,6 +436,15 @@
     int peak_meter_max; /* range maximum */
     bool car_adapter_mode; /* 0=off 1=on */
 
+    /* Rincewind Code */
+#if (CONFIG_KEYPAD == IRIVER_H100_PAD) ||       \
+    (CONFIG_KEYPAD == IRIVER_H300_PAD)
+    /* 0=none 1=playlist 2=plugins 3=themes 4=recording screen 5=instant rec */
+    int user_action1;
+    int user_action2;
+    int user_action3;  
+#endif
+
     /* show status bar */
     bool statusbar;    /* 0=hide, 1=show */
 
Index: apps/menus/settings_menu.c
===================================================================
--- apps/menus/settings_menu.c	(Revision 12574)
+++ apps/menus/settings_menu.c	(Arbeitskopie)
@@ -241,6 +241,15 @@
 #endif
 MENUITEM_SETTING(start_screen, &global_settings.start_in_screen, NULL);
 
+/* Rincewind Code */
+#if (CONFIG_KEYPAD == IRIVER_H100_PAD) || (CONFIG_KEYPAD == IRIVER_H300_PAD)
+MENUITEM_SETTING(user_action1, &global_settings.user_action1, NULL);
+MENUITEM_SETTING(user_action2, &global_settings.user_action2, NULL);
+MENUITEM_SETTING(user_action3, &global_settings.user_action3, NULL);
+MAKE_MENU(button_config, ID2P(LANG_BUTTON_CONFIG), 0, Icon_NOICON,
+           &user_action1, &user_action2, &user_action3);
+#endif
+
 MAKE_MENU(system_menu, ID2P(LANG_SYSTEM), 
           0, Icon_System_menu,
             &start_screen,
@@ -264,6 +273,9 @@
 #if CONFIG_CHARGING
             &car_adapter_mode,
 #endif
+#if (CONFIG_KEYPAD == IRIVER_H100_PAD) || (CONFIG_KEYPAD == IRIVER_H300_PAD)
+            &button_config,
+#endif
          );
 
 /*    SYSTEM MENU                  */
Index: apps/settings_list.c
===================================================================
--- apps/settings_list.c	(Revision 12574)
+++ apps/settings_list.c	(Arbeitskopie)
@@ -1082,6 +1082,27 @@
 #endif
 #endif
     OFFON_SETTING(0,cuesheet,LANG_CUESHEET_ENABLE,false,"cuesheet support", NULL),
+
+    /* Rincewind Code */
+#if (CONFIG_KEYPAD == IRIVER_H100_PAD) ||       \
+    (CONFIG_KEYPAD == IRIVER_H300_PAD)
+    CHOICE_SETTING(0, user_action1, LANG_REC_BUTTON_SHORT,0,
+                   "user-defined button action 1",
+                   "none,Current Playlist,Plugins,Themes,Recording Screen,Instant Recording",NULL, 6,
+                   ID2P(LANG_BT_NONE), ID2P(LANG_BT_PLAYLIST), ID2P(LANG_BT_PLUGINS), ID2P(LANG_BT_THEMES),
+                   ID2P(LANG_BT_RECORDING), ID2P(LANG_BT_INSTANT_REC)),
+    CHOICE_SETTING(0, user_action2, LANG_REC_BUTTON_LONG,0,
+                   "user-defined button action 2",
+                   "none,Current Playlist,Plugins,Themes,Recording Screen,Instant Recording",NULL, 6,
+                   ID2P(LANG_BT_NONE), ID2P(LANG_BT_PLAYLIST), ID2P(LANG_BT_PLUGINS), ID2P(LANG_BT_THEMES),
+                   ID2P(LANG_BT_RECORDING), ID2P(LANG_BT_INSTANT_REC)),
+    CHOICE_SETTING(0, user_action3, LANG_REC_BUTTON_PLAY,0,
+                   "user-defined button action 3",
+                   "none,Current Playlist,Plugins,Themes,Recording Screen,Instant Recording",NULL, 6,
+                   ID2P(LANG_BT_NONE), ID2P(LANG_BT_PLAYLIST), ID2P(LANG_BT_PLUGINS), ID2P(LANG_BT_THEMES),
+                   ID2P(LANG_BT_RECORDING), ID2P(LANG_BT_INSTANT_REC)),
+#endif
+
     CHOICE_SETTING(0, start_in_screen, LANG_START_SCREEN, 1, 
             "start in screen", "previous,root,files,db,wps,menu,"
 #ifdef HAVE_RECORDING
Index: apps/user_action.c
===================================================================
--- apps/user_action.c	(Revision 0)
+++ apps/user_action.c	(Revision 0)
@@ -0,0 +1,85 @@
+/***************************************************************************
+ *             __________               __   ___.
+ *   Open      \______   \ ____   ____ |  | _\_ |__   _______  ___
+ *   Source     |       _//  _ \_/ ___\|  |/ /| __ \ /  _ \  \/  /
+ *   Jukebox    |    |   (  <_> )  \___|    < | \_\ (  <_> > <  <
+ *   Firmware   |____|_  /\____/ \___  >__|_ \|___  /\____/__/\_ \
+ *                     \/            \/     \/    \/            \/
+ * $Id:$
+ *
+ * Copyright (C) 2006 by Simon Menzel
+ *
+ * All files in this archive are subject to the GNU General Public License.
+ * See the file COPYING in the source tree root for full license agreement.
+ *
+ * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
+ * KIND, either express or implied.
+ *
+ ****************************************************************************/
+#include "settings.h"
+#include "playlist_viewer.h"
+#include "tree.h"
+#include "statusbar.h"
+#include "recording.h"
+#include "main_menu.h"
+#include "lang.h"
+#include "action.h"
+#include "root_menu.h"
+
+static int get_user_action(int button)
+{
+    if ((button == ACTION_WPS_USER1) || (button == ACTION_TREE_USER1))
+        return global_settings.user_action1;
+    else if ((button ==  ACTION_WPS_USER2) || (button == ACTION_TREE_USER2))
+        return global_settings.user_action2;
+    else if ((button ==  ACTION_WPS_USER3) || (button == ACTION_TREE_USER3))
+        return global_settings.user_action3;
+    else
+        return 0;
+}
+
+int user_action(int button) {
+    int ret;
+    switch (get_user_action(button))
+    {
+        case 0: /* none */
+            ret = GO_TO_PREVIOUS;
+            break;
+        case 1:                         /* Playlist */
+            gui_syncstatusbar_draw(&statusbars,true);
+            if (playlist_viewer())
+                ret = GO_TO_ROOT;
+            else
+                ret = GO_TO_PREVIOUS;
+            break;
+        case 2:                         /* plugins */
+            gui_syncstatusbar_draw(&statusbars,true);
+            ret = rockbox_browse(PLUGIN_DIR, SHOW_PLUGINS);
+            action_signalscreenchange();
+            break;
+        case 3:                         /* themes */
+            gui_syncstatusbar_draw(&statusbars,true);
+            ret = rockbox_browse(THEME_DIR, SHOW_CFG);
+            action_signalscreenchange();
+            break;
+        case 4:                         /* recording screen */
+            ret = GO_TO_RECSCREEN;
+            break;
+        case 5:                        /* instant recording */
+            recording_start_automatic = true;
+            ret = GO_TO_RECSCREEN;
+            break;
+        default:
+            ret = GO_TO_PREVIOUS;
+    }
+    return ret;
+}
+
+bool user_action_none(int button)
+{
+    if (get_user_action(button) == 0)
+        return true;
+    else
+        return false;
+}
+        
Index: apps/user_action.h
===================================================================
--- apps/user_action.h	(Revision 0)
+++ apps/user_action.h	(Revision 0)
@@ -0,0 +1,28 @@
+/***************************************************************************
+ *             __________               __   ___.                  
+ *   Open      \______   \ ____   ____ |  | _\_ |__   _______  ___  
+ *   Source     |       _//  _ \_/ ___\|  |/ /| __ \ /  _ \  \/  /  
+ *   Jukebox    |    |   (  <_> )  \___|    < | \_\ (  <_> > <  <   
+ *   Firmware   |____|_  /\____/ \___  >__|_ \|___  /\____/__/\_ \  
+ *                     \/            \/     \/    \/            \/ 
+ * $Id:$
+ *
+ * Copyright (C) 2006 by Simon Menzel
+ *
+ * All files in this archive are subject to the GNU General Public License.
+ * See the file COPYING in the source tree root for full license agreement.
+ *
+ * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
+ * KIND, either express or implied.
+ *
+ ****************************************************************************/
+#ifndef REC_BUTTON_H
+#define REC_BUTTON_H
+
+/* Calls the user action for the button (action is taken from settings) */
+/* returns a GO_TO_xxx number */
+int user_action(int button);
+/* check if user action is "none" */
+bool user_action_none(int button);
+
+#endif
Index: apps/SOURCES
===================================================================
--- apps/SOURCES	(Revision 12574)
+++ apps/SOURCES	(Arbeitskopie)
@@ -45,6 +45,7 @@
 #endif
 filetree.c
 scrobbler.c
+user_action.c
 
 screen_access.c
 gui/buttonbar.c
Index: apps/keymaps/keymap-h1x0_h3x0.c
===================================================================
--- apps/keymaps/keymap-h1x0_h3x0.c	(Revision 12574)
+++ apps/keymaps/keymap-h1x0_h3x0.c	(Arbeitskopie)
@@ -95,6 +95,9 @@
     { ACTION_WPS_BROWSE,        BUTTON_SELECT|BUTTON_REL,       BUTTON_SELECT },
     { ACTION_WPSAB_RESET,       BUTTON_ON|BUTTON_SELECT,        BUTTON_ON },
     { ACTION_WPS_ID3SCREEN,     BUTTON_ON|BUTTON_MODE,          BUTTON_NONE },
+    { ACTION_WPS_USER1,         BUTTON_REC|BUTTON_REL,          BUTTON_REC },
+    { ACTION_WPS_USER2,         BUTTON_REC|BUTTON_REPEAT,       BUTTON_REC },
+    { ACTION_WPS_USER3,         BUTTON_ON|BUTTON_REC,           BUTTON_NONE },
     
     LAST_ITEM_IN_LIST
 }; /* button_context_wps */
@@ -115,6 +118,10 @@
     { ACTION_TREE_STOP,   BUTTON_OFF,                   BUTTON_NONE },
     { ACTION_TREE_STOP,   BUTTON_OFF|BUTTON_REL,        BUTTON_OFF },
     { ACTION_TREE_STOP,   BUTTON_OFF|BUTTON_REPEAT,     BUTTON_NONE },
+    { ACTION_TREE_USER1,  BUTTON_REC|BUTTON_REL,        BUTTON_REC },
+    { ACTION_TREE_USER2,  BUTTON_REC|BUTTON_REPEAT,     BUTTON_REC },
+    { ACTION_TREE_USER3,  BUTTON_ON|BUTTON_REC,         BUTTON_NONE },
+  
 
     LAST_ITEM_IN_LIST__NEXTLIST(CONTEXT_LIST)
 }; /* button_context_tree */
