void __guac_rdp_update_keysyms(guac_client* client, const int* keysym_string, int from, int to);
int __guac_rdp_send_keysym(guac_client* client, int keysym, int pressed);
-void __guac_rdp_send_altcode(guac_client* client, const char* altcode);
+void __guac_rdp_send_altcode(guac_client* client, int altcode);
int rdp_guac_client_free_handler(guac_client* client) {
return 0;
}
-void __guac_rdp_send_altcode(guac_client* client, const char* altcode) {
+void __guac_rdp_send_altcode(guac_client* client, int altcode) {
rdp_guac_client_data* guac_client_data = (rdp_guac_client_data*) client->data;
freerdp* rdp_inst = guac_client_data->rdp_inst;
const guac_rdp_keysym_scancode_map* keysym_scancodes = guac_client_data->keysym_scancodes;
+ int i;
/* Lookup scancode for Alt */
int alt = GUAC_RDP_KEYSYM_LOOKUP(*keysym_scancodes, 0xFFE9 /* Alt_L */).scancode;
/* Press Alt */
rdp_inst->input->KeyboardEvent(rdp_inst->input, KBD_FLAGS_DOWN, alt);
- /* For each character in Alt-code ... */
- while (*altcode != '\0') {
+ /* For each character in four-digit Alt-code ... */
+ for (i=0; i<4; i++) {
/* Get scancode of keypad digit */
- int scancode = GUAC_RDP_KEYSYM_LOOKUP(*keysym_scancodes, 0xFFB0 + (*altcode) - '0').scancode;
+ int scancode = GUAC_RDP_KEYSYM_LOOKUP(
+ *keysym_scancodes,
+ 0xFFB0 + (altcode / 1000)
+ ).scancode;
/* Press and release digit */
rdp_inst->input->KeyboardEvent(rdp_inst->input, KBD_FLAGS_DOWN, scancode);
rdp_inst->input->KeyboardEvent(rdp_inst->input, KBD_FLAGS_RELEASE, scancode);
- /* Next character */
- altcode++;
+ /* Shift digits left by one place */
+ altcode = (altcode * 10) % 10000;
+
}
/* Release Alt */
}
- /* If undefined, try to type using Alt-code */
- else {
-
- const guac_rdp_altcode_map* altcode_map = &GUAC_RDP_KEYSYM_LOOKUP(guac_rdp_keysym_altcode, keysym);
- if (altcode_map->altcode != NULL) {
+ /* If undefined but has Alt-code, use Alt-Code */
+ else if (keysym <= 0xFF) {
- /* Only send Alt-code on press */
- if (pressed)
- __guac_rdp_send_altcode(client, altcode_map->altcode);
+ /* NOTE: The Alt-codes are conveniently identical to keysyms. */
- }
-
- /* If no defined Alt-code, log warning */
- else
- guac_client_log_info(client, "unmapped keysym: 0x%x", keysym);
+ /* Only send Alt-code on press */
+ if (pressed)
+ __guac_rdp_send_altcode(client, keysym);
}
+ /* If no defined Alt-code, log warning */
+ else
+ guac_client_log_info(client, "unmapped keysym: 0x%x", keysym);
+
}
return 0;