Commit 85e105bd authored by Huw Davies's avatar Huw Davies Committed by Alexandre Julliard

user32: Add a GetKeyboardLayoutList driver entry.

parent a3a19518
......@@ -99,6 +99,7 @@ static const USER_DRIVER *load_driver(void)
GET_USER_FUNC(GetAsyncKeyState);
GET_USER_FUNC(GetKeyNameText);
GET_USER_FUNC(GetKeyboardLayout);
GET_USER_FUNC(GetKeyboardLayoutList);
GET_USER_FUNC(GetKeyboardLayoutName);
GET_USER_FUNC(LoadKeyboardLayout);
GET_USER_FUNC(MapVirtualKeyEx);
......@@ -195,6 +196,64 @@ static SHORT CDECL nulldrv_GetAsyncKeyState( INT key )
return -1;
}
static UINT CDECL nulldrv_GetKeyboardLayoutList( INT size, HKL *layouts )
{
HKEY hKeyKeyboard;
DWORD rc;
INT count = 0;
ULONG_PTR baselayout;
LANGID langid;
static const WCHAR szKeyboardReg[] = {'S','y','s','t','e','m','\\','C','u','r','r','e','n','t','C','o','n','t','r','o','l','S','e','t','\\','C','o','n','t','r','o','l','\\','K','e','y','b','o','a','r','d',' ','L','a','y','o','u','t','s',0};
baselayout = GetUserDefaultLCID();
langid = PRIMARYLANGID(LANGIDFROMLCID(baselayout));
if (langid == LANG_CHINESE || langid == LANG_JAPANESE || langid == LANG_KOREAN)
baselayout |= 0xe001 << 16; /* IME */
else
baselayout |= baselayout << 16;
/* Enumerate the Registry */
rc = RegOpenKeyW(HKEY_LOCAL_MACHINE,szKeyboardReg,&hKeyKeyboard);
if (rc == ERROR_SUCCESS)
{
do {
WCHAR szKeyName[9];
HKL layout;
rc = RegEnumKeyW(hKeyKeyboard, count, szKeyName, 9);
if (rc == ERROR_SUCCESS)
{
layout = (HKL)(ULONG_PTR)strtoulW(szKeyName,NULL,16);
if (baselayout != 0 && layout == (HKL)baselayout)
baselayout = 0; /* found in the registry do not add again */
if (size && layouts)
{
if (count >= size ) break;
layouts[count] = layout;
}
count ++;
}
} while (rc == ERROR_SUCCESS);
RegCloseKey(hKeyKeyboard);
}
/* make sure our base layout is on the list */
if (baselayout != 0)
{
if (size && layouts)
{
if (count < size)
{
layouts[count] = (HKL)baselayout;
count++;
}
}
else
count++;
}
return count;
}
static INT CDECL nulldrv_GetKeyNameText( LONG lparam, LPWSTR buffer, INT size )
{
return 0;
......@@ -455,6 +514,7 @@ static USER_DRIVER null_driver =
nulldrv_GetAsyncKeyState,
nulldrv_GetKeyNameText,
nulldrv_GetKeyboardLayout,
nulldrv_GetKeyboardLayoutList,
nulldrv_GetKeyboardLayoutName,
nulldrv_LoadKeyboardLayout,
nulldrv_MapVirtualKeyEx,
......@@ -542,6 +602,11 @@ static HKL CDECL loaderdrv_GetKeyboardLayout( DWORD thread_id )
return load_driver()->pGetKeyboardLayout( thread_id );
}
static UINT CDECL loaderdrv_GetKeyboardLayoutList( INT size, HKL *layouts )
{
return load_driver()->pGetKeyboardLayoutList( size, layouts );
}
static BOOL CDECL loaderdrv_GetKeyboardLayoutName( LPWSTR name )
{
return load_driver()->pGetKeyboardLayoutName( name );
......@@ -704,6 +769,7 @@ static USER_DRIVER lazy_load_driver =
loaderdrv_GetAsyncKeyState,
loaderdrv_GetKeyNameText,
loaderdrv_GetKeyboardLayout,
loaderdrv_GetKeyboardLayoutList,
loaderdrv_GetKeyboardLayoutName,
loaderdrv_LoadKeyboardLayout,
loaderdrv_MapVirtualKeyEx,
......
......@@ -1074,62 +1074,9 @@ BOOL WINAPI BlockInput(BOOL fBlockIt)
*/
UINT WINAPI GetKeyboardLayoutList(INT nBuff, HKL *layouts)
{
HKEY hKeyKeyboard;
DWORD rc;
INT count = 0;
ULONG_PTR baselayout;
LANGID langid;
static const WCHAR szKeyboardReg[] = {'S','y','s','t','e','m','\\','C','u','r','r','e','n','t','C','o','n','t','r','o','l','S','e','t','\\','C','o','n','t','r','o','l','\\','K','e','y','b','o','a','r','d',' ','L','a','y','o','u','t','s',0};
TRACE_(keyboard)("(%d,%p)\n",nBuff,layouts);
baselayout = GetUserDefaultLCID();
langid = PRIMARYLANGID(LANGIDFROMLCID(baselayout));
if (langid == LANG_CHINESE || langid == LANG_JAPANESE || langid == LANG_KOREAN)
baselayout |= 0xe001 << 16; /* IME */
else
baselayout |= baselayout << 16;
/* Enumerate the Registry */
rc = RegOpenKeyW(HKEY_LOCAL_MACHINE,szKeyboardReg,&hKeyKeyboard);
if (rc == ERROR_SUCCESS)
{
do {
WCHAR szKeyName[9];
HKL layout;
rc = RegEnumKeyW(hKeyKeyboard, count, szKeyName, 9);
if (rc == ERROR_SUCCESS)
{
layout = (HKL)(ULONG_PTR)strtoulW(szKeyName,NULL,16);
if (baselayout != 0 && layout == (HKL)baselayout)
baselayout = 0; /* found in the registry do not add again */
if (nBuff && layouts)
{
if (count >= nBuff ) break;
layouts[count] = layout;
}
count ++;
}
} while (rc == ERROR_SUCCESS);
RegCloseKey(hKeyKeyboard);
}
/* make sure our base layout is on the list */
if (baselayout != 0)
{
if (nBuff && layouts)
{
if (count < nBuff)
{
layouts[count] = (HKL)baselayout;
count++;
}
}
else
count++;
}
TRACE_(keyboard)( "(%d, %p)\n", nBuff, layouts );
return count;
return USER_Driver->pGetKeyboardLayoutList( nBuff, layouts );
}
......
......@@ -64,6 +64,7 @@ typedef struct tagUSER_DRIVER {
SHORT (CDECL *pGetAsyncKeyState)(INT);
INT (CDECL *pGetKeyNameText)(LONG, LPWSTR, INT);
HKL (CDECL *pGetKeyboardLayout)(DWORD);
UINT (CDECL *pGetKeyboardLayoutList)(INT, HKL *);
BOOL (CDECL *pGetKeyboardLayoutName)(LPWSTR);
HKL (CDECL *pLoadKeyboardLayout)(LPCWSTR, UINT);
UINT (CDECL *pMapVirtualKeyEx)(UINT, UINT, HKL);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment