xwin: Keyboard layout updates

layout zh_TW doesn't exist (anymore), try something else for that.

layout it variant mac doesn't seem to exist anymore, try to handle
Macintosh keyboards (running under Parallels on Mac) and other oddities
in a more generic way, by falling back to matching only on the language
identifer part of the input locale identifer.

v2:
Fix typo of 0xa0000 for 0xa000

Signed-off-by: Jon Turney <jon.turney@dronecode.org.uk>
Reviewed-by: Colin Harrison <colin.harrison@virgin.net>
This commit is contained in:
Jon Turney 2016-02-22 17:41:14 +00:00 committed by Adam Jackson
parent 8c97a0078e
commit 8c2006ddc5
2 changed files with 43 additions and 31 deletions

View File

@ -224,7 +224,8 @@ winConfigKeyboard(DeviceIntPtr pDevice)
{
char layoutName[KL_NAMELENGTH];
unsigned char layoutFriendlyName[256];
static unsigned int layoutNum = 0;
unsigned int layoutNum = 0;
unsigned int deviceIdentifier = 0;
int keyboardType;
#ifdef XWIN_XF86CONFIG
@ -272,15 +273,10 @@ winConfigKeyboard(DeviceIntPtr pDevice)
if (keyboardType > 0 && GetKeyboardLayoutName(layoutName)) {
WinKBLayoutPtr pLayout;
Bool bfound = FALSE;
int pass;
if (!layoutNum)
layoutNum = strtoul(layoutName, (char **) NULL, 16);
layoutNum = strtoul(layoutName, (char **) NULL, 16);
if ((layoutNum & 0xffff) == 0x411) {
/* The japanese layouts know a lot of different IMEs which all have
different layout numbers set. Map them to a single entry.
Same might apply for chinese, korean and other symbol languages
too */
layoutNum = (layoutNum & 0xffff);
if (keyboardType == 7) {
/* Japanese layouts have problems with key event messages
such as the lack of WM_KEYUP for Caps Lock key.
@ -318,31 +314,47 @@ winConfigKeyboard(DeviceIntPtr pDevice)
"Windows keyboard layout: \"%s\" (%08x) \"%s\", type %d\n",
layoutName, layoutNum, layoutFriendlyName, keyboardType);
for (pLayout = winKBLayouts; pLayout->winlayout != -1; pLayout++) {
if (pLayout->winlayout != layoutNum)
continue;
if (pLayout->winkbtype > 0 && pLayout->winkbtype != keyboardType)
continue;
deviceIdentifier = layoutNum >> 16;
for (pass = 0; pass < 2; pass++) {
/* If we didn't find an exact match for the input locale identifer,
try to find an match on the language identifier part only */
if (pass == 1)
layoutNum = (layoutNum & 0xffff);
bfound = TRUE;
winMsg(X_PROBED,
"Found matching XKB configuration \"%s\"\n",
pLayout->layoutname);
for (pLayout = winKBLayouts; pLayout->winlayout != -1; pLayout++) {
if (pLayout->winlayout != layoutNum)
continue;
if (pLayout->winkbtype > 0 && pLayout->winkbtype != keyboardType)
continue;
winMsg(X_PROBED,
"Model = \"%s\" Layout = \"%s\""
" Variant = \"%s\" Options = \"%s\"\n",
pLayout->xkbmodel ? pLayout->xkbmodel : "none",
pLayout->xkblayout ? pLayout->xkblayout : "none",
pLayout->xkbvariant ? pLayout->xkbvariant : "none",
pLayout->xkboptions ? pLayout->xkboptions : "none");
bfound = TRUE;
winMsg(X_PROBED,
"Found matching XKB configuration \"%s\"\n",
pLayout->layoutname);
g_winInfo.xkb.model = pLayout->xkbmodel;
g_winInfo.xkb.layout = pLayout->xkblayout;
g_winInfo.xkb.variant = pLayout->xkbvariant;
g_winInfo.xkb.options = pLayout->xkboptions;
winMsg(X_PROBED,
"Model = \"%s\" Layout = \"%s\""
" Variant = \"%s\" Options = \"%s\"\n",
pLayout->xkbmodel ? pLayout->xkbmodel : "none",
pLayout->xkblayout ? pLayout->xkblayout : "none",
pLayout->xkbvariant ? pLayout->xkbvariant : "none",
pLayout->xkboptions ? pLayout->xkboptions : "none");
break;
g_winInfo.xkb.model = pLayout->xkbmodel;
g_winInfo.xkb.layout = pLayout->xkblayout;
g_winInfo.xkb.variant = pLayout->xkbvariant;
g_winInfo.xkb.options = pLayout->xkboptions;
if (deviceIdentifier == 0xa000) {
winMsg(X_PROBED, "Windows keyboard layout device identifier indicates Macintosh, setting Model = \"macintosh\"");
g_winInfo.xkb.model = "macintosh";
}
break;
}
if (bfound)
break;
}
if (!bfound) {

View File

@ -42,7 +42,8 @@ typedef struct {
*/
WinKBLayoutRec winKBLayouts[] = {
{0x00000404, -1, "pc105", "zh_TW", NULL, NULL, "Chinese (Taiwan)"},
{0x00000404, -1, "pc105", "cn", NULL, NULL, "Chinese (Traditional)"},
{0x00000804, -1, "pc105", "cn", NULL, NULL, "Chinese (Simplified)"},
{0x00000405, -1, "pc105", "cz", NULL, NULL, "Czech"},
{0x00010405, -1, "pc105", "cz_qwerty", NULL, NULL, "Czech (QWERTY)"},
{0x00000406, -1, "pc105", "dk", NULL, NULL, "Danish"},
@ -72,7 +73,6 @@ WinKBLayoutRec winKBLayouts[] = {
{0x0000040f, -1, "pc105", "is", NULL, NULL, "Icelandic"},
{0x00000410, -1, "pc105", "it", NULL, NULL, "Italian"},
{0x00010410, -1, "pc105", "it", NULL, NULL, "Italian (142)"},
{0xa0000410, -1, "macbook79", "it", "mac", NULL, "Italiano (Apple)"},
{0x00000411, 7, "jp106", "jp", NULL, NULL, "Japanese"},
{0x00000412, -1, "kr106", "kr", NULL, NULL, "Korean"},
{0x00000413, -1, "pc105", "nl", NULL, NULL, "Dutch"},