Пример #1
0
unsigned int freerdp_kbd_init(void* dpy, unsigned int keyboard_layout_id)
{
	memset(x_keycode_to_rdp_scancode, 0, sizeof(x_keycode_to_rdp_scancode));
	memset(rdp_scancode_to_x_keycode, '\0', sizeof(rdp_scancode_to_x_keycode));

#ifdef WITH_XKBFILE
	if (!init_xkb(dpy))
	{
		DEBUG_KBD("Error initializing xkb");
		return 0;
	}
	if (keyboard_layout_id == 0)
	{
		keyboard_layout_id = detect_keyboard_layout_from_xkb(dpy);
		DEBUG_KBD("detect_keyboard_layout_from_xkb: %X", keyboard_layout_id);
	}
	init_keycodes_from_xkb(dpy, x_keycode_to_rdp_scancode, rdp_scancode_to_x_keycode);
#else
	int vkcode;
	int keycode;
	char xkbfile[256];
	KeycodeToVkcode keycodeToVkcode;

	if (keyboard_layout_id == 0)
		keyboard_layout_id = detect_keyboard(dpy, keyboard_layout_id, xkbfile, sizeof(xkbfile));

	DEBUG_KBD("Using keyboard layout 0x%X with xkb name %s and xkbfile %s",
			keyboard_layout_id, get_layout_name(keyboard_layout_id), xkbfile);

	load_keyboard_map(keycodeToVkcode, xkbfile);

	for (keycode = 0; keycode < 256; keycode++)
	{
		vkcode = keycodeToVkcode[keycode];

		DEBUG_KBD("X keycode %3d VK %3d %-19s-> RDP scancode %d/%d",
				keycode, vkcode, virtualKeyboard[vkcode].name,
				virtualKeyboard[vkcode].extended, virtualKeyboard[vkcode].scancode);

		x_keycode_to_rdp_scancode[keycode].keycode = virtualKeyboard[vkcode].scancode;
		x_keycode_to_rdp_scancode[keycode].extended = virtualKeyboard[vkcode].extended;
		x_keycode_to_rdp_scancode[keycode].keyname = virtualKeyboard[vkcode].name;

		if (x_keycode_to_rdp_scancode[keycode].extended)
			rdp_scancode_to_x_keycode[virtualKeyboard[vkcode].scancode][1] = keycode;
		else
			rdp_scancode_to_x_keycode[virtualKeyboard[vkcode].scancode][0] = keycode;
	}
#endif

	return keyboard_layout_id;
}
Пример #2
0
static unsigned int
detect_keyboard(unsigned int keyboardLayoutID, char *xkbfile, size_t xkbfilelength)
{
	xkbfile[0] = '\0';

	if (keyboardLayoutID != 0)
		printf("keyboard layout configuration: %X\n", keyboardLayoutID);

#if defined(sun)
	if(keyboardLayoutID == 0)
	{
		keyboardLayoutID = detect_keyboard_type_and_layout_sunos(xkbfile, xkbfilelength);
		printf("detect_keyboard_type_and_layout_sunos: %X %s\n", keyboardLayoutID, xkbfile);
	}
#endif

	if(keyboardLayoutID == 0)
	{
		keyboardLayoutID = detect_keyboard_layout_from_xkb();
		printf("detect_keyboard_layout_from_xkb: %X\n", keyboardLayoutID);
	}

	if(keyboardLayoutID == 0)
	{
		keyboardLayoutID = detect_keyboard_layout_from_locale();
		printf("detect_keyboard_layout_from_locale: %X\n", keyboardLayoutID);
	}

	if (keyboardLayoutID == 0)
	{
		keyboardLayoutID = 0x0409;
		printf("using default keyboard layout: %X\n", keyboardLayoutID);
	}

	if (xkbfile[0] == '\0')
	{
		detect_keyboard_type_from_xkb(xkbfile, xkbfilelength);
		printf("detect_keyboard_type_from_xkb: %s\n", xkbfile);
	}

	return keyboardLayoutID;
}