diff --git a/src/protocols/rdp/keyboard.c b/src/protocols/rdp/keyboard.c index d7e9a37c..2184e02c 100644 --- a/src/protocols/rdp/keyboard.c +++ b/src/protocols/rdp/keyboard.c @@ -244,6 +244,21 @@ void guac_rdp_keyboard_free(guac_rdp_keyboard* keyboard) { free(keyboard); } +int guac_rdp_keyboard_is_defined(guac_rdp_keyboard* keyboard, int keysym) { + + /* Verify keysym can actually be stored within keymap */ + if (!GUAC_RDP_KEYSYM_STORABLE(keysym)) + return 0; + + /* Look up scancode mapping */ + const guac_rdp_keysym_desc* keysym_desc = + &GUAC_RDP_KEYSYM_LOOKUP(keyboard->keymap, keysym); + + /* Return whether the mapping actually exists */ + return keysym_desc->scancode != 0; + +} + int guac_rdp_keyboard_send_event(guac_rdp_keyboard* keyboard, int keysym, int pressed) { diff --git a/src/protocols/rdp/keyboard.h b/src/protocols/rdp/keyboard.h index 8282c18c..d81b47a7 100644 --- a/src/protocols/rdp/keyboard.h +++ b/src/protocols/rdp/keyboard.h @@ -95,6 +95,23 @@ guac_rdp_keyboard* guac_rdp_keyboard_alloc(guac_client* client, */ void guac_rdp_keyboard_free(guac_rdp_keyboard* keyboard); +/** + * Returns whether the given keysym is defined for the keyboard layout + * associated with the given keyboard. + * + * @param keyboard + * The guac_rdp_keyboard instance to check. + * + * @param keysym + * The keysym of the key being checked against the keyboard layout of the + * given keyboard. + * + * @return + * Non-zero if the key is explicitly defined within the keyboard layout of + * the given keyboard, zero otherwise. + */ +int guac_rdp_keyboard_is_defined(guac_rdp_keyboard* keyboard, int keysym); + /** * Sends one or more RDP key events, effectively pressing or releasing the * given keysym on the remote side. The key events sent will depend on the