From fc3324151ce51e8a18ce068f229c9f1b02ce8d71 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andr=C3=A9=20Moreau?= Date: Sun, 28 Apr 2013 20:16:04 -0400 Subject: [PATCH] libfreerdp-locale: fix C++ header --- include/freerdp/locale/keyboard.h | 9 +++++++++ libfreerdp/locale/keyboard_layout.c | 25 +++++++++++++++++++++++++ 2 files changed, 34 insertions(+) diff --git a/include/freerdp/locale/keyboard.h b/include/freerdp/locale/keyboard.h index 3e57e0b32..32a7ed5fe 100644 --- a/include/freerdp/locale/keyboard.h +++ b/include/freerdp/locale/keyboard.h @@ -199,10 +199,19 @@ typedef struct _RDP_KEYBOARD_LAYOUT RDP_KEYBOARD_LAYOUT; #define KBD_TYPE_NOKIA_9140 0x00000006 /* Nokia 9140 and similar keyboards */ #define KBD_TYPE_JAPANESE 0x00000007 /* Japanese keyboard */ +#ifdef __cplusplus +extern "C" { +#endif + FREERDP_API DWORD freerdp_keyboard_init(DWORD keyboardLayoutId); FREERDP_API RDP_KEYBOARD_LAYOUT* freerdp_keyboard_get_layouts(DWORD types); FREERDP_API const char* freerdp_keyboard_get_layout_name_from_id(DWORD keyboardLayoutId); +FREERDP_API DWORD freerdp_keyboard_get_layout_id_from_name(const char* name); FREERDP_API DWORD freerdp_keyboard_get_rdp_scancode_from_x11_keycode(DWORD keycode); FREERDP_API DWORD freerdp_keyboard_get_x11_keycode_from_rdp_scancode(DWORD scancode, BOOL extended); +#ifdef __cplusplus +} +#endif + #endif /* FREERDP_LOCALE_KEYBOARD_H */ diff --git a/libfreerdp/locale/keyboard_layout.c b/libfreerdp/locale/keyboard_layout.c index bbc5bbdbf..78e98cf5b 100644 --- a/libfreerdp/locale/keyboard_layout.c +++ b/libfreerdp/locale/keyboard_layout.c @@ -285,3 +285,28 @@ const char* freerdp_keyboard_get_layout_name_from_id(DWORD keyboardLayoutID) return "unknown"; } + +DWORD freerdp_keyboard_get_layout_id_from_name(const char* name) +{ + int i; + + for (i = 0; i < ARRAYSIZE(RDP_KEYBOARD_LAYOUT_TABLE); i++) + { + if (strcmp(RDP_KEYBOARD_LAYOUT_TABLE[i].name, name) == 0) + return RDP_KEYBOARD_LAYOUT_TABLE[i].code; + } + + for (i = 0; i < ARRAYSIZE(RDP_KEYBOARD_LAYOUT_VARIANT_TABLE); i++) + { + if (strcmp(RDP_KEYBOARD_LAYOUT_VARIANT_TABLE[i].name, name) == 0) + return RDP_KEYBOARD_LAYOUT_VARIANT_TABLE[i].code; + } + + for (i = 0; i < ARRAYSIZE(RDP_KEYBOARD_IME_TABLE); i++) + { + if (strcmp(RDP_KEYBOARD_IME_TABLE[i].name, name) == 0) + return RDP_KEYBOARD_IME_TABLE[i].code; + } + + return 0; +}