https://git.reactos.org/?p=reactos.git;a=commitdiff;h=4aff6293028ffeb837dce…
commit 4aff6293028ffeb837dce4a6bc58e84c150907f7
Author: Katayama Hirofumi MZ <katayama.hirofumi.mz(a)gmail.com>
AuthorDate: Wed May 10 14:04:01 2023 +0900
Commit: GitHub <noreply(a)github.com>
CommitDate: Wed May 10 14:04:01 2023 +0900
[IMM32][NTUSER][SDK] Add ImmCallImeConsoleIME (#5271)
- Add <jpnvkeys.h>.
- Add imm32!ImmCallImeConsoleIME.
CORE-11700
---
dll/win32/imm32/imm32.spec | 1 +
dll/win32/imm32/keymsg.c | 92 ++++++++++++++++++++++++++++++++++++++++++
sdk/include/reactos/jpnvkeys.h | 27 +++++++++++++
win32ss/user/ntuser/ime.c | 19 +--------
4 files changed, 122 insertions(+), 17 deletions(-)
diff --git a/dll/win32/imm32/imm32.spec b/dll/win32/imm32/imm32.spec
index 77442f45829..92ac837fffd 100644
--- a/dll/win32/imm32/imm32.spec
+++ b/dll/win32/imm32/imm32.spec
@@ -9,6 +9,7 @@
@ stdcall ImmActivateLayout(ptr)
@ stdcall ImmAssociateContext(ptr ptr)
@ stdcall ImmAssociateContextEx(ptr ptr long)
+@ stdcall ImmCallImeConsoleIME(ptr long ptr ptr ptr)
@ stdcall ImmConfigureIMEA(ptr ptr long ptr)
@ stdcall ImmConfigureIMEW(ptr ptr long ptr)
@ stdcall ImmCreateContext()
diff --git a/dll/win32/imm32/keymsg.c b/dll/win32/imm32/keymsg.c
index c759176e7d6..3e05fe416b9 100644
--- a/dll/win32/imm32/keymsg.c
+++ b/dll/win32/imm32/keymsg.c
@@ -10,6 +10,7 @@
*/
#include "precomp.h"
+#include <jpnvkeys.h>
WINE_DEFAULT_DEBUG_CHANNEL(imm);
@@ -1195,3 +1196,94 @@ ImmSendMessageToActiveDefImeWndW(UINT uMsg, WPARAM wParam, LPARAM
lParam)
return SendMessageW(hwndIME, uMsg, wParam, lParam);
}
+
+/***********************************************************************
+ * ImmCallImeConsoleIME (IMM32.@)
+ */
+DWORD WINAPI
+ImmCallImeConsoleIME(
+ _In_ HWND hWnd,
+ _In_ UINT uMsg,
+ _In_ WPARAM wParam,
+ _In_ LPARAM lParam,
+ _Out_ LPUINT puVK)
+{
+ DWORD dwThreadId, ret = 0;
+ HKL hKL;
+ PWND pWnd = NULL;
+ HIMC hIMC;
+ PIMEDPI pImeDpi;
+ UINT uVK;
+ PIMC pIMC;
+
+ switch (uMsg)
+ {
+ case WM_KEYDOWN:
+ case WM_KEYUP:
+ case WM_SYSKEYDOWN:
+ case WM_SYSKEYUP:
+ break;
+
+ default:
+ return 0;
+ }
+
+ dwThreadId = GetWindowThreadProcessId(hWnd, NULL);
+ hKL = GetKeyboardLayout(dwThreadId);
+
+ if (hWnd && gpsi)
+ pWnd = ValidateHwndNoErr(hWnd);
+ if (IS_NULL_UNEXPECTEDLY(pWnd))
+ return 0;
+
+ hIMC = ImmGetContext(hWnd);
+ if (IS_NULL_UNEXPECTEDLY(hIMC))
+ return 0;
+
+ uVK = *puVK = (wParam & 0xFF);
+
+ pIMC = ValidateHandleNoErr(hIMC, TYPE_INPUTCONTEXT);
+ if (IS_NULL_UNEXPECTEDLY(pIMC))
+ return 0;
+
+ pImeDpi = ImmLockImeDpi(hKL);
+ if (IS_NULL_UNEXPECTEDLY(pImeDpi))
+ return 0;
+
+ if ((lParam & MAKELPARAM(0, KF_UP)) && (pImeDpi->ImeInfo.fdwProperty
& IME_PROP_IGNORE_UPKEYS))
+ goto Quit;
+
+ switch (uVK)
+ {
+ case VK_DBE_ROMAN:
+ case VK_DBE_NOROMAN:
+ case VK_DBE_HIRAGANA:
+ case VK_DBE_KATAKANA:
+ case VK_DBE_CODEINPUT:
+ case VK_DBE_NOCODEINPUT:
+ case VK_DBE_ENTERWORDREGISTERMODE:
+ case VK_DBE_ENTERCONFIGMODE:
+ break;
+
+ default:
+ {
+ if (uMsg == WM_SYSKEYDOWN || uMsg == WM_SYSKEYUP)
+ {
+ if (uVK != VK_MENU && uVK != VK_F10)
+ goto Quit;
+ }
+
+ if (!(pImeDpi->ImeInfo.fdwProperty & IME_PROP_NEED_ALTKEY))
+ {
+ if (uVK == VK_MENU || (lParam & MAKELPARAM(0, KF_ALTDOWN)))
+ goto Quit;
+ }
+ }
+ }
+
+ ret = ImmProcessKey(hWnd, hKL, uVK, lParam, INVALID_HOTKEY_ID);
+
+Quit:
+ ImmUnlockImeDpi(pImeDpi);
+ return ret;
+}
diff --git a/sdk/include/reactos/jpnvkeys.h b/sdk/include/reactos/jpnvkeys.h
new file mode 100644
index 00000000000..1f71f04e67b
--- /dev/null
+++ b/sdk/include/reactos/jpnvkeys.h
@@ -0,0 +1,27 @@
+/*
+ * PROJECT: ReactOS header
+ * LICENSE: LGPL-2.0-or-later (
https://spdx.org/licenses/LGPL-2.0-or-later)
+ * PURPOSE: The special virtual keys for Japanese
+ * COPYRIGHT: Copyright 2023 Katayama Hirofumi MZ
<katayama.hirofumi.mz(a)gmail.com>
+ */
+
+#pragma once
+
+/*
+ * The special virtual keys for Japanese: Used for key states.
+ *
https://www.kthree.co.jp/kihelp/index.html?page=app/vkey&type=html
+ */
+#define VK_DBE_ALPHANUMERIC 0xF0
+#define VK_DBE_KATAKANA 0xF1
+#define VK_DBE_HIRAGANA 0xF2
+#define VK_DBE_SBCSCHAR 0xF3
+#define VK_DBE_DBCSCHAR 0xF4
+#define VK_DBE_ROMAN 0xF5
+#define VK_DBE_NOROMAN 0xF6
+#define VK_DBE_ENTERWORDREGISTERMODE 0xF7
+#define VK_DBE_ENTERCONFIGMODE 0xF8
+#define VK_DBE_FLUSHSTRING 0xF9
+#define VK_DBE_CODEINPUT 0xFA
+#define VK_DBE_NOCODEINPUT 0xFB
+#define VK_DBE_DETERINESTRING 0xFC
+#define VK_DBE_ENTERDLGCONVERSIONMODE 0xFD
diff --git a/win32ss/user/ntuser/ime.c b/win32ss/user/ntuser/ime.c
index 5a1eeb86580..5c21f2f9da9 100644
--- a/win32ss/user/ntuser/ime.c
+++ b/win32ss/user/ntuser/ime.c
@@ -8,6 +8,8 @@
*/
#include <win32k.h>
+#include <jpnvkeys.h>
+
DBG_DEFAULT_CHANNEL(UserMisc);
#define INVALID_THREAD_ID ((ULONG)-1)
@@ -21,23 +23,6 @@ DBG_DEFAULT_CHANNEL(UserMisc);
#define LANGID_CHINESE_TRADITIONAL MAKELANGID(LANG_CHINESE,
SUBLANG_CHINESE_TRADITIONAL)
#define LANGID_NEUTRAL MAKELANGID(LANG_NEUTRAL, SUBLANG_NEUTRAL)
-// The special virtual keys for Japanese: Used for key states.
-//
https://www.kthree.co.jp/kihelp/index.html?page=app/vkey&type=html
-#define VK_DBE_ALPHANUMERIC 0xF0
-#define VK_DBE_KATAKANA 0xF1
-#define VK_DBE_HIRAGANA 0xF2
-#define VK_DBE_SBCSCHAR 0xF3
-#define VK_DBE_DBCSCHAR 0xF4
-#define VK_DBE_ROMAN 0xF5
-#define VK_DBE_NOROMAN 0xF6
-#define VK_DBE_ENTERWORDREGISTERMODE 0xF7
-#define VK_DBE_ENTERCONFIGMODE 0xF8
-#define VK_DBE_FLUSHSTRING 0xF9
-#define VK_DBE_CODEINPUT 0xFA
-#define VK_DBE_NOCODEINPUT 0xFB
-#define VK_DBE_DETERINESTRING 0xFC
-#define VK_DBE_ENTERDLGCONVERSIONMODE 0xFD
-
HIMC ghIMC = NULL;
BOOL gfImeOpen = (BOOL)-1;
DWORD gdwImeConversion = (DWORD)-1;