*** /home/simon/rockbox-clean/apps/SOURCES	2006-11-19 15:11:40.000000000 +0100
--- /home/simon/rockbox-devel/apps/SOURCES	2006-12-06 17:45:00.000000000 +0100
***************
*** 18,23 ****
--- 18,24 ----
  playlist_menu.c
  playlist_viewer.c
  plugin.c
+ user_action.c
  screens.c
  settings.c
  settings_menu.c

*** /home/simon/rockbox-clean/apps/action.h	2006-11-16 03:53:40.000000000 +0100
--- /home/simon/rockbox-devel/apps/action.h	2006-11-16 18:38:26.000000000 +0100
***************
*** 115,120 ****
--- 115,123 ----
      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 */
***************
*** 128,133 ****
--- 131,139 ----
      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,

*** /home/simon/rockbox-clean/apps/gui/gwps.c	2006-11-26 10:53:42.000000000 +0100
--- /home/simon/rockbox-devel/apps/gui/gwps.c	2006-12-06 17:45:04.000000000 +0100
***************
*** 27,32 ****
--- 27,33 ----
  #include "font.h"
  #include "backlight.h"
  #include "action.h"
+ #include "user_action.h"
  #include "kernel.h"
  #include "tree.h"
  #include "debug.h"
***************
*** 218,223 ****
--- 219,252 ----
                  restore = true;
                  break;
  
+                 /* 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();
+                 if(user_action(button))
+                     return true;
+ #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);

*** /home/simon/rockbox-clean/apps/keymaps/keymap-h1x0_h3x0.c	2006-12-01 00:18:56.000000000 +0100
--- /home/simon/rockbox-devel/apps/keymaps/keymap-h1x0_h3x0.c	2006-12-06 17:45:05.000000000 +0100
***************
*** 89,94 ****
--- 89,97 ----
      { 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 */
***************
*** 109,114 ****
--- 112,121 ----
      { 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 */

*** /home/simon/rockbox-clean/apps/lang/english.lang	2006-12-10 11:47:11.000000000 +0100
--- /home/simon/rockbox-devel/apps/lang/english.lang	2006-12-11 15:55:28.000000000 +0100
***************
*** 10173,10178 ****
--- 10173,10318 ----
    </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:

*** /home/simon/rockbox-clean/apps/recorder/recording.c	2006-12-10 15:32:38.000000000 +0100
--- /home/simon/rockbox-devel/apps/recorder/recording.c	2006-12-11 15:55:29.000000000 +0100
***************
*** 736,741 ****
--- 736,743 ----
      }
  }
  
+ bool recording_start_automatic = false;
+ 
  bool recording_screen(bool no_source)
  {
      long button;
***************
*** 782,787 ****
--- 784,790 ----
      int trig_xpos[NB_SCREENS];
      int trig_ypos[NB_SCREENS];
      int trig_width[NB_SCREENS];
+     bool just_entered = true;
  
      static const unsigned char *byte_units[] = {
          ID2P(LANG_BYTE),
***************
*** 923,928 ****
--- 926,939 ----
                  have_recorded = true;
              }
              last_audio_stat = audio_stat;
+         } 
+ 
+ 
+         if (recording_start_automatic && just_entered)
+         {
+             /* simulate a button press */
+             button = ACTION_REC_PAUSE;
+             just_entered = false;
          }
  
          switch(button)

*** /home/simon/rockbox-clean/apps/recorder/recording.h	2006-11-23 20:21:12.000000000 +0100
--- /home/simon/rockbox-devel/apps/recorder/recording.h	2006-12-06 17:45:10.000000000 +0100
***************
*** 23,28 ****
--- 23,31 ----
  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);

*** /home/simon/rockbox-clean/apps/settings.c	2006-12-06 13:11:56.000000000 +0100
--- /home/simon/rockbox-devel/apps/settings.c	2006-12-06 17:45:02.000000000 +0100
***************
*** 689,694 ****
--- 689,704 ----
  
      /* If values are just added to the end, no need to bump the version. */
      /* new stuff to be added at the end */
+ 
+ #if (CONFIG_KEYPAD == IRIVER_H100_PAD) ||       \
+     (CONFIG_KEYPAD == IRIVER_H300_PAD)
+     {4, S_O(user_action1), 0, "user-defined button action 1",
+      "none,Current Playlist,Plugins,Themes,Recording Screen,Instant Recording"},
+     {4, S_O(user_action2), 0, "user-defined button action 2",
+      "none,Current Playlist,Plugins,Themes,Recording Screen,Instant Recording"},
+     {4, S_O(user_action3), 0, "user-defined button action 3",
+      "none,Current Playlist,Plugins,Themes,Recording Screen,Instant Recording"},
+ #endif
  #ifdef HAVE_RECORDING
      {2, S_O(rec_trigger_type), 0, "trigger type", "stop,pause,nf stp"},
  #endif

*** /home/simon/rockbox-clean/apps/settings.h	2006-11-24 20:49:02.000000000 +0100
--- /home/simon/rockbox-devel/apps/settings.h	2006-12-06 17:45:02.000000000 +0100
***************
*** 287,292 ****
--- 287,300 ----
      int peak_meter_max; /* range maximum */
      bool car_adapter_mode; /* 0=off 1=on */
  
+ #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 */
  

*** /home/simon/rockbox-clean/apps/settings_menu.c	2006-11-13 01:45:20.000000000 +0100
--- /home/simon/rockbox-devel/apps/settings_menu.c	2006-11-15 22:30:40.000000000 +0100
***************
*** 2186,2191 ****
--- 2186,2255 ----
      return result;
  }
  
+ #if (CONFIG_KEYPAD == IRIVER_H100_PAD) || (CONFIG_KEYPAD == IRIVER_H300_PAD)
+ static bool rec_button_short(void)
+ {
+     static const struct opt_items names[] = {
+         { STR(LANG_BT_NONE) },
+         { STR(LANG_BT_PLAYLIST) },
+         { STR(LANG_BT_PLUGINS) },
+         { STR(LANG_BT_THEMES) },
+         { STR(LANG_BT_RECORDING) },
+     };
+     bool ret;
+     ret=set_option( str(LANG_REC_BUTTON_SHORT),
+                     &global_settings.user_action1, INT, names, 5, NULL);
+     return ret;
+ }
+ 
+ static bool rec_button_long(void)
+ {
+     static const struct opt_items names[] = {
+         { STR(LANG_BT_NONE) },
+         { STR(LANG_BT_PLAYLIST) },
+         { STR(LANG_BT_PLUGINS) },
+         { STR(LANG_BT_THEMES) },
+         { STR(LANG_BT_RECORDING) },
+         { STR(LANG_BT_INSTANT_REC) },
+     };
+     bool ret;
+     ret=set_option( str(LANG_REC_BUTTON_LONG),
+                     &global_settings.user_action2, INT, names, 6, NULL);
+     return ret;
+ }
+ static bool rec_button_play(void)
+ {
+     static const struct opt_items names[] = {
+         { STR(LANG_BT_NONE) },
+         { STR(LANG_BT_PLAYLIST) },
+         { STR(LANG_BT_PLUGINS) },
+         { STR(LANG_BT_THEMES) },
+         { STR(LANG_BT_RECORDING) },
+         { STR(LANG_BT_INSTANT_REC) },
+     };
+     bool ret;
+     ret=set_option( str(LANG_REC_BUTTON_PLAY),
+                     &global_settings.user_action3, INT, names, 6, NULL);
+     return ret;
+ }
+ 
+ static bool button_config_menu(void)
+ {
+     int m;
+     bool result;
+ 
+     static const struct menu_item items[] = {
+         { ID2P(LANG_REC_BUTTON_SHORT), rec_button_short },
+         { ID2P(LANG_REC_BUTTON_LONG),  rec_button_long  },
+         { ID2P(LANG_REC_BUTTON_PLAY), rec_button_play   },
+     };
+      m=menu_init( items, sizeof(items) / sizeof(*items), NULL,
+                  NULL, NULL, NULL);
+     result = menu_run(m);
+     menu_exit(m);
+     return result;
+ }
+ #endif  /* rec button */
  
  static bool system_settings_menu(void)
  {
***************
*** 2212,2217 ****
--- 2276,2284 ----
  #ifdef CONFIG_CHARGING
          { ID2P(LANG_CAR_ADAPTER_MODE), car_adapter_mode       },
  #endif
+ #if (CONFIG_KEYPAD == IRIVER_H100_PAD) || (CONFIG_KEYPAD == IRIVER_H300_PAD)
+         { ID2P(LANG_BUTTON_CONFIG), button_config_menu        },
+ #endif
      };
  
      m=menu_init( items, sizeof(items) / sizeof(*items), NULL,

*** /home/simon/rockbox-clean/apps/tree.c	2006-12-08 14:55:14.000000000 +0100
--- /home/simon/rockbox-devel/apps/tree.c	2006-12-11 15:55:24.000000000 +0100
***************
*** 53,58 ****
--- 53,59 ----
  #include "plugin.h"
  #include "power.h"
  #include "action.h"
+ #include "user_action.h"
  #include "talk.h"
  #include "filetypes.h"
  #include "misc.h"
***************
*** 79,85 ****
  #include "textarea.h"
  #include "action.h"
  
- 
  #if LCD_DEPTH > 1
  #include "backdrop.h"
  #endif
--- 80,85 ----
***************
*** 780,785 ****
--- 780,800 ----
                      exit_func = true;
                  break;
  
+                 /* 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;
+                 if (*tc.dirfilter < NUM_FILTER_MODES)
+                 {
+                     if (user_action(button))
+                         reload_dir = true;
+                     restore = true;
+                 }
+                 break;
+ 
              case ACTION_TREE_WPS:
                  /* don't enter wps from plugin browser etc */
                  if (*tc.dirfilter < NUM_FILTER_MODES)

*** /home/simon/rockbox-clean/apps/user_action.c	2006-12-11 17:44:26.000000000 +0100
--- /home/simon/rockbox-devel/apps/user_action.c	2006-11-08 23:51:05.000000000 +0100
***************
*** 0 ****
--- 1,88 ----
+ /***************************************************************************
+  *             __________               __   ___.
+  *   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"
+ 
+ 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;
+ }
+ 
+ bool user_action(int button) {
+     bool ret;
+     ret= false;
+     switch (get_user_action(button))
+     {
+         case 0: /* none */
+             ret = false;
+             break;
+         case 1:                         /* Playlist */
+             gui_syncstatusbar_draw(&statusbars,true);
+             if (playlist_viewer())
+                 ret = true;
+             break;
+         case 2:                         /* plugins */
+             gui_syncstatusbar_draw(&statusbars,true);
+             ret = rockbox_browse(PLUGIN_DIR, SHOW_PLUGINS);
+             break;
+         case 3:                         /* themes */
+             gui_syncstatusbar_draw(&statusbars,true);
+             ret = rockbox_browse(THEME_DIR, SHOW_CFG);
+             break;
+         case 4:                         /* recording screen */
+             gui_syncstatusbar_draw(&statusbars,true);
+             recording_screen(false);
+             if (rec_menu())
+                 ret = true;
+             break;
+         case 5:                        /* instant recording */
+             gui_syncstatusbar_draw(&statusbars,true);
+             recording_start_automatic = true;
+             recording_screen(false);
+             recording_start_automatic = false;
+             if (rec_menu())
+                 ret = true;
+             break;
+         default:
+             ret = false;
+     }
+     return ret;
+ }
+ 
+ bool user_action_none(int button)
+ {
+     if (get_user_action(button) == 0)
+         return true;
+     else
+         return false;
+ }
+         

*** /home/simon/rockbox-clean/apps/user_action.h	2006-12-11 17:44:34.000000000 +0100
--- /home/simon/rockbox-devel/apps/user_action.h	2006-11-08 23:51:15.000000000 +0100
***************
*** 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 true if usb connected */
+ bool user_action(int button);
+ /* check if user action is "none" */
+ bool user_action_none(int button);
+ 
+ #endif

