https://git.reactos.org/?p=reactos.git;a=commitdiff;h=fcc4384554a92d9fd3f2c…
commit fcc4384554a92d9fd3f2ce021a363e71c4b5fc45
Author: Katayama Hirofumi MZ <katayama.hirofumi.mz(a)gmail.com>
AuthorDate: Wed May 11 21:42:32 2022 +0900
Commit: GitHub <noreply(a)github.com>
CommitDate: Wed May 11 21:42:32 2022 +0900
[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
---
dll/keyboard/kbdja/kbdja.c | 4 +-
win32ss/user/user32/misc/imm.c | 9 ---
win32ss/user/user32/windows/input.c | 103 ++++++++++++++++++++++++++++++++++
win32ss/user/user32/windows/message.c | 27 ++++-----
4 files changed, 119 insertions(+), 24 deletions(-)
diff --git a/dll/keyboard/kbdja/kbdja.c b/dll/keyboard/kbdja/kbdja.c
index b250b9a1118..ee44d941a1a 100644
--- a/dll/keyboard/kbdja/kbdja.c
+++ b/dll/keyboard/kbdja/kbdja.c
@@ -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, { '^','~'} },
diff --git a/win32ss/user/user32/misc/imm.c b/win32ss/user/user32/misc/imm.c
index 9099235c8ee..83b6b492777 100644
--- a/win32ss/user/user32/misc/imm.c
+++ b/win32ss/user/user32/misc/imm.c
@@ -1054,15 +1054,6 @@ RegisterIMEClass(VOID)
return TRUE;
}
-/*
- * @unimplemented
- */
-BOOL WINAPI CliImmSetHotKey(DWORD dwID, UINT uModifiers, UINT uVirtualKey, HKL hKl)
-{
- UNIMPLEMENTED;
- return FALSE;
-}
-
/*
* @implemented
*/
diff --git a/win32ss/user/user32/windows/input.c b/win32ss/user/user32/windows/input.c
index 4cd7832d7b3..50189f831f4 100644
--- a/win32ss/user/user32/windows/input.c
+++ b/win32ss/user/user32/windows/input.c
@@ -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;
diff --git a/win32ss/user/user32/windows/message.c
b/win32ss/user/user32/windows/message.c
index 1c745cb4584..2740f2e632f 100644
--- a/win32ss/user/user32/windows/message.c
+++ b/win32ss/user/user32/windows/message.c
@@ -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;
}