Signed-off-by: Rémi Bernon rbernon@codeweavers.com --- dlls/user32/driver.c | 79 +++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 78 insertions(+), 1 deletion(-)
diff --git a/dlls/user32/driver.c b/dlls/user32/driver.c index 8060baa5df1..65b9388a79a 100644 --- a/dlls/user32/driver.c +++ b/dlls/user32/driver.c @@ -297,7 +297,84 @@ static BOOL CDECL nulldrv_RegisterHotKey( HWND hwnd, UINT modifiers, UINT vk ) static INT CDECL nulldrv_ToUnicodeEx( UINT virt, UINT scan, const BYTE *state, LPWSTR str, int size, UINT flags, HKL layout ) { - return 0; + WCHAR buffer[2]; + BOOL shift = state[VK_SHIFT] & 0x80; + BOOL ctrl = state[VK_CONTROL] & 0x80; + BOOL numlock = state[VK_NUMLOCK] & 0x01; + INT len; + + TRACE_(keyboard)( "virt %u, scan %u, state %p, str %p, size %d, flags %x, layout %p.\n", + virt, scan, state, str, size, flags, layout ); + + buffer[0] = buffer[1] = 0; + + if (scan & 0x8000) return 0; /* key up */ + + if (!ctrl) + { + switch (virt) + { + case VK_BACK: buffer[0] = '\b'; break; + case VK_OEM_1: buffer[0] = shift ? ':' : ';'; break; + case VK_OEM_2: buffer[0] = shift ? '?' : '/'; break; + case VK_OEM_3: buffer[0] = shift ? '~' : '`'; break; + case VK_OEM_4: buffer[0] = shift ? '{' : '['; break; + case VK_OEM_5: buffer[0] = shift ? '|' : '\'; break; + case VK_OEM_6: buffer[0] = shift ? '}' : ']'; break; + case VK_OEM_7: buffer[0] = shift ? '"' : '''; break; + case VK_OEM_COMMA: buffer[0] = shift ? '<' : ','; break; + case VK_OEM_MINUS: buffer[0] = shift ? '_' : '-'; break; + case VK_OEM_PERIOD: buffer[0] = shift ? '>' : '.'; break; + case VK_OEM_PLUS: buffer[0] = shift ? '+' : '='; break; + case VK_RETURN: buffer[0] = '\r'; break; + case VK_SPACE: buffer[0] = ' '; break; + case VK_TAB: buffer[0] = '\t'; break; + case VK_MULTIPLY: buffer[0] = '*'; break; + case VK_ADD: buffer[0] = '+'; break; + case VK_SUBTRACT: buffer[0] = '-'; break; + case VK_DIVIDE: buffer[0] = '/'; break; + default: + if (virt >= '0' && virt <= '9') + { + buffer[0] = shift ? ")!@#$%^&*("[virt - '0'] : virt; + break; + } + if (virt >= 'A' && virt <= 'Z') + { + buffer[0] = shift || (state[VK_CAPITAL] & 0x01) ? virt : virt + 'a' - 'A'; + break; + } + if (virt >= VK_NUMPAD0 && virt <= VK_NUMPAD9 && numlock && !shift) + { + buffer[0] = '0' + virt - VK_NUMPAD0; + break; + } + if (virt == VK_DECIMAL && numlock && !shift) + { + buffer[0] = '.'; + break; + } + break; + } + } + else /* Control codes */ + { + switch (virt) + { + case VK_OEM_4: buffer[0] = 0x1b; break; + case VK_OEM_5: buffer[0] = 0x1c; break; + case VK_OEM_6: buffer[0] = 0x1d; break; + case VK_SUBTRACT: buffer[0] = 0x1e; break; + default: + if (virt >= 'A' && virt <= 'Z') buffer[0] = virt - 'A' + 1; + break; + } + } + + len = wcslen( buffer ); + wcsncpy( str, buffer, size ); + TRACE_(keyboard)( "ret %d, str %s.\n", len, debugstr_wn(str, len) ); + return len; }
static BOOL CDECL nulldrv_UnloadKeyboardLayout( HKL layout )