xref: /reactos/sdk/include/ddk/immdev.h (revision 8ee308d7)
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 typedef struct INPUTCONTEXTDX /* unconfirmed */
121 {
122     INPUTCONTEXT;
123     UINT nVKey;
124     BOOL bNeedsTrans;
125     DWORD dwUnknown1;
126     DWORD dwUIFlags;
127     DWORD dwUnknown2;
128     struct IME_STATE *pState;
129     DWORD dwChange;
130     DWORD dwUnknown5;
131 } INPUTCONTEXTDX, *LPINPUTCONTEXTDX;
132 
133 #ifndef _WIN64
134 C_ASSERT(offsetof(INPUTCONTEXTDX, nVKey) == 0x140);
135 C_ASSERT(offsetof(INPUTCONTEXTDX, bNeedsTrans) == 0x144);
136 C_ASSERT(offsetof(INPUTCONTEXTDX, dwUIFlags) == 0x14c);
137 C_ASSERT(offsetof(INPUTCONTEXTDX, pState) == 0x154);
138 C_ASSERT(offsetof(INPUTCONTEXTDX, dwChange) == 0x158);
139 C_ASSERT(sizeof(INPUTCONTEXTDX) == 0x160);
140 #endif
141 
142 // bits of fdwInit of INPUTCONTEXT
143 #define INIT_STATUSWNDPOS               0x00000001
144 #define INIT_CONVERSION                 0x00000002
145 #define INIT_SENTENCE                   0x00000004
146 #define INIT_LOGFONT                    0x00000008
147 #define INIT_COMPFORM                   0x00000010
148 #define INIT_SOFTKBDPOS                 0x00000020
149 
150 // bits for INPUTCONTEXTDX.dwChange
151 #define INPUTCONTEXTDX_CHANGE_OPEN          0x1
152 #define INPUTCONTEXTDX_CHANGE_CONVERSION    0x2
153 #define INPUTCONTEXTDX_CHANGE_SENTENCE      0x4
154 #define INPUTCONTEXTDX_CHANGE_FORCE_OPEN    0x100
155 
156 #ifndef WM_IME_REPORT
157     #define WM_IME_REPORT 0x280
158 #endif
159 
160 // WM_IME_REPORT wParam
161 #define IR_STRINGSTART   0x100
162 #define IR_STRINGEND     0x101
163 #define IR_OPENCONVERT   0x120
164 #define IR_CHANGECONVERT 0x121
165 #define IR_CLOSECONVERT  0x122
166 #define IR_FULLCONVERT   0x123
167 #define IR_IMESELECT     0x130
168 #define IR_STRING        0x140
169 #define IR_DBCSCHAR      0x160
170 #define IR_UNDETERMINE   0x170
171 #define IR_STRINGEX      0x180
172 #define IR_MODEINFO      0x190
173 
174 // for IR_UNDETERMINE
175 typedef struct tagUNDETERMINESTRUCT
176 {
177     DWORD dwSize;
178     UINT  uDefIMESize;
179     UINT  uDefIMEPos;
180     UINT  uUndetTextLen;
181     UINT  uUndetTextPos;
182     UINT  uUndetAttrPos;
183     UINT  uCursorPos;
184     UINT  uDeltaStart;
185     UINT  uDetermineTextLen;
186     UINT  uDetermineTextPos;
187     UINT  uDetermineDelimPos;
188     UINT  uYomiTextLen;
189     UINT  uYomiTextPos;
190     UINT  uYomiDelimPos;
191 } UNDETERMINESTRUCT, *PUNDETERMINESTRUCT, *LPUNDETERMINESTRUCT;
192 
193 LPINPUTCONTEXT WINAPI ImmLockIMC(HIMC);
194 
195 typedef struct IME_SUBSTATE
196 {
197     struct IME_SUBSTATE *pNext;
198     HKL hKL;
199     DWORD dwValue;
200 } IME_SUBSTATE, *PIME_SUBSTATE;
201 
202 #ifndef _WIN64
203 C_ASSERT(sizeof(IME_SUBSTATE) == 0xc);
204 #endif
205 
206 typedef struct IME_STATE
207 {
208     struct IME_STATE *pNext;
209     WORD wLang;
210     WORD fOpen;
211     DWORD dwConversion;
212     DWORD dwSentence;
213     DWORD dwInit;
214     PIME_SUBSTATE pSubState;
215 } IME_STATE, *PIME_STATE;
216 
217 #ifndef _WIN64
218 C_ASSERT(sizeof(IME_STATE) == 0x18);
219 #endif
220 
221 #ifdef __cplusplus
222 } // extern "C"
223 #endif
224 
225 #endif  /* ndef _IMMDEV_ */
226