From b47c61430be6d9c06e43d6a9e7d22b332933879c Mon Sep 17 00:00:00 2001 From: Michael Jumper Date: Tue, 1 May 2012 09:09:16 -0700 Subject: [PATCH] Embed RDP keyboard layout within keymap (see ticket #126). --- include/rdp_keymap.h | 9 +++++++++ src/client.c | 15 ++++++++++++++- src/rdp_keymap_en_us.c | 4 +++- 3 files changed, 26 insertions(+), 2 deletions(-) diff --git a/include/rdp_keymap.h b/include/rdp_keymap.h index a75e08e..5316b52 100644 --- a/include/rdp_keymap.h +++ b/include/rdp_keymap.h @@ -38,6 +38,8 @@ #ifndef _GUAC_RDP_RDP_KEYMAP_H #define _GUAC_RDP_RDP_KEYMAP_H +#include + /** * Represents a keysym-to-scancode mapping for RDP, with extra information * about the state of prerequisite keysyms. @@ -96,6 +98,13 @@ struct guac_rdp_keymap { */ const guac_rdp_keysym_desc* mapping; + /** + * FreeRDP keyboard layout associated with this + * keymap. If this keymap is selected, this layout + * will be requested from the server. + */ + const uint32 freerdp_keyboard_layout; + }; /** diff --git a/src/client.c b/src/client.c index 1dcd309..aa37ad3 100644 --- a/src/client.c +++ b/src/client.c @@ -218,6 +218,7 @@ void __guac_rdp_client_load_keymap(guac_client* client, rdp_guac_client_data* guac_client_data = (rdp_guac_client_data*) client->data; + /* Get mapping */ const guac_rdp_keysym_desc* mapping = keymap->mapping; @@ -253,6 +254,15 @@ int guac_client_init(guac_client* client, int argc, char** argv) { int port = RDP_DEFAULT_PORT; boolean bitmap_cache; + /** + * Selected server-side keymap. Client will be assumed to also use this + * keymap. Keys will be sent to server based on client input on a + * best-effort basis. + * + * Currently hard-coded to en-us-qwerty. + */ + const guac_rdp_keymap* chosen_keymap = &guac_rdp_keymap_en_us; + if (argc < 8) { guac_protocol_send_error(client->socket, @@ -381,7 +391,10 @@ int guac_client_init(guac_client* client, int argc, char** argv) { ((rdp_freerdp_context*) rdp_inst->context)->client = client; /* Load keymap into client */ - __guac_rdp_client_load_keymap(client, &guac_rdp_keymap_en_us); + __guac_rdp_client_load_keymap(client, chosen_keymap); + + /* Set server-side keymap */ + settings->kbd_layout = chosen_keymap->freerdp_keyboard_layout; /* Connect to RDP server */ if (!freerdp_connect(rdp_inst)) { diff --git a/src/rdp_keymap_en_us.c b/src/rdp_keymap_en_us.c index fa4a634..7be6422 100644 --- a/src/rdp_keymap_en_us.c +++ b/src/rdp_keymap_en_us.c @@ -37,6 +37,7 @@ * ***** END LICENSE BLOCK ***** */ #include +#include #include "rdp_keymap.h" @@ -429,7 +430,8 @@ const guac_rdp_keymap guac_rdp_keymap_en_us = { .name = "en-us-qwerty", .parent = &guac_rdp_keymap_base, - .mapping = __guac_rdp_keymap_mapping + .mapping = __guac_rdp_keymap_mapping, + .freerdp_keyboard_layout = KBD_US }; -- 1.7.10.4