Index: apps/filetree.c
===================================================================
RCS file: /cvsroot/rockbox/apps/filetree.c,v
retrieving revision 1.35
diff -u -r1.35 filetree.c
--- apps/filetree.c	21 May 2006 11:00:00 -0000	1.35
+++ apps/filetree.c	23 Jul 2006 12:45:28 -0000
@@ -7,7 +7,7 @@
  *                     \/            \/     \/    \/            \/
  * $Id: filetree.c,v 1.35 2006-05-21 11:00:00 peter Exp $
  *
- * Copyright (C) 2005 by Bj�n Stenberg
+ * Copyright (C) 2005 by Bj�n Stenberg
  *
  * 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.
@@ -516,10 +516,18 @@
 
             case TREE_ATTR_KBD:
                 gui_syncsplash(0, true, str(LANG_WAIT));
-                if (!load_kbd(buf))
+                if (!load_kbd(buf,0))
                     gui_syncsplash(HZ, true, str(LANG_KEYBOARD_LOADED));
                 set_file(buf, (char *)global_settings.kbd_file, MAX_FILENAME);
                 break;
+#if defined(HAVE_REMOTE_LCD) && (NB_SCREENS > 1)
+            case TREE_ATTR_RKBD:
+                gui_syncsplash(0, true, str(LANG_WAIT));
+                if (!load_kbd(buf,1))
+                    gui_syncsplash(HZ, true, str(LANG_KEYBOARD_LOADED));
+                set_file(buf, (char *)global_settings.rkbd_file, MAX_FILENAME);
+                break;
+#endif
 #endif
 
 #ifndef SIMULATOR
Index: apps/keyboard.h
===================================================================
RCS file: /cvsroot/rockbox/apps/keyboard.h,v
retrieving revision 1.2
diff -u -r1.2 keyboard.h
--- apps/keyboard.h	29 Mar 2006 16:21:42 -0000	1.2
+++ apps/keyboard.h	23 Jul 2006 12:45:28 -0000
@@ -7,7 +7,7 @@
  *                     \/            \/     \/    \/            \/
  * $Id: keyboard.h,v 1.2 2006-03-29 16:21:42 phaedrus961 Exp $
  *
- * Copyright (C) 2002 by Bj�n Stenberg
+ * Copyright (C) 2002 by Bj�n Stenberg
  *
  * 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.
@@ -22,7 +22,7 @@
 int kbd_input(char* buffer, int buflen);
 
 #ifdef HAVE_LCD_BITMAP
-int load_kbd(unsigned char* filename);
+int load_kbd(unsigned char* filename, int screen);
 #endif
 
 #endif
Index: apps/settings.c
===================================================================
RCS file: /cvsroot/rockbox/apps/settings.c,v
retrieving revision 1.392
diff -u -r1.392 settings.c
--- apps/settings.c	22 Jul 2006 17:23:05 -0000	1.392
+++ apps/settings.c	23 Jul 2006 12:45:30 -0000
@@ -94,7 +94,7 @@
 #include "dsp.h"
 #endif
 
-#define CONFIG_BLOCK_VERSION 47
+#define CONFIG_BLOCK_VERSION 48
 #define CONFIG_BLOCK_SIZE 512
 #define RTC_BLOCK_SIZE 44
 
@@ -923,6 +923,11 @@
     strncpy((char *)&config_block[i], (char *)global_settings.kbd_file,
             MAX_FILENAME);
     i+= MAX_FILENAME;
+#if defined(HAVE_REMOTE_LCD) && (NB_SCREENS > 1)
+    strncpy((char *)&config_block[i], (char *)global_settings.rkbd_file,
+         MAX_FILENAME);
+    i+= MAX_FILENAME;
+#endif
 #endif
 
     if(save_config_buffer())
@@ -1127,11 +1132,16 @@
          global_settings.kbd_file[0] != 0xff ) {
         snprintf(buf, sizeof buf, ROCKBOX_DIR "/%s.kbd",
                  global_settings.kbd_file);
-        load_kbd(buf);
-    }
-    else
-        load_kbd(NULL);
-
+        load_kbd(buf,0);
+    } else load_kbd(NULL,0);
+#if defined(HAVE_REMOTE_LCD) && (NB_SCREENS > 1)
+    if ( global_settings.rkbd_file[0] &&
+         global_settings.rkbd_file[0] != 0xff ) {
+        snprintf(buf, sizeof buf, ROCKBOX_DIR "/%s.rkbd",
+                global_settings.rkbd_file);
+        load_kbd(buf,1);
+    } else load_kbd(NULL,1);
+#endif
     lcd_scroll_step(global_settings.scroll_step);
     gui_list_screen_scroll_step(global_settings.screen_scroll_step);
     gui_list_screen_scroll_out_of_view(global_settings.offset_out_of_view);
@@ -1293,6 +1303,11 @@
         strncpy((char *)global_settings.kbd_file, (char *)&config_block[i],
                 MAX_FILENAME);
         i+= MAX_FILENAME;
+#if defined(HAVE_REMOTE_LCD) && (NB_SCREENS > 1)
+        strncpy((char *)global_settings.rkbd_file, (char *)&config_block[i],
+                MAX_FILENAME);
+        i+= MAX_FILENAME;
+#endif
 #endif
     }
 }
@@ -1479,11 +1494,16 @@
 #endif
 #ifdef HAVE_LCD_BITMAP
         else if (!strcasecmp(name, "keyboard")) {
-            if (!load_kbd(value))
+            if (!load_kbd(value,0))
                 set_file(value, (char *)global_settings.kbd_file, MAX_FILENAME);
         }
+#if defined(HAVE_REMOTE_LCD) && (NB_SCREENS > 1)
+        else if (!strcasecmp(name, "rkeyboard")) {
+            if (!load_kbd(value,1))
+                set_file(value, (char *)global_settings.rkbd_file, MAX_FILENAME);
+        }
+#endif
 #endif
-
 
         /* check for scalar values, using the two tables */
         pos = load_cfg_table(table[last_table], ta_size[last_table],
@@ -1651,6 +1671,11 @@
     if (global_settings.kbd_file[0] != 0)
         fdprintf(fd, "keyboard: %s/%s.kbd\r\n", ROCKBOX_DIR,
                  global_settings.kbd_file);
+#if defined(HAVE_REMOTE_LCD) && (NB_SCREENS > 1)
+    if (global_settings.rkbd_file[0] != 0)
+        fdprintf(fd, "rkeyboard: %s/%s.rkbd\r\n", ROCKBOX_DIR,
+                 global_settings.rkbd_file);
+#endif
 #endif
 
     /* here's the action: write values to file, specified via table */
Index: apps/settings.h
===================================================================
RCS file: /cvsroot/rockbox/apps/settings.h,v
retrieving revision 1.223
diff -u -r1.223 settings.h
--- apps/settings.h	22 Jul 2006 17:23:05 -0000	1.223
+++ apps/settings.h	23 Jul 2006 12:45:31 -0000
@@ -516,6 +516,9 @@
 
 #ifdef HAVE_LCD_BITMAP
     unsigned char kbd_file[MAX_FILENAME+1]; /* last keyboard */
+#if defined(HAVE_REMOTE_LCD) && (NB_SCREENS > 1)
+    unsigned char rkbd_file[MAX_FILENAME+1]; /* last remote keyboard */
+#endif
 #endif
 };
 
Index: apps/tree.c
===================================================================
RCS file: /cvsroot/rockbox/apps/tree.c,v
retrieving revision 1.417
diff -u -r1.417 tree.c
--- apps/tree.c	18 Jul 2006 18:33:11 -0000	1.417
+++ apps/tree.c	23 Jul 2006 12:45:33 -0000
@@ -108,6 +108,7 @@
     { "wps", TREE_ATTR_WPS, Icon_Wps, VOICE_EXT_WPS },
 #ifdef HAVE_REMOTE_LCD
     { "rwps", TREE_ATTR_RWPS, Icon_Wps, VOICE_EXT_RWPS },
+    { "rkbd", TREE_ATTR_RKBD, Icon_Keyboard, VOICE_EXT_KBD },
 #endif
 #ifdef HAVE_LCD_COLOR
     { "bmp", TREE_ATTR_BMP, Icon_Wps, VOICE_EXT_WPS },
Index: apps/tree.h
===================================================================
RCS file: /cvsroot/rockbox/apps/tree.h,v
retrieving revision 1.73
diff -u -r1.73 tree.h
--- apps/tree.h	10 Apr 2006 03:51:17 -0000	1.73
+++ apps/tree.h	23 Jul 2006 12:45:33 -0000
@@ -238,6 +238,7 @@
 #define TREE_ATTR_BMP   0x1100 /* backdrop bmp file */
 #define TREE_ATTR_KBD   0x1200 /* keyboard file */
 #define TREE_ATTR_FMR   0x1300 /* preset file */
+#define TREE_ATTR_RKBD  0x1400 /* remote-keyboard file */
 #define TREE_ATTR_MASK  0xFF00 /* which bits tree.c uses for file types */
 
 void tree_get_filetypes(const struct filetype**, int*);
Index: apps/recorder/keyboard.c
===================================================================
RCS file: /cvsroot/rockbox/apps/recorder/keyboard.c,v
retrieving revision 1.51
diff -u -r1.51 keyboard.c
--- apps/recorder/keyboard.c	19 Jul 2006 12:07:51 -0000	1.51
+++ apps/recorder/keyboard.c	23 Jul 2006 12:45:37 -0000
@@ -7,7 +7,7 @@
  *                     \/            \/     \/    \/            \/
  * $Id: keyboard.c,v 1.51 2006-07-19 12:07:51 mmmm Exp $
  *
- * Copyright (C) 2002 by Bj�n Stenberg
+ * Copyright (C) 2002 by Bj�n Stenberg
  *
  * 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.
@@ -198,10 +198,11 @@
     int page;
     int x;
     int y;
+    bool kbd_loaded;
 };
 
 struct keyboard_parameters param[NB_SCREENS];
-static bool kbd_loaded = false;
+
 
 #ifdef KBD_MORSE_INPUT
 /* FIXME: We should put this to a configuration file. */
@@ -218,17 +219,16 @@
 
 /* Loads a custom keyboard into memory
    call with NULL to reset keyboard    */
-int load_kbd(unsigned char* filename)
+int load_kbd(unsigned char* filename, int screen)
 {
-    int fd, count, l;
-    int i[NB_SCREENS];
+    int fd, count;
+    int i;
     unsigned char buf[4];
     
-    FOR_NB_SCREENS(l)
-        i[l] = 0;
+    i = 0;
 
     if (filename == NULL) {
-        kbd_loaded = false;
+        param[screen].kbd_loaded = false;
         return 0;
     }
 
@@ -236,40 +236,36 @@
     if (fd < 0)
         return 1;
 
-    FOR_NB_SCREENS(l)
-    {
-        while (read(fd, buf, 1) == 1 && i[l] < KBD_BUF_SIZE) {
-        /* check how many bytes to read */
-            if (buf[0] < 0x80) {
-                count = 0;
-            } else if (buf[0] < 0xe0) {
-                count = 1;
-            } else if (buf[0] < 0xf0) {
-                count = 2;
-            } else if (buf[0] < 0xf5) {
-                count = 3;
-            } else {
-            /* Invalid size. */
-                continue;
-            }
-
-            if (read(fd, &buf[1], count) != count) {
-                close(fd);
-                kbd_loaded = false;
-                return 1;
-            }
+    while (read(fd, buf, 1) == 1 && i < KBD_BUF_SIZE) {
+    /* check how many bytes to read */
+        if (buf[0] < 0x80) {
+            count = 0;
+        } else if (buf[0] < 0xe0) {
+            count = 1;
+        } else if (buf[0] < 0xf0) {
+            count = 2;
+        } else if (buf[0] < 0xf5) {
+            count = 3;
+        } else {
+        /* Invalid size. */
+            continue;
+        }
 
-            utf8decode(buf, &param[l].kbd_buf[i[l]]);
-            if (param[l].kbd_buf[i[l]] != 0xFEFF && param[l].kbd_buf[i[l]] != '\n' &&
-                param[l].kbd_buf[i[l]] != '\r') /*skip BOM & newlines */
-                i[l]++;
+        if (read(fd, &buf[1], count) != count) {
+            close(fd);
+            param[screen].kbd_loaded = false;
+            return 1;
         }
+
+        utf8decode(buf, &param[screen].kbd_buf[i]);
+        if (param[screen].kbd_buf[i] != 0xFEFF && param[screen].kbd_buf[i] != '\n' &&
+            param[screen].kbd_buf[i] != '\r') /*skip BOM & newlines */
+            i++;
     }
 
     close(fd);
-    kbd_loaded = true;
-    FOR_NB_SCREENS(l)
-        param[l].nchars = i[l];
+    param[screen].kbd_loaded = true;
+    param[screen].nchars = i;
     return 0;
 
 }
@@ -409,7 +405,7 @@
     FOR_NB_SCREENS(l)
     {
         i = 0;
-        if (!kbd_loaded) {
+        if (!param[l].kbd_loaded) {
             param[l].curfont = FONT_SYSFIXED;
             p = param[l].default_kbd;
             while (*p != 0) {
@@ -461,7 +457,7 @@
 
     /* calculate keyboard grid size */
         param[l].max_chars = screens[l].width / param[l].font_w;
-        if (!kbd_loaded) {
+        if (!param[l].kbd_loaded) {
             param[l].lines = param[l].DEFAULT_LINES;
             param[l].keyboard_margin = DEFAULT_MARGIN;
         } else {
@@ -478,7 +474,7 @@
 
         param[l].pages = (param[l].nchars + (param[l].lines*param[l].max_chars-1))
              /(param[l].lines*param[l].max_chars);
-        if (param[l].pages == 1 && kbd_loaded)
+        if (param[l].pages == 1 && param[l].kbd_loaded)
             param[l].lines = (param[l].nchars + param[l].max_chars - 1) / param[l].max_chars;
 
         param[l].main_y = param[l].font_h*param[l].lines + param[l].keyboard_margin + statusbar_size;
