Implement keymap find.

This commit is contained in:
Michael Jumper 2014-01-02 23:41:16 -08:00
parent 54a570e0d3
commit 3a922355e3
4 changed files with 35 additions and 38 deletions

View File

@ -37,12 +37,7 @@ libguac_client_rdp_la_SOURCES = \
rdp_fs.c \
rdp_gdi.c \
rdp_glyph.c \
rdp_keymap_base.c \
rdp_keymap.c \
rdp_keymap_de_de.c \
rdp_keymap_failsafe.c \
rdp_keymap_fr_fr.c \
rdp_keymap_en_us.c \
rdp_pointer.c \
rdp_settings.c \
unicode.c

View File

@ -569,40 +569,14 @@ int guac_client_init(guac_client* client, int argc, char** argv) {
((rdp_freerdp_context*) rdp_inst->context)->client = client;
/* Pick keymap based on argument */
if (argv[IDX_SERVER_LAYOUT][0] != '\0') {
settings->server_layout = NULL;
if (argv[IDX_SERVER_LAYOUT][0] != '\0')
settings->server_layout =
guac_rdp_keymap_find(argv[IDX_SERVER_LAYOUT]);
/* US English Qwerty */
if (strcmp("en-us-qwerty", argv[IDX_SERVER_LAYOUT]) == 0)
settings->server_layout = &guac_rdp_keymap_en_us;
/* German Qwertz */
else if (strcmp("de-de-qwertz", argv[IDX_SERVER_LAYOUT]) == 0)
settings->server_layout = &guac_rdp_keymap_de_de;
/* French Azerty */
else if (strcmp("fr-fr-azerty", argv[IDX_SERVER_LAYOUT]) == 0)
settings->server_layout = &guac_rdp_keymap_fr_fr;
/* Failsafe (Unicode) keymap */
else if (strcmp("failsafe", argv[IDX_SERVER_LAYOUT]) == 0)
settings->server_layout = &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_SERVER_LAYOUT]);
settings->server_layout = &guac_rdp_keymap_failsafe;
}
}
/* If no keymap requested, assume US */
else
settings->server_layout = &guac_rdp_keymap_en_us;
/* If no keymap requested, use default */
if (settings->server_layout == NULL);
settings->server_layout = guac_rdp_keymap_find(GUAC_DEFAULT_KEYMAP);
/* Load keymap into client */
__guac_rdp_client_load_keymap(client, settings->server_layout);

View File

@ -46,3 +46,21 @@ const int GUAC_KEYSYMS_ALL_MODIFIERS[] = {
0
};
const guac_rdp_keymap* guac_rdp_keymap_find(const char* name) {
/* For each keymap */
const guac_rdp_keymap** current = GUAC_KEYMAPS;
while (current != NULL) {
/* If name matches, done */
if (strcmp((*current)->name, name) == 0)
return *current;
current++;
}
/* Failure */
return NULL;
}

View File

@ -133,6 +133,11 @@ typedef int guac_rdp_keysym_state_map[0x200][0x100];
[(keysym) & 0xFF] \
)
/**
* The name of the default keymap, which MUST exist.
*/
#define GUAC_DEFAULT_KEYMAP "en-us-qwerty"
/**
* Keysym string containing only the left "shift" key.
*/
@ -195,5 +200,10 @@ extern const int GUAC_KEYSYMS_ALL_MODIFIERS[];
*/
extern const guac_rdp_keymap* GUAC_KEYMAPS[];
/**
* Return the keymap having the given name, if any, or NULL otherwise.
*/
const guac_rdp_keymap* guac_rdp_keymap_find(const char* name);
#endif