Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

support br_abnt2 and Japanese on US keyboard layout #34

Merged
merged 2 commits into from
Jul 28, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 16 additions & 3 deletions libweston/backend-rdp/rdp.c
Original file line number Diff line number Diff line change
Expand Up @@ -1109,7 +1109,7 @@ struct rdp_to_xkb_keyboard_layout rdp_keyboards[] = {
{KBD_IRISH, 0, 0},
{KBD_BOSNIAN_CYRILLIC, "ba", "us"},
{KBD_UNITED_STATES_DVORAK, "us", "dvorak"},
{KBD_PORTUGUESE_BRAZILIAN_ABNT2, "br", "nativo"},
{KBD_PORTUGUESE_BRAZILIAN_ABNT2, "br", "abnt2"},
{KBD_CANADIAN_MULTILINGUAL_STANDARD, "ca", "multix"},
{KBD_GAELIC, "ie", "CloGaelach"},

Expand Down Expand Up @@ -1147,6 +1147,7 @@ convert_rdp_keyboard_to_xkb_rule_names(
break;
}
}

/* Korean keyboard support (KeyboardType 8, LangID 0x412) */
if (KeyboardType == 8 && ((KeyboardLayout & 0xFFFF) == 0x412)) {
/* TODO: PC/AT 101 Enhanced Korean Keyboard (Type B) and (Type C) is not supported yet
Expand All @@ -1160,8 +1161,20 @@ convert_rdp_keyboard_to_xkb_rule_names(
else if (KeyboardSubType == 6) // PC/AT 103 Enhanced Korean Keyboard
xkbRuleNames->variant = "kr106"; // kr(hw_keys)
}
weston_log("%s: matching layout=%s variant=%s options=%s\n", __FUNCTION__,
xkbRuleNames->layout, xkbRuleNames->variant, xkbRuleNames->options);
/* Japanese keyboard layout is used with other than Japanese 106/109 keyboard */
else if (KeyboardType != 7 && ((KeyboardLayout & 0xFFFF) == 0x411)) {
/* when Japanese keyboard layout is used other than Japanese 106/109 keyboard (keyboard type 7),
use "us" layout, since the "jp" layout in xkb expects Japanese 106/109 keyboard layout. */
xkbRuleNames->layout = "us";
xkbRuleNames->variant = 0;
}
/* Brazilian ABNT2 keyboard */
else if (KeyboardLayout == KBD_PORTUGUESE_BRAZILIAN_ABNT2) {
xkbRuleNames->model = "pc105";
}

weston_log("%s: matching model=%s layout=%s variant=%s options=%s\n", __FUNCTION__,
xkbRuleNames->model, xkbRuleNames->layout, xkbRuleNames->variant, xkbRuleNames->options);
}

static BOOL
Expand Down
63 changes: 52 additions & 11 deletions libweston/backend-rdp/rdprail.c
Original file line number Diff line number Diff line change
Expand Up @@ -751,8 +751,8 @@ languageGuid_to_string(const GUID *guid)
} lang_GUID;

static const lang_GUID c_GUID_NULL = GUID_NULL;
static const lang_GUID c_GUID_MSIME_JPN = GUID_MSIME_JPN;
static const lang_GUID c_GUID_MSIME_KOR = GUID_MSIME_KOR;
static const lang_GUID c_GUID_JPNIME = GUID_MSIME_JPN;
static const lang_GUID c_GUID_KORIME = GUID_MSIME_KOR;
static const lang_GUID c_GUID_CHSIME = GUID_CHSIME;
static const lang_GUID c_GUID_CHTIME = GUID_CHTIME;
static const lang_GUID c_GUID_PROFILE_NEWPHONETIC = GUID_PROFILE_NEWPHONETIC;
Expand All @@ -767,10 +767,10 @@ languageGuid_to_string(const GUID *guid)
RPC_STATUS rpc_status;
if (UuidEqual(guid, (GUID *)&c_GUID_NULL, &rpc_status))
return "GUID_NULL";
else if (UuidEqual(guid, (GUID *)&c_GUID_MSIME_JPN, &rpc_status))
return "GUID_MSIME_JPN";
else if (UuidEqual(guid, (GUID *)&c_GUID_MSIME_KOR, &rpc_status))
return "GUID_MSIME_KOR";
else if (UuidEqual(guid, (GUID *)&c_GUID_JPNIME, &rpc_status))
return "GUID_JPNIME";
else if (UuidEqual(guid, (GUID *)&c_GUID_KORIME, &rpc_status))
return "GUID_KORIME";
else if (UuidEqual(guid, (GUID *)&c_GUID_CHSIME, &rpc_status))
return "GUID_CHSIME";
else if (UuidEqual(guid, (GUID *)&c_GUID_CHTIME, &rpc_status))
Expand Down Expand Up @@ -804,6 +804,9 @@ rail_client_LanguageImeInfo_callback(int fd, uint32_t mask, void *arg)
rdpSettings *settings = client->settings;
RdpPeerContext *peerCtx = (RdpPeerContext *)client->context;
struct rdp_backend *b = peerCtx->rdpBackend;
UINT32 new_keyboard_layout = 0;
struct xkb_keymap *keymap = NULL;
struct xkb_rule_names xkbRuleNames;
char *s;

ASSERT_COMPOSITOR_THREAD(b);
Expand All @@ -829,24 +832,62 @@ rail_client_LanguageImeInfo_callback(int fd, uint32_t mask, void *arg)
rdp_debug(b, "Client: LanguageImeInfo: KeyboardLayout: 0x%x\n", languageImeInfo->KeyboardLayout);

if (languageImeInfo->ProfileType == TF_PROFILETYPE_KEYBOARDLAYOUT) {
struct xkb_rule_names xkbRuleNames;
struct xkb_keymap *keymap = NULL;
settings->KeyboardLayout = languageImeInfo->KeyboardLayout;
new_keyboard_layout = languageImeInfo->KeyboardLayout;
} else if (languageImeInfo->ProfileType == TF_PROFILETYPE_INPUTPROCESSOR) {
typedef struct _lang_GUID
{
UINT32 Data1;
UINT16 Data2;
UINT16 Data3;
BYTE Data4_0;
BYTE Data4_1;
BYTE Data4_2;
BYTE Data4_3;
BYTE Data4_4;
BYTE Data4_5;
BYTE Data4_6;
BYTE Data4_7;
} lang_GUID;

static const lang_GUID c_GUID_JPNIME = GUID_MSIME_JPN;
static const lang_GUID c_GUID_KORIME = GUID_MSIME_KOR;
static const lang_GUID c_GUID_CHSIME = GUID_CHSIME;
static const lang_GUID c_GUID_CHTIME = GUID_CHTIME;

RPC_STATUS rpc_status;
if (UuidEqual(&languageImeInfo->LanguageProfileCLSID,
(GUID *)&c_GUID_JPNIME, &rpc_status))
new_keyboard_layout = KBD_JAPANESE;
else if (UuidEqual(&languageImeInfo->LanguageProfileCLSID,
(GUID *)&c_GUID_KORIME, &rpc_status))
new_keyboard_layout = KBD_KOREAN;
else if (UuidEqual(&languageImeInfo->LanguageProfileCLSID,
(GUID *)&c_GUID_CHSIME, &rpc_status))
new_keyboard_layout = KBD_CHINESE_SIMPLIFIED_US;
else if (UuidEqual(&languageImeInfo->LanguageProfileCLSID,
(GUID *)&c_GUID_CHTIME, &rpc_status))
new_keyboard_layout = KBD_CHINESE_TRADITIONAL_US;
else
new_keyboard_layout = KBD_US;
}

if (new_keyboard_layout && (new_keyboard_layout != settings->KeyboardLayout)) {
convert_rdp_keyboard_to_xkb_rule_names(settings->KeyboardType,
settings->KeyboardSubType,
settings->KeyboardLayout,
new_keyboard_layout,
&xkbRuleNames);
if (xkbRuleNames.layout) {
keymap = xkb_keymap_new_from_names(b->compositor->xkb_context,
&xkbRuleNames, 0);
if (keymap) {
weston_seat_update_keymap(peerCtx->item.seat, keymap);
xkb_keymap_unref(keymap);
settings->KeyboardLayout = new_keyboard_layout;
}
}
if (!keymap) {
rdp_debug_error(b, "%s: Failed to switch to kbd_layout:0x%x kbd_type:0x%x kbd_subType:0x%x\n",
__func__, settings->KeyboardLayout, settings->KeyboardType, settings->KeyboardSubType);
__func__, new_keyboard_layout, settings->KeyboardType, settings->KeyboardSubType);
}
}

Expand Down