From 15ed1f07daf8fa53a06f9adee2d2d17dbf1d1821 Mon Sep 17 00:00:00 2001
From: Felix Zhang <fezhang@suse.com>
Date: Wed, 5 Nov 2014 17:34:29 +0800
Subject: [PATCH] xrdp bnc896931 jp keyboard

Add the Japanese keyboard layout and mapping
---
 common/lang.c    |   3 ++
 sesman/session.c |  12 +++++-
 xrdp/lang.c      | 115 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 129 insertions(+), 1 deletion(-)

diff --git a/common/lang.c /bcommon/lang.c
deleted file mode 100644
index 7e3061b..4695812 100644
--- a/common/lang.c
+++ /bcommon/lang.c
@@ -50,6 +50,9 @@ get_keylayout_name(int keylayout)
     case 0x419: /* russian */
         layout_name = "su";
       break;
+    case 0x411: /* japan */
+        layout_name = "jp";
+      break;
     default:
         layout_name = NULL;
   }
diff --git a/sesman/session.c /bsesman/session.c
deleted file mode 100644
index 92a133d..ebd5e88 100644
--- a/sesman/session.c
+++ /bsesman/session.c
@@ -588,7 +588,7 @@ session_start(int width, int height, int bpp, int layout,
     /*THREAD-FIX unlock chain*/
     lock_chain_release();
     log_message(&(g_cfg->log), LOG_LEVEL_INFO, "max concurrent session limit exceeded. login \
-for user %s denied", username);
+      for user %s denied", username);
     return 0;
   }
 
@@ -1072,6 +1072,16 @@ for user %s denied", username);
 		    }
 		}
 		break;
+	    case 0x411: /* japanese */
+		list_add_item(setxkbmap_params, (long)g_strdup("jp"));
+		for (i = 0; i < g_cfg->dmx_xkb_params.lang->count; i++)
+		{
+		    if (0 == g_strcmp("jp", (char*)list_get_item(g_cfg->dmx_xkb_params.lang, i)))
+		    {
+			list_add_item(setxkbmap_params, (long)g_strdup((char*)list_get_item (g_cfg->dmx_xkb_params.params, i)));
+		    }
+		}
+		break;
 	    default: /* default 0x409 us en */
 		list_add_item(setxkbmap_params, (long)g_strdup("us"));
 		for (i = 0; i < g_cfg->dmx_xkb_params.lang->count; i++)
diff --git a/xrdp/lang.c /bxrdp/lang.c
deleted file mode 100644
index 0341c94..3623a0c 100644
--- a/xrdp/lang.c
+++ /bxrdp/lang.c
@@ -980,6 +980,114 @@ int ru_shiftcapslock[] =
 };
 
 /*****************************************************************************/
+/* japan 0x411 */
+
+/* non shift chars */
+int jp_noshift[] =
+{
+      0,      0,    '1',    '2',    '3',    '4',    '5',    '6',
+    '7',    '8',    '9',    '0',    '-',    '^',      0,      0,
+    'q',    'w',    'e',    'r',    't',    'y',    'u',    'i',
+    'o',    'p',    '@',    '[',      0,      0,    'a',    's',
+    'd',    'f',    'g',    'h',    'j',    'k',    'l',    ';',
+    ':',      0,      0,    ']',    'z',    'x',    'c',    'v',
+    'b',    'n',    'm',    ',',    '.',    '/',      0,    '*',
+      0,    ' ',      0,      0,      0,      0,      0,      0,
+      0,      0,      0,      0,      0,      0,      0,    '7',
+    '8',    '9',    '-',    '4',    '5',    '6',    '+',    '1',
+    '2',    '3',    '0',    '.',      0,      0,      0,      0,
+      0,      0,      0,      0,      0,      0,      0,      0,
+      0,      0,      0,      0,      0,      0,      0,      0,
+      0,      0,      0,      0,      0,      0,      0,      0,
+      0,      0,      0,   '\\',      0,      0,      0,      0,
+      0,      0,      0,      0,      0,   '\\',      0,      0
+};
+
+/* shift chars */
+int jp_shift[] =
+{
+      0,      0,    '!',    '"',    '#',    '$',    '%',    '&',
+   '\'',    '(',    ')',      0,    '=',    '~',      0,      0,
+    'Q',    'W',    'E',    'R',    'T',    'Y',    'U',    'I',
+    'O',    'P',    '`',    '{',      0,      0,    'A',    'S',
+    'D',    'F',    'G',    'H',    'J',    'K',    'L',    '+',
+    '*',      0,      0,    '}',    'Z',    'X',    'C',    'V',
+    'B',    'N',    'M',    '<',    '>',    '?',      0,    '*',
+      0,    ' ',      0,      0,      0,      0,      0,      0,
+      0,      0,      0,      0,      0,      0,      0,    '7',
+    '8',    '9',    '-',    '4',    '5',    '6',    '+',    '1',
+    '2',    '3',    '0',    '.',      0,      0,      0,      0,
+      0,      0,      0,      0,      0,      0,      0,      0,
+      0,      0,      0,      0,      0,      0,      0,      0,
+      0,      0,      0,      0,      0,      0,      0,      0,
+      0,      0,      0,    '_',      0,      0,      0,      0,
+      0,      0,      0,      0,      0,    '|',      0,      0
+};
+
+/* right alt chars */
+int jp_altgr[] =
+{
+      0,      0,      0,      0,      0,      0,      0,      0,
+      0,      0,      0,      0,      0,      0,      0,      0,
+      0,      0,      0,      0,      0,      0,      0,      0,
+      0,      0,      0,      0,      0,      0,      0,      0,
+      0,      0,      0,      0,      0,      0,      0,      0,
+      0,      0,      0,      0,      0,      0,      0,      0,
+      0,      0,      0,      0,      0,      0,      0,      0,
+      0,      0,      0,      0,      0,      0,      0,      0,
+      0,      0,      0,      0,      0,      0,      0,      0,
+      0,      0,      0,      0,      0,      0,      0,      0,
+      0,      0,      0,      0,      0,      0,      0,      0,
+      0,      0,      0,      0,      0,      0,      0,      0,
+      0,      0,      0,      0,      0,      0,      0,      0,
+      0,      0,      0,      0,      0,      0,      0,      0,
+      0,      0,      0,      0,      0,      0,      0,      0,
+      0,      0,      0,      0,      0,      0,      0,      0
+};
+
+/* caps lock chars */
+int jp_capslock[] =
+{
+      0,      0,    '1',    '2',    '3',    '4',    '5',    '6',
+    '7',    '8',    '9',    '0',    '-',    '^',      0,      0,
+    'Q',    'W',    'E',    'R',    'T',    'Y',    'U',    'I',
+    'O',    'P',    '@',    '[',      0,      0,    'A',    'S',
+    'D',    'F',    'G',    'H',    'J',    'K',    'L',    ';',
+    ':',      0,      0,    ']',    'Z',    'X',    'C',    'V',
+    'B',    'N',    'M',    ',',    '.',    '/',      0,    '*',
+      0,    ' ',      0,      0,      0,      0,      0,      0,
+      0,      0,      0,      0,      0,      0,      0,    '7',
+    '8',    '9',    '-',    '4',    '5',    '6',    '+',    '1',
+    '2',    '3',    '0',    '.',      0,      0,      0,      0,
+      0,      0,      0,      0,      0,      0,      0,      0,
+      0,      0,      0,      0,      0,      0,      0,      0,
+      0,      0,      0,      0,      0,      0,      0,      0,
+      0,      0,      0,   '\\',      0,      0,      0,      0,
+      0,      0,      0,      0,      0,   '\\',      0,      0
+};
+
+/* shift caps lock chars */
+int jp_shiftcapslock[] =
+{
+      0,      0,    '!',    '"',    '#',    '$',    '%',    '&',
+   '\'',    '(',    ')',      0,    '=',    '~',      0,      0,
+    'q',    'w',    'e',    'r',    't',    'y',    'u',    'i',
+    'o',    'p',    '`',    '{',      0,      0,    'a',    's',
+    'd',    'f',    'g',    'h',    'j',    'k',    'l',    '+',
+    '*',      0,      0,    '}',    'z',    'x',    'c',    'v',
+    'b',    'n',    'm',    '<',    '>',    '?',      0,    '*',
+      0,    ' ',      0,      0,      0,      0,      0,      0,
+      0,      0,      0,      0,      0,      0,      0,    '7',
+    '8',    '9',    '-',    '4',    '5',    '6',    '+',    '1',
+    '2',    '3',    '0',    '.',      0,      0,      0,      0,
+      0,      0,      0,      0,      0,      0,      0,      0,
+      0,      0,      0,      0,      0,      0,      0,      0,
+      0,      0,      0,      0,      0,      0,      0,      0,
+      0,      0,      0,    '_',      0,      0,      0,      0,
+      0,      0,      0,      0,      0,    '|',      0,      0
+};
+
+/*****************************************************************************/
 twchar APP_CC
 get_char_from_scan_code(int device_flags, int scan_code, int* keys,
                         int caps_lock, int num_lock, int scroll_lock,
@@ -1169,6 +1277,13 @@ get_keymaps(int keylayout, struct xrdp_keymap* keymap)
       g_memcpy(keymap->keys_capslock, ru_capslock, ks);
       g_memcpy(keymap->keys_shiftcapslock, ru_shiftcapslock, ks);
       break;
+    case 0x411: /* japan */
+      g_memcpy(keymap->keys_noshift, jp_noshift, ks);
+      g_memcpy(keymap->keys_shift, jp_shift, ks);
+      g_memcpy(keymap->keys_altgr, jp_altgr, ks);
+      g_memcpy(keymap->keys_capslock, jp_capslock, ks);
+      g_memcpy(keymap->keys_shiftcapslock, jp_shiftcapslock, ks);
+      break;
     default: /* default 0x409 us en */
       g_memcpy(keymap->keys_noshift, en_us_noshift, ks);
       g_memcpy(keymap->keys_shift, en_us_shift, ks);
-- 
2.1.2

