mirror of
https://github.com/reactos/reactos.git
synced 2025-02-22 08:25:03 +00:00
[USER32][KBDJA] Implement CliImmSetHotKey (#4504)
- Fix Japanese keyboard about [Shift]+[0] and [半/全] (VK_PROCESSKEY). - Add user32!CliSaveImeHotKey helper function. - Implement user32!CliImmSetHotKey function. This function is forwarded from imm32!ImmSetHotKey. - Fix user32!TranslateMessage by using imm32!ImmTranslateMessage. CORE-11700, CORE-18183, CORE-18182
This commit is contained in:
parent
7396ba84ce
commit
fcc4384554
4 changed files with 119 additions and 24 deletions
|
@ -54,7 +54,7 @@ ROSDATA USHORT scancode_to_vk[] = {
|
|||
VK_LCONTROL,
|
||||
'A', 'S', 'D', 'F',
|
||||
'G', 'H', 'J', 'K',
|
||||
'L', SC_40, SC_41, VK_EMPTY,
|
||||
'L', SC_40, SC_41, VK_PROCESSKEY,
|
||||
VK_LSHIFT, VK_OEM_6,
|
||||
/* - 2c - */
|
||||
/* Third letters row */
|
||||
|
@ -211,7 +211,7 @@ ROSDATA VK_TO_WCHARS2 key_to_chars_2mod[] = {
|
|||
{ '7', 0, {'7', '\''} },
|
||||
{ '8', 0, {'8', '('} },
|
||||
{ '9', 0, {'9', ')'} },
|
||||
{ '0', 0, {'0', 0xff} },
|
||||
{ '0', 0, {'0', 0 } },
|
||||
|
||||
/*Japanese Keys*/
|
||||
{ SC_13, 0, { '^','~'} },
|
||||
|
|
|
@ -1054,15 +1054,6 @@ RegisterIMEClass(VOID)
|
|||
return TRUE;
|
||||
}
|
||||
|
||||
/*
|
||||
* @unimplemented
|
||||
*/
|
||||
BOOL WINAPI CliImmSetHotKey(DWORD dwID, UINT uModifiers, UINT uVirtualKey, HKL hKl)
|
||||
{
|
||||
UNIMPLEMENTED;
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/*
|
||||
* @implemented
|
||||
*/
|
||||
|
|
|
@ -143,6 +143,109 @@ Failure:
|
|||
return FALSE;
|
||||
}
|
||||
|
||||
BOOL APIENTRY
|
||||
CliSaveImeHotKey(DWORD dwID, UINT uModifiers, UINT uVirtualKey, HKL hKL, BOOL bDelete)
|
||||
{
|
||||
WCHAR szName[MAX_PATH];
|
||||
LONG error;
|
||||
HKEY hControlPanel = NULL, hInputMethod = NULL, hHotKeys = NULL, hKey = NULL;
|
||||
BOOL ret = FALSE, bRevertOnFailure = FALSE;
|
||||
|
||||
if (bDelete)
|
||||
{
|
||||
StringCchPrintfW(szName, _countof(szName),
|
||||
L"Control Panel\\Input Method\\Hot Keys\\%08lX", dwID);
|
||||
error = RegDeleteKeyW(HKEY_CURRENT_USER, szName);
|
||||
return (error == ERROR_SUCCESS);
|
||||
}
|
||||
|
||||
// Open "Control Panel"
|
||||
error = RegCreateKeyExW(HKEY_CURRENT_USER, L"Control Panel", 0, NULL, 0, KEY_ALL_ACCESS,
|
||||
NULL, &hControlPanel, NULL);
|
||||
if (error == ERROR_SUCCESS)
|
||||
{
|
||||
// Open "Input Method"
|
||||
error = RegCreateKeyExW(hControlPanel, L"Input Method", 0, NULL, 0, KEY_ALL_ACCESS,
|
||||
NULL, &hInputMethod, NULL);
|
||||
if (error == ERROR_SUCCESS)
|
||||
{
|
||||
// Open "Hot Keys"
|
||||
error = RegCreateKeyExW(hInputMethod, L"Hot Keys", 0, NULL, 0, KEY_ALL_ACCESS,
|
||||
NULL, &hHotKeys, NULL);
|
||||
if (error == ERROR_SUCCESS)
|
||||
{
|
||||
// Open "Key"
|
||||
StringCchPrintfW(szName, _countof(szName), L"%08lX", dwID);
|
||||
error = RegCreateKeyExW(hHotKeys, szName, 0, NULL, 0, KEY_ALL_ACCESS,
|
||||
NULL, &hKey, NULL);
|
||||
if (error == ERROR_SUCCESS)
|
||||
{
|
||||
bRevertOnFailure = TRUE;
|
||||
|
||||
// Set "Virtual Key"
|
||||
error = RegSetValueExW(hKey, L"Virtual Key", 0, REG_BINARY,
|
||||
(LPBYTE)&uVirtualKey, sizeof(uVirtualKey));
|
||||
if (error == ERROR_SUCCESS)
|
||||
{
|
||||
// Set "Key Modifiers"
|
||||
error = RegSetValueExW(hKey, L"Key Modifiers", 0, REG_BINARY,
|
||||
(LPBYTE)&uModifiers, sizeof(uModifiers));
|
||||
if (error == ERROR_SUCCESS)
|
||||
{
|
||||
// Set "Target IME"
|
||||
error = RegSetValueExW(hKey, L"Target IME", 0, REG_BINARY,
|
||||
(LPBYTE)&hKL, sizeof(hKL));
|
||||
if (error == ERROR_SUCCESS)
|
||||
{
|
||||
// Success!
|
||||
ret = TRUE;
|
||||
bRevertOnFailure = FALSE;
|
||||
}
|
||||
}
|
||||
}
|
||||
RegCloseKey(hKey);
|
||||
}
|
||||
RegCloseKey(hHotKeys);
|
||||
}
|
||||
RegCloseKey(hInputMethod);
|
||||
}
|
||||
RegCloseKey(hControlPanel);
|
||||
}
|
||||
|
||||
if (bRevertOnFailure)
|
||||
CliSaveImeHotKey(dwID, uVirtualKey, uModifiers, hKL, TRUE);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
/*
|
||||
* @implemented
|
||||
* Same as imm32!ImmSetHotKey.
|
||||
*/
|
||||
BOOL WINAPI CliImmSetHotKey(DWORD dwID, UINT uModifiers, UINT uVirtualKey, HKL hKL)
|
||||
{
|
||||
BOOL ret;
|
||||
|
||||
if (uVirtualKey == 0) // Delete?
|
||||
{
|
||||
ret = CliSaveImeHotKey(dwID, uModifiers, uVirtualKey, hKL, TRUE);
|
||||
if (ret)
|
||||
CliImmSetHotKeyWorker(dwID, uModifiers, uVirtualKey, hKL, SETIMEHOTKEY_DELETE);
|
||||
return ret;
|
||||
}
|
||||
|
||||
// Add
|
||||
ret = CliImmSetHotKeyWorker(dwID, uModifiers, uVirtualKey, hKL, SETIMEHOTKEY_ADD);
|
||||
if (ret)
|
||||
{
|
||||
ret = CliSaveImeHotKey(dwID, uModifiers, uVirtualKey, hKL, FALSE);
|
||||
if (!ret) // Failure?
|
||||
CliImmSetHotKeyWorker(dwID, uModifiers, uVirtualKey, hKL, SETIMEHOTKEY_DELETE);
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
BOOL FASTCALL CliSetSingleHotKey(LPCWSTR pszSubKey, HANDLE hKey)
|
||||
{
|
||||
LONG error;
|
||||
|
|
|
@ -2825,20 +2825,21 @@ TranslateMessageEx(CONST MSG *lpMsg, UINT Flags)
|
|||
BOOL WINAPI
|
||||
TranslateMessage(CONST MSG *lpMsg)
|
||||
{
|
||||
BOOL Ret = FALSE;
|
||||
BOOL ret;
|
||||
|
||||
// Ref: msdn ImmGetVirtualKey:
|
||||
// http://msdn.microsoft.com/en-us/library/aa912145.aspx
|
||||
/*
|
||||
if ( (LOWORD(lpMsg->wParam) != VK_PROCESSKEY) ||
|
||||
!(Ret = IMM_ImmTranslateMessage( lpMsg->hwnd,
|
||||
lpMsg->message,
|
||||
lpMsg->wParam,
|
||||
lpMsg->lParam)) )*/
|
||||
{
|
||||
Ret = TranslateMessageEx((LPMSG)lpMsg, 0);
|
||||
}
|
||||
return Ret;
|
||||
// http://msdn.microsoft.com/en-us/library/aa912145.aspx
|
||||
if (LOWORD(lpMsg->wParam) == VK_PROCESSKEY)
|
||||
{
|
||||
ret = IMM_FN(ImmTranslateMessage)(lpMsg->hwnd,
|
||||
lpMsg->message,
|
||||
lpMsg->wParam,
|
||||
lpMsg->lParam);
|
||||
if (ret)
|
||||
return ret;
|
||||
}
|
||||
|
||||
ret = TranslateMessageEx((LPMSG)lpMsg, 0);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue