static BOOL wf_pre_connect(freerdp* instance)
{
+ UINT32 rc;
wfContext* wfc;
int desktopWidth;
int desktopHeight;
if (!freerdp_client_load_addins(context->channels, instance->settings))
return -1;
- freerdp_set_param_uint32(settings, FreeRDP_KeyboardLayout,
- (int)GetKeyboardLayout(0) & 0x0000FFFF);
+ rc = freerdp_keyboard_init(freerdp_settings_get_uint32(settings, FreeRDP_KeyboardLayout));
+ freerdp_set_param_uint32(settings, FreeRDP_KeyboardLayout, rc);
PubSub_SubscribeChannelConnected(instance->context->pubSub, wf_OnChannelConnectedEventHandler);
PubSub_SubscribeChannelDisconnected(instance->context->pubSub,
wf_OnChannelDisconnectedEventHandler);
int freerdp_detect_keyboard(DWORD* keyboardLayoutId)
{
+#if defined(_WIN32)
+ CHAR name[KL_NAMELENGTH + 1] = { 0 };
+ if (GetKeyboardLayoutNameA(name))
+ {
+ ULONG rc;
+
+ errno = 0;
+ rc = strtoul(name, NULL, 16);
+ if (errno == 0)
+ *keyboardLayoutId = rc;
+ }
+
+ if (*keyboardLayoutId == 0)
+ *keyboardLayoutId = ((DWORD)GetKeyboardLayout(0) >> 16) & 0x0000FFFF;
+#endif
+
#ifdef WITH_X11
if (*keyboardLayoutId == 0)
freerdp_detect_keyboard_layout_from_xkb(keyboardLayoutId);