uint32 freerdp_keyboard_init_x11(uint32 keyboardLayoutId, RDP_SCANCODE x11_keycode_to_rdp_scancode[256]) { uint32 vkcode; uint32 keycode; uint32 keycode_to_vkcode[256]; memset(keycode_to_vkcode, 0, sizeof(keycode_to_vkcode)); memset(x11_keycode_to_rdp_scancode, 0, sizeof(x11_keycode_to_rdp_scancode)); #ifdef __APPLE__ /* Apple X11 breaks XKB detection */ freerdp_keyboard_load_map(keycode_to_vkcode, "macosx(macosx)"); #elif defined(WITH_SUN) { char sunkeymap[32]; freerdp_detect_keyboard_type_and_layout_solaris(sunkeymap, sizeof(sunkeymap)); freerdp_keyboard_load_map(keycode_to_vkcode, sunkeymap); } #else { char* keymap; char* xkb_layout; char* xkb_variant; if (keyboardLayoutId == 0) { keyboardLayoutId = freerdp_detect_keyboard_layout_from_xkb(&xkb_layout, &xkb_variant); xfree(xkb_layout); xfree(xkb_variant); } keymap = freerdp_detect_keymap_from_xkb(); if (keymap != NULL) { freerdp_keyboard_load_maps(keycode_to_vkcode, keymap); xfree(keymap); } } #endif for (keycode = 0; keycode < 256; keycode++) { vkcode = keycode_to_vkcode[keycode]; if (!(vkcode > 0 && vkcode < 256)) continue; x11_keycode_to_rdp_scancode[keycode] = VIRTUAL_KEY_CODE_TO_DEFAULT_RDP_SCANCODE_TABLE[vkcode]; } return keyboardLayoutId; }
uint32 freerdp_keyboard_init_x11(uint32 keyboardLayoutId) { uint32 vkcode; uint32 keycode; uint32 keycode_to_vkcode[256]; memset(keycode_to_vkcode, 0, sizeof(keycode_to_vkcode)); memset(X11_KEYCODE_TO_RDP_SCANCODE, 0, sizeof(X11_KEYCODE_TO_RDP_SCANCODE)); memset(RDP_SCANCODE_TO_X11_KEYCODE, 0, sizeof(RDP_SCANCODE_TO_X11_KEYCODE)); if (keyboardLayoutId == 0) { keyboardLayoutId = freerdp_detect_keyboard_layout_from_system_locale(); DEBUG_KBD("using keyboard layout: %X", keyboardLayoutId); } if (keyboardLayoutId == 0) { keyboardLayoutId = 0x0409; DEBUG_KBD("using default keyboard layout: %X", keyboardLayoutId); } #ifdef __APPLE__ /* Apple X11 breaks XKB detection */ freerdp_keyboard_load_map(keycode_to_vkcode, "macosx(macosx)"); #endif for (keycode = 0; keycode < 256; keycode++) { vkcode = keycode_to_vkcode[keycode]; if (!(vkcode > 0 && vkcode < 256)) continue; X11_KEYCODE_TO_RDP_SCANCODE[keycode].code = VIRTUAL_KEY_CODE_TO_RDP_SCANCODE_TABLE[vkcode].code; X11_KEYCODE_TO_RDP_SCANCODE[keycode].extended = VIRTUAL_KEY_CODE_TO_RDP_SCANCODE_TABLE[vkcode].extended; if (X11_KEYCODE_TO_RDP_SCANCODE[keycode].extended) RDP_SCANCODE_TO_X11_KEYCODE[VIRTUAL_KEY_CODE_TO_RDP_SCANCODE_TABLE[vkcode].code][1] = keycode; else RDP_SCANCODE_TO_X11_KEYCODE[VIRTUAL_KEY_CODE_TO_RDP_SCANCODE_TABLE[vkcode].code][0] = keycode; } return keyboardLayoutId; }
uint32 freerdp_keyboard_init_x11(uint32 keyboardLayoutId) { char* keymap; uint32 vkcode; uint32 keycode; uint32 scancode; boolean extended; char* xkb_layout; char* xkb_variant; uint32 keycode_to_vkcode[256]; memset(keycode_to_vkcode, 0, sizeof(keycode_to_vkcode)); memset(X11_KEYCODE_TO_RDP_SCANCODE, 0, sizeof(X11_KEYCODE_TO_RDP_SCANCODE)); memset(RDP_SCANCODE_TO_X11_KEYCODE, 0, sizeof(RDP_SCANCODE_TO_X11_KEYCODE)); if (keyboardLayoutId == 0) { keyboardLayoutId = freerdp_detect_keyboard_layout_from_system_locale(); DEBUG_KBD("using keyboard layout: %X", keyboardLayoutId); } if (keyboardLayoutId == 0) { keyboardLayoutId = 0x0409; DEBUG_KBD("using default keyboard layout: %X", keyboardLayoutId); } #ifdef __APPLE__ /* Apple X11 breaks XKB detection */ freerdp_keyboard_load_map(keycode_to_vkcode, "macosx(macosx)"); #else if (keyboardLayoutId == 0) keyboardLayoutId = freerdp_detect_keyboard_layout_from_xkb(&xkb_layout, &xkb_variant); keymap = freerdp_detect_keymap_from_xkb(); if (keymap != NULL) freerdp_keyboard_load_maps(keycode_to_vkcode, keymap); #endif for (keycode = 0; keycode < 256; keycode++) { vkcode = keycode_to_vkcode[keycode]; if (!(vkcode > 0 && vkcode < 256)) continue; scancode = VIRTUAL_KEY_CODE_TO_RDP_SCANCODE_TABLE[vkcode]; extended = VIRTUAL_KEY_CODE_TO_DEFAULT_RDP_SCANCODE_TABLE[vkcode].extended; X11_KEYCODE_TO_RDP_SCANCODE[keycode].code = scancode; X11_KEYCODE_TO_RDP_SCANCODE[keycode].extended = extended; if (extended) RDP_SCANCODE_TO_X11_KEYCODE[scancode][1] = keycode; else RDP_SCANCODE_TO_X11_KEYCODE[scancode][0] = keycode; } return keyboardLayoutId; }