diff --git a/protocols/rdp/Makefile.am b/protocols/rdp/Makefile.am index ccfae88a..595691f8 100644 --- a/protocols/rdp/Makefile.am +++ b/protocols/rdp/Makefile.am @@ -43,20 +43,22 @@ lib_LTLIBRARIES = libguac-client-rdp.la freerdp_LTLIBRARIES = guac_rdpsnd.la libguac_client_rdp_la_SOURCES = \ - $(OGG_SOURCES) \ - src/audio.c \ - src/client.c \ - src/default_pointer.c \ - src/guac_handlers.c \ - src/rdp_bitmap.c \ - src/rdp_cliprdr.c \ - src/rdp_gdi.c \ - src/rdp_glyph.c \ - src/rdp_keymap_base.c \ - src/rdp_keymap.c \ - src/rdp_keymap_de_de.c \ - src/rdp_keymap_en_us.c \ - src/rdp_pointer.c \ + $(OGG_SOURCES) \ + src/audio.c \ + src/client.c \ + src/default_pointer.c \ + src/guac_handlers.c \ + src/rdp_bitmap.c \ + src/rdp_cliprdr.c \ + src/rdp_gdi.c \ + src/rdp_glyph.c \ + src/rdp_keymap_base.c \ + src/rdp_keymap.c \ + src/rdp_keymap_de_de.c \ + src/rdp_keymap_failsafe.c \ + src/rdp_keymap_fr_fr.c \ + src/rdp_keymap_en_us.c \ + src/rdp_pointer.c \ src/wav_encoder.c guac_rdpsnd_la_SOURCES = \ diff --git a/protocols/rdp/include/rdp_keymap.h b/protocols/rdp/include/rdp_keymap.h index bb26bc2f..f9aa7ecd 100644 --- a/protocols/rdp/include/rdp_keymap.h +++ b/protocols/rdp/include/rdp_keymap.h @@ -122,17 +122,27 @@ typedef guac_rdp_keysym_desc guac_rdp_static_keymap[256][256]; typedef int guac_rdp_keysym_state_map[256][256]; /** - * Map of X11 keysyms to RDP scancodes (US English). + * US English keymap. */ extern const guac_rdp_keymap guac_rdp_keymap_en_us; /** - * Map of X11 keysyms to RDP scancodes (German). + * German keymap. */ extern const guac_rdp_keymap guac_rdp_keymap_de_de; /** - * Map of X11 keysyms to RDP scancodes (common non-printable keys). + * French keymap. + */ +extern const guac_rdp_keymap guac_rdp_keymap_fr_fr; + +/** + * Failsafe (Unicode events for all printable characters) keymap. + */ +extern const guac_rdp_keymap guac_rdp_keymap_failsafe; + +/** + * Common, base keymap for non-printable keys. */ extern const guac_rdp_keymap guac_rdp_keymap_base; @@ -172,6 +182,16 @@ extern const int GUAC_KEYSYMS_ALT[]; */ extern const int GUAC_KEYSYMS_ALL_ALT[]; +/** + * Keysym string containing both "alt" keys. + */ +extern const int GUAC_KEYSYMS_ALL_ALT[]; + +/** + * Keysym string containing the left "alt" and left "ctrl" keys + */ +extern const int GUAC_KEYSYMS_CTRL_ALT[]; + /** * Keysym string containing all modifier keys. */ @@ -180,7 +200,7 @@ extern const int GUAC_KEYSYMS_ALL_MODIFIERS[]; /** * NULL-terminated array of all keymaps. */ -extern const guac_rpd_keymap* GUAC_KEYMAPS[]; +extern const guac_rdp_keymap* GUAC_KEYMAPS[]; #endif diff --git a/protocols/rdp/src/client.c b/protocols/rdp/src/client.c index 66db28ae..842a9bd4 100644 --- a/protocols/rdp/src/client.c +++ b/protocols/rdp/src/client.c @@ -527,16 +527,37 @@ int guac_client_init(guac_client* client, int argc, char** argv) { /* US English Qwerty */ if (strcmp("en-us-qwerty", argv[IDX_LAYOUT]) == 0) - chosen_keymap = &rdp_guac_keymap_en_us; + chosen_keymap = &guac_rdp_keymap_en_us; - /* US English Qwerty */ - if (strcmp("en-us-qwerty", argv[IDX_LAYOUT]) == 0) - chosen_keymap = &rdp_guac_keymap_en_us; + /* German Qwertz */ + else if (strcmp("de-de-qwertz", argv[IDX_LAYOUT]) == 0) + chosen_keymap = &guac_rdp_keymap_de_de; + + /* French Azerty */ + else if (strcmp("fr-fr-azerty", argv[IDX_LAYOUT]) == 0) + chosen_keymap = &guac_rdp_keymap_fr_fr; + + /* Failsafe (Unicode) keymap */ + else if (strcmp("failsafe", argv[IDX_LAYOUT]) == 0) + chosen_keymap = &guac_rdp_keymap_failsafe; + + /* If keymap unknown, resort to failsafe */ + else { + + guac_client_log_error(client, + "Unknown layout \"%s\". Using the failsafe layout instead.", + argv[IDX_LAYOUT]); + + chosen_keymap = &guac_rdp_keymap_failsafe; + + } - else - chosen_keymap = &rdp_guac_keymap_en_us; } + /* If no keymap requested, assume US */ + else + chosen_keymap = &guac_rdp_keymap_en_us; + /* Load keymap into client */ __guac_rdp_client_load_keymap(client, chosen_keymap); diff --git a/protocols/rdp/src/rdp_keymap.c b/protocols/rdp/src/rdp_keymap.c index 8391754f..c5a79c02 100644 --- a/protocols/rdp/src/rdp_keymap.c +++ b/protocols/rdp/src/rdp_keymap.c @@ -46,6 +46,8 @@ const int GUAC_KEYSYMS_ALL_CTRL[] = {0xFFE3, 0xFFE4, 0}; const int GUAC_KEYSYMS_ALT[] = {0xFFE9, 0}; const int GUAC_KEYSYMS_ALL_ALT[] = {0xFFE9, 0xFFEA, 0}; +const int GUAC_KEYSYMS_CTRL_ALT[] = {0xFFE3, 0xFFE9, 0}; + const int GUAC_KEYSYMS_ALL_MODIFIERS[] = { 0xFFE1, 0xFFE2, /* Left and right shift */ 0xFFE3, 0xFFE4, /* Left and right control */ diff --git a/protocols/rdp/src/rdp_keymap_de_de.c b/protocols/rdp/src/rdp_keymap_de_de.c index 1458b22f..3ca6708a 100644 --- a/protocols/rdp/src/rdp_keymap_de_de.c +++ b/protocols/rdp/src/rdp_keymap_de_de.c @@ -57,7 +57,7 @@ static guac_rdp_keysym_desc __guac_rdp_keymap_mapping[] = { /* quotedbl */ { .keysym = 0x0022, .scancode = 0x03, .set_keysyms = GUAC_KEYSYMS_SHIFT }, - + /* numbersign */ { .keysym = 0x0023, .scancode = 0x2b, .clear_keysyms = GUAC_KEYSYMS_ALL_SHIFT }, diff --git a/protocols/rdp/src/rdp_keymap_failsafe.c b/protocols/rdp/src/rdp_keymap_failsafe.c new file mode 100644 index 00000000..e4ecc67c --- /dev/null +++ b/protocols/rdp/src/rdp_keymap_failsafe.c @@ -0,0 +1,63 @@ + +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is libguac-client-rdp. + * + * The Initial Developer of the Original Code is + * Michael Jumper. + * Portions created by the Initial Developer are Copyright (C) 2011 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +#include + +#ifdef HAVE_FREERDP_LOCALE_KEYBOARD_H +#include +#else +#include +#endif + +#include "rdp_keymap.h" + +static guac_rdp_keysym_desc __guac_rdp_keymap_mapping[] = { + + {0} + +}; + +const guac_rdp_keymap guac_rdp_keymap_failsafe = { + + .name = "failsafe", + + .parent = &guac_rdp_keymap_base, + .mapping = __guac_rdp_keymap_mapping, + .freerdp_keyboard_layout = KBD_US + +}; + diff --git a/protocols/rdp/src/rdp_keymap_fr_fr.c b/protocols/rdp/src/rdp_keymap_fr_fr.c index 5df4692b..64de29eb 100644 --- a/protocols/rdp/src/rdp_keymap_fr_fr.c +++ b/protocols/rdp/src/rdp_keymap_fr_fr.c @@ -48,12 +48,6 @@ #include "rdp_keymap.h" -/* - This array is order by .keysym - the .keysym is the ASCII value - the .scancode the key scancode - -*/ static guac_rdp_keysym_desc __guac_rdp_keymap_mapping[] = { /* space */ @@ -85,7 +79,7 @@ static guac_rdp_keysym_desc __guac_rdp_keymap_mapping[] = { /* quoteright */ { .keysym = 0x0027, .scancode = 0x05, - .clear_keysyms = GUAC_KEYSYMS_ALL_SHIFT }, + .clear_keysyms = GUAC_KEYSYMS_ALL_SHIFT }, /* parenleft */ { .keysym = 0x0028, .scancode = 0x06, @@ -477,7 +471,7 @@ static guac_rdp_keysym_desc __guac_rdp_keymap_mapping[] = { /* ugrave */ { .keysym = 0x00f9, .scancode = 0x28, - .clear_keysyms = GUAC_KEYSYMS_ALL_SHIFT }, + .clear_keysyms = GUAC_KEYSYMS_ALL_SHIFT }, /* euro */ { .keysym = 0x10020ac, .scancode = 0x12, @@ -487,7 +481,7 @@ static guac_rdp_keysym_desc __guac_rdp_keymap_mapping[] = { }; -guac_rdp_keymap guac_rdp_keymap_fr_fr = { +const guac_rdp_keymap guac_rdp_keymap_fr_fr = { .name = "fr-fr-azerty",