GUACAMOLE-313: Add missing keysyms. Track modifier keys only.

This commit is contained in:
Michael Jumper 2017-12-08 12:56:27 -08:00
parent 5b612b856a
commit 5e5f1fcb3e
3 changed files with 66 additions and 24 deletions

View File

@ -30,24 +30,53 @@
* All known keys.
*/
const guaclog_keydef known_keys[] = {
{ 0xFE03, "AltGr" },
{ 0xFE03, "AltGr", "", true },
{ 0xFF08, "Backspace" },
{ 0xFF09, "Tab", "<Tab>" },
{ 0xFF09, "Tab" },
{ 0xFF0B, "Clear" },
{ 0xFF0D, "Return", "\n" },
{ 0xFF13, "Pause" },
{ 0xFF14, "Scroll" },
{ 0xFF15, "SysReq" },
{ 0xFF1B, "Escape" },
{ 0xFF50, "Home" },
{ 0xFF51, "Left" },
{ 0xFF52, "Up" },
{ 0xFF53, "Right" },
{ 0xFF54, "Down" },
{ 0xFF55, "Page Up" },
{ 0xFF56, "Page Down" },
{ 0xFF57, "End" },
{ 0xFF63, "Insert" },
{ 0xFF65, "Undo" },
{ 0xFF6A, "Help" },
{ 0xFF7F, "Num" },
{ 0xFF80, "Space", " " },
{ 0xFF8D, "Enter", "\n" },
{ 0xFF95, "Home" },
{ 0xFF96, "Left" },
{ 0xFF97, "Up" },
{ 0xFF98, "Right" },
{ 0xFF99, "Down" },
{ 0xFF9A, "Page Up" },
{ 0xFF9B, "Page Down" },
{ 0xFF9C, "End" },
{ 0xFF9E, "Insert" },
{ 0xFFAA, "*", "*" },
{ 0xFFAB, "+", "+" },
{ 0xFFAD, "-", "-" },
{ 0xFFAE, ".", "." },
{ 0xFFAF, "/", "/" },
{ 0xFFB0, "0", "0" },
{ 0xFFB1, "1", "1" },
{ 0xFFB2, "2", "2" },
{ 0xFFB3, "3", "3" },
{ 0xFFB4, "4", "4" },
{ 0xFFB5, "5", "5" },
{ 0xFFB6, "6", "6" },
{ 0xFFB7, "7", "7" },
{ 0xFFB8, "8", "8" },
{ 0xFFB9, "9", "9" },
{ 0xFFBE, "F1" },
{ 0xFFBF, "F2" },
{ 0xFFC0, "F3" },
@ -72,20 +101,19 @@ const guaclog_keydef known_keys[] = {
{ 0xFFD3, "F22" },
{ 0xFFD4, "F23" },
{ 0xFFD5, "F24" },
{ 0xFFE1, "Shift", "" },
{ 0xFFE2, "Shift", "" },
{ 0xFFE3, "Ctrl" },
{ 0xFFE4, "Ctrl" },
{ 0xFFE1, "Shift", "", true },
{ 0xFFE2, "Shift", "", true },
{ 0xFFE3, "Ctrl", NULL, true },
{ 0xFFE4, "Ctrl", NULL, true },
{ 0xFFE5, "Caps" },
{ 0xFFE7, "Meta" },
{ 0xFFE8, "Meta" },
{ 0xFFE9, "Alt" },
{ 0xFFEA, "Alt" },
{ 0xFFEB, "Super" },
{ 0xFFEB, "Win" },
{ 0xFFEC, "Super" },
{ 0xFFED, "Hyper" },
{ 0xFFEE, "Hyper" },
{ 0xFFE7, "Meta", NULL, true },
{ 0xFFE8, "Meta", NULL, true },
{ 0xFFE9, "Alt", NULL, true },
{ 0xFFEA, "Alt", NULL, true },
{ 0xFFEB, "Super", NULL, true },
{ 0xFFEC, "Super", NULL, true },
{ 0xFFED, "Hyper", NULL, true },
{ 0xFFEE, "Hyper", NULL, true },
{ 0xFFFF, "Delete" }
};

View File

@ -22,6 +22,8 @@
#include "config.h"
#include <stdbool.h>
/**
* A mapping of X11 keysym to its corresponding human-readable name.
*/
@ -44,6 +46,12 @@ typedef struct guaclog_keydef {
*/
char* value;
/**
* Whether this key is a modifier which may affect the interpretation of
* other keys, and thus should be tracked as it is held down.
*/
bool modifier;
} guaclog_keydef;
/**

View File

@ -217,14 +217,16 @@ int guaclog_state_update_key(guaclog_state* state, int keysym, bool pressed) {
if (keydef == NULL)
return 0;
/* Update tracked key state */
if (guaclog_state_add_key(state, keydef, pressed))
guaclog_keydef_free(keydef);
else
guaclog_state_trim_keys(state);
/* Update tracked key state for modifiers */
if (keydef->modifier) {
if (guaclog_state_add_key(state, keydef, pressed))
guaclog_keydef_free(keydef);
else
guaclog_state_trim_keys(state);
}
/* Output key states only for printable keys */
if (pressed && keydef->value != NULL) {
else if (pressed) {
if (guaclog_state_is_shortcut(state)) {
@ -244,13 +246,17 @@ int guaclog_state_update_key(guaclog_state* state, int keysym, bool pressed) {
}
fprintf(state->output, ">");
fprintf(state->output, "%s>", keydef->value);
}
/* Print the key itself */
else
fprintf(state->output, "%s", keydef->value);
else {
if (keydef->value != NULL)
fprintf(state->output, "%s", keydef->value);
else
fprintf(state->output, "<%s>", keydef->name);
}
}