Implement keymap find.
This commit is contained in:
parent
54a570e0d3
commit
3a922355e3
@ -37,12 +37,7 @@ libguac_client_rdp_la_SOURCES = \
|
|||||||
rdp_fs.c \
|
rdp_fs.c \
|
||||||
rdp_gdi.c \
|
rdp_gdi.c \
|
||||||
rdp_glyph.c \
|
rdp_glyph.c \
|
||||||
rdp_keymap_base.c \
|
|
||||||
rdp_keymap.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_pointer.c \
|
||||||
rdp_settings.c \
|
rdp_settings.c \
|
||||||
unicode.c
|
unicode.c
|
||||||
|
@ -569,40 +569,14 @@ int guac_client_init(guac_client* client, int argc, char** argv) {
|
|||||||
((rdp_freerdp_context*) rdp_inst->context)->client = client;
|
((rdp_freerdp_context*) rdp_inst->context)->client = client;
|
||||||
|
|
||||||
/* Pick keymap based on argument */
|
/* 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 no keymap requested, use default */
|
||||||
if (strcmp("en-us-qwerty", argv[IDX_SERVER_LAYOUT]) == 0)
|
if (settings->server_layout == NULL);
|
||||||
settings->server_layout = &guac_rdp_keymap_en_us;
|
settings->server_layout = guac_rdp_keymap_find(GUAC_DEFAULT_KEYMAP);
|
||||||
|
|
||||||
/* 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;
|
|
||||||
|
|
||||||
/* Load keymap into client */
|
/* Load keymap into client */
|
||||||
__guac_rdp_client_load_keymap(client, settings->server_layout);
|
__guac_rdp_client_load_keymap(client, settings->server_layout);
|
||||||
|
@ -46,3 +46,21 @@ const int GUAC_KEYSYMS_ALL_MODIFIERS[] = {
|
|||||||
0
|
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;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@ -133,6 +133,11 @@ typedef int guac_rdp_keysym_state_map[0x200][0x100];
|
|||||||
[(keysym) & 0xFF] \
|
[(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.
|
* 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[];
|
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
|
#endif
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user