Commit 7c2ea163 authored by Rémi Bernon's avatar Rémi Bernon Committed by Alexandre Julliard

win32u: Introduce KbdLayerDescriptor user driver entry.

parent d64ea8e4
......@@ -715,6 +715,15 @@ static SHORT nulldrv_VkKeyScanEx( WCHAR ch, HKL layout )
return -256; /* use default implementation */
}
static const KBDTABLES *nulldrv_KbdLayerDescriptor( HKL layout )
{
return NULL;
}
static void nulldrv_ReleaseKbdTables( const KBDTABLES *tables )
{
}
static UINT nulldrv_ImeProcessKey( HIMC himc, UINT wparam, UINT lparam, const BYTE *state )
{
return 0;
......@@ -1087,6 +1096,16 @@ static SHORT loaderdrv_VkKeyScanEx( WCHAR ch, HKL layout )
return load_driver()->pVkKeyScanEx( ch, layout );
}
static const KBDTABLES *loaderdrv_KbdLayerDescriptor( HKL layout )
{
return load_driver()->pKbdLayerDescriptor( layout );
}
static void loaderdrv_ReleaseKbdTables( const KBDTABLES *tables )
{
return load_driver()->pReleaseKbdTables( tables );
}
static UINT loaderdrv_ImeProcessKey( HIMC himc, UINT wparam, UINT lparam, const BYTE *state )
{
return load_driver()->pImeProcessKey( himc, wparam, lparam, state );
......@@ -1213,6 +1232,8 @@ static const struct user_driver_funcs lazy_load_driver =
loaderdrv_ToUnicodeEx,
loaderdrv_UnregisterHotKey,
loaderdrv_VkKeyScanEx,
loaderdrv_KbdLayerDescriptor,
loaderdrv_ReleaseKbdTables,
loaderdrv_ImeProcessKey,
loaderdrv_ImeToAsciiEx,
loaderdrv_NotifyIMEStatus,
......@@ -1296,6 +1317,8 @@ void __wine_set_user_driver( const struct user_driver_funcs *funcs, UINT version
SET_USER_FUNC(ToUnicodeEx);
SET_USER_FUNC(UnregisterHotKey);
SET_USER_FUNC(VkKeyScanEx);
SET_USER_FUNC(KbdLayerDescriptor);
SET_USER_FUNC(ReleaseKbdTables);
SET_USER_FUNC(ImeProcessKey);
SET_USER_FUNC(ImeToAsciiEx);
SET_USER_FUNC(NotifyIMEStatus);
......
......@@ -1016,13 +1016,16 @@ BOOL WINAPI NtUserSetKeyboardState( BYTE *state )
*/
WORD WINAPI NtUserVkKeyScanEx( WCHAR chr, HKL layout )
{
const KBDTABLES *kbd_tables = &kbdus_tables;
const KBDTABLES *kbd_tables;
SHORT ret;
TRACE_(keyboard)( "chr %s, layout %p\n", debugstr_wn(&chr, 1), layout );
if ((ret = user_driver->pVkKeyScanEx( chr, layout )) != -256) return ret;
if (!(kbd_tables = user_driver->pKbdLayerDescriptor( layout ))) kbd_tables = &kbdus_tables;
ret = kbd_tables_wchar_to_vkey( kbd_tables, chr );
if (kbd_tables != &kbdus_tables) user_driver->pReleaseKbdTables( kbd_tables );
TRACE_(keyboard)( "ret %04x\n", ret );
return ret;
......@@ -1034,14 +1037,16 @@ WORD WINAPI NtUserVkKeyScanEx( WCHAR chr, HKL layout )
*/
UINT WINAPI NtUserMapVirtualKeyEx( UINT code, UINT type, HKL layout )
{
const KBDTABLES *kbd_tables = &kbdus_tables;
BYTE vsc2vk[0x300], vk2char[0x100];
UINT ret;
const KBDTABLES *kbd_tables;
UINT ret = 0;
TRACE_(keyboard)( "code %u, type %u, layout %p.\n", code, type, layout );
if ((ret = user_driver->pMapVirtualKeyEx( code, type, layout )) != -1) return ret;
if (!(kbd_tables = user_driver->pKbdLayerDescriptor( layout ))) kbd_tables = &kbdus_tables;
switch (type)
{
case MAPVK_VK_TO_VSC_EX:
......@@ -1101,9 +1106,11 @@ UINT WINAPI NtUserMapVirtualKeyEx( UINT code, UINT type, HKL layout )
break;
default:
FIXME_(keyboard)( "unknown type %d\n", type );
return 0;
break;
}
if (kbd_tables != &kbdus_tables) user_driver->pReleaseKbdTables( kbd_tables );
TRACE_(keyboard)( "returning 0x%04x\n", ret );
return ret;
}
......@@ -1114,7 +1121,8 @@ UINT WINAPI NtUserMapVirtualKeyEx( UINT code, UINT type, HKL layout )
INT WINAPI NtUserGetKeyNameText( LONG lparam, WCHAR *buffer, INT size )
{
INT code = ((lparam >> 16) & 0x1ff), vkey, len;
const KBDTABLES *kbd_tables = &kbdus_tables;
HKL layout = NtUserGetKeyboardLayout( 0 );
const KBDTABLES *kbd_tables;
VSC_LPWSTR *key_name;
TRACE_(keyboard)( "lparam %#x, buffer %p, size %d.\n", (int)lparam, buffer, size );
......@@ -1122,6 +1130,8 @@ INT WINAPI NtUserGetKeyNameText( LONG lparam, WCHAR *buffer, INT size )
if (!buffer || !size) return 0;
if ((len = user_driver->pGetKeyNameText( lparam, buffer, size )) >= 0) return len;
if (!(kbd_tables = user_driver->pKbdLayerDescriptor( layout ))) kbd_tables = &kbdus_tables;
if (lparam & 0x2000000)
{
BYTE vsc2vk[0x300];
......@@ -1155,6 +1165,8 @@ INT WINAPI NtUserGetKeyNameText( LONG lparam, WCHAR *buffer, INT size )
}
buffer[len] = 0;
if (kbd_tables != &kbdus_tables) user_driver->pReleaseKbdTables( kbd_tables );
TRACE_(keyboard)( "ret %d, str %s.\n", len, debugstr_w(buffer) );
return len;
}
......@@ -1165,7 +1177,7 @@ INT WINAPI NtUserGetKeyNameText( LONG lparam, WCHAR *buffer, INT size )
INT WINAPI NtUserToUnicodeEx( UINT virt, UINT scan, const BYTE *state,
WCHAR *str, int size, UINT flags, HKL layout )
{
const KBDTABLES *kbd_tables = &kbdus_tables;
const KBDTABLES *kbd_tables;
WCHAR buffer[2] = {0};
INT len;
......@@ -1173,9 +1185,9 @@ INT WINAPI NtUserToUnicodeEx( UINT virt, UINT scan, const BYTE *state,
virt, scan, state, str, size, flags, layout );
if (!state) return 0;
if ((len = user_driver->pToUnicodeEx( virt, scan, state, str, size, flags, layout )) >= -1)
return len;
if ((len = user_driver->pToUnicodeEx( virt, scan, state, str, size, flags, layout )) >= -1) return len;
if (!(kbd_tables = user_driver->pKbdLayerDescriptor( layout ))) kbd_tables = &kbdus_tables;
if (scan & 0x8000) buffer[0] = 0; /* key up */
else buffer[0] = kbd_tables_vkey_to_wchar( kbd_tables, virt, state );
......@@ -1184,6 +1196,8 @@ INT WINAPI NtUserToUnicodeEx( UINT virt, UINT scan, const BYTE *state,
lstrcpynW( str, buffer, size );
if (kbd_tables != &kbdus_tables) user_driver->pReleaseKbdTables( kbd_tables );
TRACE_(keyboard)( "ret %d, str %s.\n", len, debugstr_w(str) );
return len;
}
......
......@@ -29,6 +29,7 @@
#include "ntuser.h"
#include "immdev.h"
#include "ddk/d3dkmthk.h"
#include "kbd.h"
#include "wine/list.h"
struct gdi_dc_funcs;
......@@ -292,6 +293,8 @@ struct user_driver_funcs
INT (*pToUnicodeEx)(UINT,UINT,const BYTE *,LPWSTR,int,UINT,HKL);
void (*pUnregisterHotKey)(HWND, UINT, UINT);
SHORT (*pVkKeyScanEx)(WCHAR, HKL);
const KBDTABLES *(*pKbdLayerDescriptor)(HKL);
void (*pReleaseKbdTables)(const KBDTABLES *);
/* IME functions */
UINT (*pImeProcessKey)(HIMC,UINT,UINT,const BYTE*);
UINT (*pImeToAsciiEx)(UINT,UINT,const BYTE*,COMPOSITIONSTRING*,HIMC);
......
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