xref: /reactos/sdk/include/ddk/immdev.h (revision dfb7e2d6)
1 /*
2  * PROJECT:     ReactOS headers
3  * LICENSE:     LGPL-2.0-or-later (https://spdx.org/licenses/LGPL-2.0-or-later)
4  * PURPOSE:     Providing DDK-compatible <immdev.h> and IME/IMM development helper
5  * COPYRIGHT:   Copyright 2021-2022 Katayama Hirofumi MZ <katayama.hirofumi.mz@gmail.com>
6  */
7 
8 #ifndef _IMMDEV_
9 #define _IMMDEV_
10 
11 #pragma once
12 
13 #include <wingdi.h>
14 #include <imm.h>
15 
16 #ifdef __cplusplus
17 extern "C" {
18 #endif
19 
20 /* wParam for WM_IME_CONTROL */
21 #define IMC_GETCONVERSIONMODE           0x0001
22 #define IMC_GETSENTENCEMODE             0x0003
23 #define IMC_GETOPENSTATUS               0x0005
24 #define IMC_GETSOFTKBDPOS               0x0013
25 #define IMC_SETSOFTKBDPOS               0x0014
26 
27 /* wParam for WM_IME_SYSTEM */
28 #define IMS_NOTIFYIMESHOW       0x05
29 #define IMS_UPDATEIMEUI         0x06
30 #define IMS_SETCANDFORM         0x09
31 #define IMS_SETCOMPFONT         0x0A
32 #define IMS_SETCOMPFORM         0x0B
33 #define IMS_CONFIGURE           0x0D
34 #define IMS_SETOPENSTATUS       0x0F
35 #define IMS_FREELAYOUT          0x11
36 #define IMS_GETCONVSTATUS       0x14
37 #define IMS_IMEHELP             0x15
38 #define IMS_IMEACTIVATE         0x17
39 #define IMS_IMEDEACTIVATE       0x18
40 #define IMS_ACTIVATELAYOUT      0x19
41 #define IMS_GETIMEMENU          0x1C
42 #define IMS_GETCONTEXT          0x1E
43 #define IMS_SENDNOTIFICATION    0x1F
44 #define IMS_COMPLETECOMPSTR     0x20
45 #define IMS_LOADTHREADLAYOUT    0x21
46 #define IMS_SETLANGBAND         0x23
47 #define IMS_UNSETLANGBAND       0x24
48 
49 #define IMMGWL_IMC       0
50 #define IMMGWL_PRIVATE   (sizeof(LONG))
51 
52 #define IMMGWLP_IMC      0
53 #define IMMGWLP_PRIVATE  (sizeof(LONG_PTR))
54 
55 typedef struct _tagINPUTCONTEXT {
56     HWND                hWnd;
57     BOOL                fOpen;
58     POINT               ptStatusWndPos;
59     POINT               ptSoftKbdPos;
60     DWORD               fdwConversion;
61     DWORD               fdwSentence;
62     union   {
63         LOGFONTA        A;
64         LOGFONTW        W;
65     } lfFont;
66     COMPOSITIONFORM     cfCompForm;
67     CANDIDATEFORM       cfCandForm[4];
68     HIMCC               hCompStr;
69     HIMCC               hCandInfo;
70     HIMCC               hGuideLine;
71     HIMCC               hPrivate;
72     DWORD               dwNumMsgBuf;
73     HIMCC               hMsgBuf;
74     DWORD               fdwInit;
75     DWORD               dwReserve[3];
76 } INPUTCONTEXT, *PINPUTCONTEXT, *LPINPUTCONTEXT;
77 
78 #ifdef _WIN64
79 C_ASSERT(offsetof(INPUTCONTEXT, hWnd) == 0x0);
80 C_ASSERT(offsetof(INPUTCONTEXT, fOpen) == 0x8);
81 C_ASSERT(offsetof(INPUTCONTEXT, ptStatusWndPos) == 0xc);
82 C_ASSERT(offsetof(INPUTCONTEXT, ptSoftKbdPos) == 0x14);
83 C_ASSERT(offsetof(INPUTCONTEXT, fdwConversion) == 0x1c);
84 C_ASSERT(offsetof(INPUTCONTEXT, fdwSentence) == 0x20);
85 C_ASSERT(offsetof(INPUTCONTEXT, lfFont) == 0x24);
86 C_ASSERT(offsetof(INPUTCONTEXT, cfCompForm) == 0x80);
87 C_ASSERT(offsetof(INPUTCONTEXT, cfCandForm) == 0x9c);
88 C_ASSERT(offsetof(INPUTCONTEXT, hCompStr) == 0x120);
89 C_ASSERT(offsetof(INPUTCONTEXT, hCandInfo) == 0x128);
90 C_ASSERT(offsetof(INPUTCONTEXT, hGuideLine) == 0x130);
91 C_ASSERT(offsetof(INPUTCONTEXT, hPrivate) == 0x138);
92 C_ASSERT(offsetof(INPUTCONTEXT, dwNumMsgBuf) == 0x140);
93 C_ASSERT(offsetof(INPUTCONTEXT, hMsgBuf) == 0x148);
94 C_ASSERT(offsetof(INPUTCONTEXT, fdwInit) == 0x150);
95 C_ASSERT(offsetof(INPUTCONTEXT, dwReserve) == 0x154);
96 C_ASSERT(sizeof(INPUTCONTEXT) == 0x160);
97 #else
98 C_ASSERT(offsetof(INPUTCONTEXT, hWnd) == 0x0);
99 C_ASSERT(offsetof(INPUTCONTEXT, fOpen) == 0x4);
100 C_ASSERT(offsetof(INPUTCONTEXT, ptStatusWndPos) == 0x8);
101 C_ASSERT(offsetof(INPUTCONTEXT, ptSoftKbdPos) == 0x10);
102 C_ASSERT(offsetof(INPUTCONTEXT, fdwConversion) == 0x18);
103 C_ASSERT(offsetof(INPUTCONTEXT, fdwSentence) == 0x1c);
104 C_ASSERT(offsetof(INPUTCONTEXT, lfFont) == 0x20);
105 C_ASSERT(offsetof(INPUTCONTEXT, cfCompForm) == 0x7c);
106 C_ASSERT(offsetof(INPUTCONTEXT, cfCandForm) == 0x98);
107 C_ASSERT(offsetof(INPUTCONTEXT, hCompStr) == 0x118);
108 C_ASSERT(offsetof(INPUTCONTEXT, hCandInfo) == 0x11c);
109 C_ASSERT(offsetof(INPUTCONTEXT, hGuideLine) == 0x120);
110 C_ASSERT(offsetof(INPUTCONTEXT, hPrivate) == 0x124);
111 C_ASSERT(offsetof(INPUTCONTEXT, dwNumMsgBuf) == 0x128);
112 C_ASSERT(offsetof(INPUTCONTEXT, hMsgBuf) == 0x12c);
113 C_ASSERT(offsetof(INPUTCONTEXT, fdwInit) == 0x130);
114 C_ASSERT(offsetof(INPUTCONTEXT, dwReserve) == 0x134);
115 C_ASSERT(sizeof(INPUTCONTEXT) == 0x140);
116 #endif
117 
118 struct IME_STATE;
119 
120 /* unconfirmed */
121 #ifdef __cplusplus
122 typedef struct INPUTCONTEXTDX : INPUTCONTEXT
123 {
124 #else
125 typedef struct INPUTCONTEXTDX
126 {
127     INPUTCONTEXT;
128 #endif
129     UINT nVKey;
130     BOOL bNeedsTrans;
131     DWORD dwUnknown1;
132     DWORD dwUIFlags;
133     DWORD dwUnknown2;
134     struct IME_STATE *pState;
135     DWORD dwChange;
136     DWORD dwUnknown5;
137 } INPUTCONTEXTDX, *PINPUTCONTEXTDX, *LPINPUTCONTEXTDX;
138 
139 #ifndef _WIN64
140 C_ASSERT(offsetof(INPUTCONTEXTDX, nVKey) == 0x140);
141 C_ASSERT(offsetof(INPUTCONTEXTDX, bNeedsTrans) == 0x144);
142 C_ASSERT(offsetof(INPUTCONTEXTDX, dwUIFlags) == 0x14c);
143 C_ASSERT(offsetof(INPUTCONTEXTDX, pState) == 0x154);
144 C_ASSERT(offsetof(INPUTCONTEXTDX, dwChange) == 0x158);
145 C_ASSERT(sizeof(INPUTCONTEXTDX) == 0x160);
146 #endif
147 
148 // bits of fdwInit of INPUTCONTEXT
149 #define INIT_STATUSWNDPOS               0x00000001
150 #define INIT_CONVERSION                 0x00000002
151 #define INIT_SENTENCE                   0x00000004
152 #define INIT_LOGFONT                    0x00000008
153 #define INIT_COMPFORM                   0x00000010
154 #define INIT_SOFTKBDPOS                 0x00000020
155 
156 // bits for INPUTCONTEXTDX.dwChange
157 #define INPUTCONTEXTDX_CHANGE_OPEN          0x1
158 #define INPUTCONTEXTDX_CHANGE_CONVERSION    0x2
159 #define INPUTCONTEXTDX_CHANGE_SENTENCE      0x4
160 #define INPUTCONTEXTDX_CHANGE_FORCE_OPEN    0x100
161 
162 #ifndef WM_IME_REPORT
163     #define WM_IME_REPORT 0x280
164 #endif
165 
166 // WM_IME_REPORT wParam
167 #define IR_STRINGSTART   0x100
168 #define IR_STRINGEND     0x101
169 #define IR_OPENCONVERT   0x120
170 #define IR_CHANGECONVERT 0x121
171 #define IR_CLOSECONVERT  0x122
172 #define IR_FULLCONVERT   0x123
173 #define IR_IMESELECT     0x130
174 #define IR_STRING        0x140
175 #define IR_DBCSCHAR      0x160
176 #define IR_UNDETERMINE   0x170
177 #define IR_STRINGEX      0x180
178 #define IR_MODEINFO      0x190
179 
180 // for IR_UNDETERMINE
181 typedef struct tagUNDETERMINESTRUCT
182 {
183     DWORD dwSize;
184     UINT  uDefIMESize;
185     UINT  uDefIMEPos;
186     UINT  uUndetTextLen;
187     UINT  uUndetTextPos;
188     UINT  uUndetAttrPos;
189     UINT  uCursorPos;
190     UINT  uDeltaStart;
191     UINT  uDetermineTextLen;
192     UINT  uDetermineTextPos;
193     UINT  uDetermineDelimPos;
194     UINT  uYomiTextLen;
195     UINT  uYomiTextPos;
196     UINT  uYomiDelimPos;
197 } UNDETERMINESTRUCT, *PUNDETERMINESTRUCT, *LPUNDETERMINESTRUCT;
198 
199 LPINPUTCONTEXT WINAPI ImmLockIMC(HIMC);
200 
201 typedef struct IME_SUBSTATE
202 {
203     struct IME_SUBSTATE *pNext;
204     HKL hKL;
205     DWORD dwValue;
206 } IME_SUBSTATE, *PIME_SUBSTATE;
207 
208 #ifndef _WIN64
209 C_ASSERT(sizeof(IME_SUBSTATE) == 0xc);
210 #endif
211 
212 typedef struct IME_STATE
213 {
214     struct IME_STATE *pNext;
215     WORD wLang;
216     WORD fOpen;
217     DWORD dwConversion;
218     DWORD dwSentence;
219     DWORD dwInit;
220     PIME_SUBSTATE pSubState;
221 } IME_STATE, *PIME_STATE;
222 
223 #ifndef _WIN64
224 C_ASSERT(sizeof(IME_STATE) == 0x18);
225 #endif
226 
227 #ifdef __cplusplus
228 } // extern "C"
229 #endif
230 
231 #endif  /* ndef _IMMDEV_ */
232