Do not use addressof in lookup macro. Update keysym state in event handler.

This commit is contained in:
Michael Jumper 2012-03-20 19:47:41 -07:00
parent d5c00f628c
commit 1fc7a9a8cd
2 changed files with 11 additions and 6 deletions

View File

@ -111,7 +111,7 @@ extern const guac_rdp_keysym_altcode_map guac_rdp_keysym_altcode;
/** /**
* Simple macro for referencing the mapped value of an altcode or scancode for a given keysym. * Simple macro for referencing the mapped value of an altcode or scancode for a given keysym.
*/ */
#define GUAC_RDP_KEYSYM_LOOKUP(keysym_mapping, keysym) (&((keysym_mapping)[((keysym) & 0xFF00) >> 8][(keysym) & 0xFF])) #define GUAC_RDP_KEYSYM_LOOKUP(keysym_mapping, keysym) ((keysym_mapping)[((keysym) & 0xFF00) >> 8][(keysym) & 0xFF])
/** /**
* Keysym string containing only the left "shift" key. * Keysym string containing only the left "shift" key.

View File

@ -234,7 +234,7 @@ void __guac_rdp_send_altcode(guac_client* client, const char* altcode) {
const guac_rdp_keysym_scancode_map* keysym_scancodes = guac_client_data->keysym_scancodes; const guac_rdp_keysym_scancode_map* keysym_scancodes = guac_client_data->keysym_scancodes;
/* Lookup scancode for Alt */ /* Lookup scancode for Alt */
int alt = GUAC_RDP_KEYSYM_LOOKUP(*keysym_scancodes, 0xFFE9 /* Alt_L */)->scancode; int alt = GUAC_RDP_KEYSYM_LOOKUP(*keysym_scancodes, 0xFFE9 /* Alt_L */).scancode;
/* Press Alt */ /* Press Alt */
rdp_inst->input->KeyboardEvent(rdp_inst->input, KBD_FLAGS_DOWN, alt); rdp_inst->input->KeyboardEvent(rdp_inst->input, KBD_FLAGS_DOWN, alt);
@ -243,7 +243,7 @@ void __guac_rdp_send_altcode(guac_client* client, const char* altcode) {
while (*altcode != '\0') { while (*altcode != '\0') {
/* Get scancode of keypad digit */ /* 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) - '0').scancode;
/* Press and release digit */ /* Press and release digit */
rdp_inst->input->KeyboardEvent(rdp_inst->input, KBD_FLAGS_DOWN, scancode); rdp_inst->input->KeyboardEvent(rdp_inst->input, KBD_FLAGS_DOWN, scancode);
@ -268,7 +268,7 @@ int __guac_rdp_send_keysym(guac_client* client, int keysym, int pressed) {
if (keysym <= 0xFFFF) { if (keysym <= 0xFFFF) {
/* Look up scancode mapping */ /* Look up scancode mapping */
const guac_rdp_scancode_map* scancode_map = GUAC_RDP_KEYSYM_LOOKUP(*keysym_scancodes, keysym); const guac_rdp_scancode_map* scancode_map = &GUAC_RDP_KEYSYM_LOOKUP(*keysym_scancodes, keysym);
/* If defined, send event */ /* If defined, send event */
if (scancode_map->scancode != 0) { if (scancode_map->scancode != 0) {
@ -293,7 +293,7 @@ int __guac_rdp_send_keysym(guac_client* client, int keysym, int pressed) {
/* If undefined, try to type using Alt-code */ /* If undefined, try to type using Alt-code */
else { else {
const guac_rdp_altcode_map* altcode_map = GUAC_RDP_KEYSYM_LOOKUP(guac_rdp_keysym_altcode, keysym); const guac_rdp_altcode_map* altcode_map = &GUAC_RDP_KEYSYM_LOOKUP(guac_rdp_keysym_altcode, keysym);
if (altcode_map->altcode != NULL) { if (altcode_map->altcode != NULL) {
/* Only send Alt-code on press */ /* Only send Alt-code on press */
@ -323,7 +323,12 @@ void __guac_rdp_send_keysym_string(guac_client* client, const int* keysym_string
int rdp_guac_client_key_handler(guac_client* client, int keysym, int pressed) { int rdp_guac_client_key_handler(guac_client* client, int keysym, int pressed) {
return __guac_rdp_send_keysym(client, keysym, pressed);; rdp_guac_client_data* guac_client_data = (rdp_guac_client_data*) client->data;
/* Update keysym state */
GUAC_RDP_KEYSYM_LOOKUP(guac_client_data->keysym_state, keysym) = pressed;
return __guac_rdp_send_keysym(client, keysym, pressed);
} }