1 | /* $Id: winkeyboard.cpp,v 1.8 2001-02-19 21:43:18 sandervl Exp $ */
|
---|
2 | /*
|
---|
3 | * Win32 <-> PM key translation
|
---|
4 | *
|
---|
5 | *
|
---|
6 | * Project Odin Software License can be found in LICENSE.TXT
|
---|
7 | *
|
---|
8 | */
|
---|
9 | #include <os2win.h>
|
---|
10 | #include <odin.h>
|
---|
11 | #include <string.h>
|
---|
12 | #include <stdio.h>
|
---|
13 | #include <winkeyboard.h>
|
---|
14 | #include "oslibwin.h"
|
---|
15 | #include <heapstring.h>
|
---|
16 |
|
---|
17 | #define DBG_LOCALLOG DBG_winkeyboard
|
---|
18 | #include "dbglocal.h"
|
---|
19 |
|
---|
20 | BYTE abPMScanToWinVKey[256] =
|
---|
21 | /****************************************************************************/
|
---|
22 | /* PM Scancode * Win32 vkey */
|
---|
23 | /****************************************************************************/
|
---|
24 | /* 0x00 */ { 0x00
|
---|
25 | /* 0x01 PMSCAN_ESC */ , VK_ESCAPE
|
---|
26 | /* 0x02 PMSCAN_ONE */ , VK_1
|
---|
27 | /* 0x03 PMSCAN_TWO */ , VK_2
|
---|
28 | /* 0x04 PMSCAN_THREE */ , VK_3
|
---|
29 | /* 0x05 PMSCAN_FOUR */ , VK_4
|
---|
30 | /* 0x06 PMSCAN_FIVE */ , VK_5
|
---|
31 | /* 0x07 PMSCAN_SIX */ , VK_6
|
---|
32 | /* 0x08 PMSCAN_SEVEN */ , VK_7
|
---|
33 | /* 0x09 PMSCAN_EIGHT */ , VK_8
|
---|
34 | /* 0x0A PMSCAN_NINE */ , VK_9
|
---|
35 | /* 0x0B PMSCAN_ZERO */ , VK_0
|
---|
36 | /* 0x0C PMSCAN_HYPHEN */ , VK_HYPHEN
|
---|
37 | /* 0x0D PMSCAN_EQUAL */ , VK_EQUAL
|
---|
38 | /* 0x0E PMSCAN_BACKSPACE */ , VK_BACK
|
---|
39 | /* 0x0F PMSCAN_TAB */ , VK_TAB
|
---|
40 | /* 0x10 PMSCAN_Q */ , VK_Q
|
---|
41 | /* 0x11 PMSCAN_W */ , VK_W
|
---|
42 | /* 0x12 PMSCAN_E */ , VK_E
|
---|
43 | /* 0x13 PMSCAN_R */ , VK_R
|
---|
44 | /* 0x14 PMSCAN_T */ , VK_T
|
---|
45 | /* 0x15 PMSCAN_Y */ , VK_Y
|
---|
46 | /* 0x16 PMSCAN_U */ , VK_U
|
---|
47 | /* 0x17 PMSCAN_I */ , VK_I
|
---|
48 | /* 0x18 PMSCAN_O */ , VK_O
|
---|
49 | /* 0x19 PMSCAN_P */ , VK_P
|
---|
50 | /* 0x1A PMSCAN_BRACKETLEFT */ , VK_BRACKETLEFT
|
---|
51 | /* 0x1B PMSCAN_BRACKETRIGHT */ , VK_BRACKETRIGHT
|
---|
52 | /* 0x1C PMSCAN_ENTER */ , VK_RETURN
|
---|
53 | /* 0x1D PMSCAN_CTRLLEFT */ , VK_CONTROL
|
---|
54 | /* 0x1E PMSCAN_A */ , VK_A
|
---|
55 | /* 0x1F PMSCAN_S */ , VK_S
|
---|
56 | /* 0x20 PMSCAN_D */ , VK_D
|
---|
57 | /* 0x21 PMSCAN_F */ , VK_F
|
---|
58 | /* 0x22 PMSCAN_G */ , VK_G
|
---|
59 | /* 0x23 PMSCAN_H */ , VK_H
|
---|
60 | /* 0x24 PMSCAN_J */ , VK_J
|
---|
61 | /* 0x25 PMSCAN_K */ , VK_K
|
---|
62 | /* 0x26 PMSCAN_L */ , VK_L
|
---|
63 | /* 0x27 PMSCAN_SEMICOLON */ , VK_SEMICOLON
|
---|
64 | /* 0x28 PMSCAN_QUOTESINGLE */ , VK_QUOTESINGLE
|
---|
65 | /* 0x29 PMSCAN_GRAVE */ , VK_GRAVE
|
---|
66 | /* 0x2A PMSCAN_SHIFTLEFT */ , VK_SHIFT
|
---|
67 | /* 0x2B PMSCAN_BACKSLASH */ , VK_BACKSLASH
|
---|
68 | /* 0x2C PMSCAN_Z */ , VK_Z
|
---|
69 | /* 0x2D PMSCAN_X */ , VK_X
|
---|
70 | /* 0x2E PMSCAN_C */ , VK_C
|
---|
71 | /* 0x2F PMSCAN_V */ , VK_V
|
---|
72 | /* 0x30 PMSCAN_B */ , VK_B
|
---|
73 | /* 0x31 PMSCAN_N */ , VK_N
|
---|
74 | /* 0x32 PMSCAN_M */ , VK_M
|
---|
75 | /* 0x33 PMSCAN_COMMA */ , VK_COMMA
|
---|
76 | /* 0x34 PMSCAN_PERIOD */ , VK_PERIOD
|
---|
77 | /* 0x35 PMSCAN_SLASH */ , VK_SLASH
|
---|
78 | /* 0x36 PMSCAN_SHIFTRIGHT */ , VK_SHIFT
|
---|
79 | /* 0x37 PMSCAN_PADASTERISK */ , VK_MULTIPLY
|
---|
80 | /* 0x38 PMSCAN_ALTLEFT */ , VK_MENU
|
---|
81 | /* 0x39 PMSCAN_SPACE */ , VK_SPACE
|
---|
82 | /* 0x3A PMSCAN_CAPSLOCK */ , VK_CAPITAL
|
---|
83 | /* 0x3B PMSCAN_F1 */ , VK_F1
|
---|
84 | /* 0x3C PMSCAN_F2 */ , VK_F2
|
---|
85 | /* 0x3D PMSCAN_F3 */ , VK_F3
|
---|
86 | /* 0x3E PMSCAN_F4 */ , VK_F4
|
---|
87 | /* 0x3F PMSCAN_F5 */ , VK_F5
|
---|
88 | /* 0x40 PMSCAN_F6 */ , VK_F6
|
---|
89 | /* 0x41 PMSCAN_F7 */ , VK_F7
|
---|
90 | /* 0x42 PMSCAN_F8 */ , VK_F8
|
---|
91 | /* 0x43 PMSCAN_F9 */ , VK_F9
|
---|
92 | /* 0x44 PMSCAN_F10 */ , VK_F10
|
---|
93 | /* 0x45 PMSCAN_NUMLOCK */ , VK_NUMLOCK
|
---|
94 | /* 0x46 PMSCAN_SCROLLLOCK */ , VK_SCROLL
|
---|
95 | /* 0x47 PMSCAN_PAD7 */ , VK_NUMPAD7
|
---|
96 | /* 0x48 PMSCAN_PAD8 */ , VK_NUMPAD8
|
---|
97 | /* 0x49 PMSCAN_PAD9 */ , VK_NUMPAD9
|
---|
98 | /* 0x4A PMSCAN_PADMINUS */ , VK_SUBTRACT
|
---|
99 | /* 0x4B PMSCAN_PAD4 */ , VK_NUMPAD4
|
---|
100 | /* 0x4C PMSCAN_PAD5 */ , VK_NUMPAD5
|
---|
101 | /* 0x4D PMSCAN_PAD6 */ , VK_NUMPAD6
|
---|
102 | /* 0x4E PMSCAN_PADPLUS */ , VK_ADD
|
---|
103 | /* 0x4F PMSCAN_PAD1 */ , VK_NUMPAD1
|
---|
104 | /* 0x50 PMSCAN_PAD2 */ , VK_NUMPAD2
|
---|
105 | /* 0x51 PMSCAN_PAD3 */ , VK_NUMPAD3
|
---|
106 | /* 0x52 PMSCAN_PAD0 */ , VK_NUMPAD0
|
---|
107 | /* 0x53 PMSCAN_PADPERIOD */ , VK_DECIMAL
|
---|
108 | /* 0x54 PMSCAN_SYSREQ */ , 0x00
|
---|
109 | /* 0x55 PMSCAN_RESET */ , 0x00
|
---|
110 | /* 0x56 PMSCAN_EXTRA */ , VK_EXTRA
|
---|
111 | /* 0x57 PMSCAN_F11 */ , VK_F11
|
---|
112 | /* 0x58 PMSCAN_F12 */ , VK_F12
|
---|
113 | /* 0x59 PMSCAN_BACKTAB */ , 0x00
|
---|
114 | /* 0x5A PMSCAN_PADENTER */ , VK_RETURN
|
---|
115 | /* 0x5B PMSCAN_CTRLRIGHT */ , VK_CONTROL
|
---|
116 | /* 0x5C PMSCAN_PADSLASH */ , VK_DIVIDE
|
---|
117 | /* 0x5D PMSCAN_PRINT */ , VK_PRINT
|
---|
118 | /* 0x5E PMSCAN_ALTRIGHT */ , VK_MENU
|
---|
119 | /* 0x5F PMSCAN_PAUSE */ , VK_PAUSE
|
---|
120 | /* 0x60 PMSCAN_HOME */ , VK_HOME
|
---|
121 | /* 0x61 PMSCAN_UP */ , VK_UP
|
---|
122 | /* 0x62 PMSCAN_PAGEUP */ , VK_PRIOR
|
---|
123 | /* 0x63 PMSCAN_LEFT */ , VK_LEFT
|
---|
124 | /* 0x64 PMSCAN_RIGHT */ , VK_RIGHT
|
---|
125 | /* 0x65 PMSCAN_END */ , VK_END
|
---|
126 | /* 0x66 PMSCAN_DOWN */ , VK_DOWN
|
---|
127 | /* 0x67 PMSCAN_PAGEDOWN */ , VK_NEXT
|
---|
128 | /* 0x68 PMSCAN_INSERT */ , VK_INSERT
|
---|
129 | /* 0x69 PMSCAN_DELETE */ , VK_DELETE
|
---|
130 | /* 0x6A PMSCAN_F23 */ , VK_F23
|
---|
131 | /* 0x6B PMSCAN_F24 */ , VK_F24
|
---|
132 | /* 0x6C PMSCAN_SYSMEM */ , 0x00
|
---|
133 | /* 0x6D PMSCAN_ERASEEOF */ , VK_EREOF
|
---|
134 | /* 0x6E PMSCAN_BREAK */ , VK_CANCEL
|
---|
135 | /* 0x6F PMSCAN_MOVEWIN */ , 0x00
|
---|
136 | /* 0x70 PMSCAN_NLS3 */ , 0x00
|
---|
137 | /* 0x71 PMSCAN_HELP */ , VK_HELP
|
---|
138 | /* 0x72 PMSCAN_TASKMAN */ , 0x00
|
---|
139 | /* 0x73 PMSCAN_B11 */ , 0x00
|
---|
140 | /* 0x74 PMSCAN_JUMP */ , 0x00
|
---|
141 | /* 0x75 PMSCAN_MINWIN */ , 0x00
|
---|
142 | /* 0x76 PMSCAN_CLEAR */ , 0x00
|
---|
143 | /* 0x77 PMSCAN_77 */ , 0x00
|
---|
144 | /* 0x78 PMSCAN_78 */ , 0x00
|
---|
145 | /* 0x79 PMSCAN_NLS2 */ , 0x00
|
---|
146 | /* 0x7a PMSCAN_SIZE */ , 0x00
|
---|
147 | /* 0x7b PMSCAN_NLS1 */ , 0x00
|
---|
148 | /* 0x7c PMSCAN_APPLICATION */ , VK_APPS
|
---|
149 | /* 0x7d PMSCAN_E13 */ , 0x00
|
---|
150 | /* 0x7e PMSCAN */ , 0x00
|
---|
151 | /* 0x7f PMSCAN */ , 0x00
|
---|
152 | /* 0x80 PMSCAN_PA1 */ , VK_PA1
|
---|
153 | /* 0x81 PMSCAN_F13 */ , VK_F13
|
---|
154 | /* 0x82 PMSCAN_F14 */ , VK_F14
|
---|
155 | /* 0x83 PMSCAN_F15 */ , VK_F15
|
---|
156 | /* 0x84 PMSCAN_PA2 */ , 0x00
|
---|
157 | /* 0x85 PMSCAN_PA3 */ , 0x00
|
---|
158 | /* 0x86 PMSCAN_SPACEBREAK */ , 0x00
|
---|
159 | /* 0x87 PMSCAN_TABRIGHT */ , 0x00
|
---|
160 | /* 0x88 PMSCAN_NOOP */ , 0x00
|
---|
161 | /* 0x89 PMSCAN_F16 */ , VK_F16
|
---|
162 | /* 0x8a PMSCAN_F17 */ , VK_F17
|
---|
163 | /* 0x8b PMSCAN_F18 */ , VK_F18
|
---|
164 | /* 0x8c PMSCAN_F19 */ , VK_F19
|
---|
165 | /* 0x8d PMSCAN_F20 */ , VK_F20
|
---|
166 | /* 0x8e PMSCAN_F21 */ , VK_F21
|
---|
167 | /* 0x8f PMSCAN_F22 */ , VK_F22
|
---|
168 | /* 0x90 */ , 0x00
|
---|
169 | /* 0x91 */ , 0x00
|
---|
170 | /* 0x92 */ , 0x00
|
---|
171 | /* 0x93 */ , 0x00
|
---|
172 | /* 0x94 */ , 0x00
|
---|
173 | /* 0x95 */ , 0x00
|
---|
174 | /* 0x96 */ , 0x00
|
---|
175 | /* 0x97 */ , 0x00
|
---|
176 | /* 0x98 */ , 0x00
|
---|
177 | /* 0x99 */ , 0x00
|
---|
178 | /* 0x9A */ , 0x00
|
---|
179 | /* 0x9B */ , 0x00
|
---|
180 | /* 0x9C */ , 0x00
|
---|
181 | /* 0x9D */ , 0x00
|
---|
182 | /* 0x9E */ , 0x00
|
---|
183 | /* 0x9F */ , 0x00
|
---|
184 | /* 0xA0 */ , 0x00
|
---|
185 | /* 0xA1 */ , 0x00
|
---|
186 | /* 0xA2 */ , 0x00
|
---|
187 | /* 0xA3 */ , 0x00
|
---|
188 | /* 0xA4 */ , 0x00
|
---|
189 | /* 0xA5 */ , 0x00
|
---|
190 | /* 0xA6 */ , 0x00
|
---|
191 | /* 0xA7 */ , 0x00
|
---|
192 | /* 0xA8 */ , 0x00
|
---|
193 | /* 0xA9 */ , 0x00
|
---|
194 | /* 0xAA */ , 0x00
|
---|
195 | /* 0xAB */ , 0x00
|
---|
196 | /* 0xAC */ , 0x00
|
---|
197 | /* 0xAD */ , 0x00
|
---|
198 | /* 0xAE */ , 0x00
|
---|
199 | /* 0xAF */ , 0x00
|
---|
200 | /* 0xB0 */ , 0x00
|
---|
201 | /* 0xB1 */ , 0x00
|
---|
202 | /* 0xB2 */ , 0x00
|
---|
203 | /* 0xB3 */ , 0x00
|
---|
204 | /* 0xB4 */ , 0x00
|
---|
205 | /* 0xB5 */ , 0x00
|
---|
206 | /* 0xB6 */ , 0x00
|
---|
207 | /* 0xB7 */ , 0x00
|
---|
208 | /* 0xB8 */ , 0x00
|
---|
209 | /* 0xB9 */ , 0x00
|
---|
210 | /* 0xBA */ , 0x00
|
---|
211 | /* 0xBB */ , 0x00
|
---|
212 | /* 0xBC */ , 0x00
|
---|
213 | /* 0xBD */ , 0x00
|
---|
214 | /* 0xBE */ , 0x00
|
---|
215 | /* 0xBF */ , 0x00
|
---|
216 | /* 0xC0 */ , 0x00
|
---|
217 | /* 0xC1 */ , 0x00
|
---|
218 | /* 0xC2 */ , 0x00
|
---|
219 | /* 0xC3 */ , 0x00
|
---|
220 | /* 0xC4 */ , 0x00
|
---|
221 | /* 0xC5 */ , 0x00
|
---|
222 | /* 0xC6 */ , 0x00
|
---|
223 | /* 0xC7 */ , 0x00
|
---|
224 | /* 0xC8 */ , 0x00
|
---|
225 | /* 0xC9 */ , 0x00
|
---|
226 | /* 0xCA */ , 0x00
|
---|
227 | /* 0xCB */ , 0x00
|
---|
228 | /* 0xCC */ , 0x00
|
---|
229 | /* 0xCD */ , 0x00
|
---|
230 | /* 0xCE */ , 0x00
|
---|
231 | /* 0xCF */ , 0x00
|
---|
232 | /* 0xD0 */ , 0x00
|
---|
233 | /* 0xD1 */ , 0x00
|
---|
234 | /* 0xD2 */ , 0x00
|
---|
235 | /* 0xD3 */ , 0x00
|
---|
236 | /* 0xD4 */ , 0x00
|
---|
237 | /* 0xD5 */ , 0x00
|
---|
238 | /* 0xD6 */ , 0x00
|
---|
239 | /* 0xD7 */ , 0x00
|
---|
240 | /* 0xD8 */ , 0x00
|
---|
241 | /* 0xD9 */ , 0x00
|
---|
242 | /* 0xDA */ , 0x00
|
---|
243 | /* 0xDB */ , 0x00
|
---|
244 | /* 0xDC */ , 0x00
|
---|
245 | /* 0xDD */ , 0x00
|
---|
246 | /* 0xDE */ , 0x00
|
---|
247 | /* 0xDF */ , 0x00
|
---|
248 | /* 0xE0 */ , 0x00
|
---|
249 | /* 0xE1 */ , 0x00
|
---|
250 | /* 0xE2 */ , 0x00
|
---|
251 | /* 0xE3 */ , 0x00
|
---|
252 | /* 0xE4 */ , 0x00
|
---|
253 | /* 0xE5 */ , 0x00
|
---|
254 | /* 0xE6 */ , 0x00
|
---|
255 | /* 0xE7 */ , 0x00
|
---|
256 | /* 0xE8 */ , 0x00
|
---|
257 | /* 0xE9 */ , 0x00
|
---|
258 | /* 0xEA */ , 0x00
|
---|
259 | /* 0xEB */ , 0x00
|
---|
260 | /* 0xEC */ , 0x00
|
---|
261 | /* 0xED */ , 0x00
|
---|
262 | /* 0xEE */ , 0x00
|
---|
263 | /* 0xEF */ , 0x00
|
---|
264 | /* 0xF0 */ , 0x00
|
---|
265 | /* 0xF1 */ , 0x00
|
---|
266 | /* 0xF2 */ , 0x00
|
---|
267 | /* 0xF3 */ , 0x00
|
---|
268 | /* 0xF4 */ , 0x00
|
---|
269 | /* 0xF5 */ , 0x00
|
---|
270 | /* 0xF6 */ , 0x00
|
---|
271 | /* 0xF7 */ , 0x00
|
---|
272 | /* 0xF8 */ , 0x00
|
---|
273 | /* 0xF9 */ , 0x00
|
---|
274 | /* 0xFA */ , 0x00
|
---|
275 | /* 0xFB */ , 0x00
|
---|
276 | /* 0xFC */ , 0x00
|
---|
277 | /* 0xFD */ , 0x00
|
---|
278 | /* 0xFE */ , 0x00
|
---|
279 | /* 0xFF */ , 0x00
|
---|
280 | };
|
---|
281 |
|
---|
282 | //******************************************************************************
|
---|
283 | //******************************************************************************
|
---|
284 | BYTE WIN32API KeyTranslatePMToWin(BYTE key)
|
---|
285 | {
|
---|
286 | return abPMScanToWinVKey[key];
|
---|
287 | }
|
---|
288 | //******************************************************************************
|
---|
289 | //******************************************************************************
|
---|
290 | void WIN32API KeyTranslatePMToWinBuf(BYTE *pmkey, BYTE *winkey, int nrkeys)
|
---|
291 | {
|
---|
292 | for(int i=0;i<nrkeys;i++) {
|
---|
293 | winkey[i] = abPMScanToWinVKey[pmkey[i]];
|
---|
294 | }
|
---|
295 | }
|
---|
296 | //******************************************************************************
|
---|
297 | //******************************************************************************
|
---|
298 | int WIN32API GetKeyboardType( int nTypeFlag)
|
---|
299 | {
|
---|
300 | dprintf(("USER32: GetKeyboardType\n"));
|
---|
301 | return O32_GetKeyboardType(nTypeFlag);
|
---|
302 | }
|
---|
303 | //******************************************************************************
|
---|
304 | //******************************************************************************
|
---|
305 | BOOL WIN32API GetKeyboardState(PBYTE lpKeyState)
|
---|
306 | {
|
---|
307 | BYTE PMKeyState[256];
|
---|
308 | BOOL rc;
|
---|
309 |
|
---|
310 | dprintf(("USER32: GetKeyboardState %x", lpKeyState));
|
---|
311 | rc = OSLibWinGetKeyboardStateTable((PBYTE)&PMKeyState );
|
---|
312 |
|
---|
313 | if(rc == TRUE)
|
---|
314 | {
|
---|
315 | KeyTranslatePMToWinBuf((BYTE *)&PMKeyState, lpKeyState, 256);
|
---|
316 | return TRUE;
|
---|
317 | }
|
---|
318 | return FALSE;
|
---|
319 | }
|
---|
320 | //******************************************************************************
|
---|
321 | //******************************************************************************
|
---|
322 | BOOL WIN32API SetKeyboardState(PBYTE lpKeyState)
|
---|
323 | {
|
---|
324 | dprintf(("USER32: SetKeyboardState %x not implemented", lpKeyState));
|
---|
325 | return(TRUE);
|
---|
326 | }
|
---|
327 | /***********************************************************************
|
---|
328 | * GetKeyboardLayout (USER32.250)
|
---|
329 | *
|
---|
330 | * FIXME: - device handle for keyboard layout defaulted to
|
---|
331 | * the language id. This is the way Windows default works.
|
---|
332 | * - the thread identifier (dwLayout) is also ignored.
|
---|
333 | */
|
---|
334 | // * Remark : Based on Wine version (991031)
|
---|
335 | HKL WIN32API GetKeyboardLayout(DWORD dwLayout)
|
---|
336 | {
|
---|
337 | HKL layout;
|
---|
338 | layout = GetSystemDefaultLCID(); /* FIXME */
|
---|
339 | layout |= (layout<<16); /* FIXME */
|
---|
340 | dprintf(("GetKeyboardLayout returning %08x\n",layout));
|
---|
341 | return layout;
|
---|
342 | }
|
---|
343 | /*****************************************************************************
|
---|
344 | * Name : BOOL WIN32API GetKeyboardLayoutNameA
|
---|
345 | * Purpose : The GetKeyboardLayoutName function retrieves the name of the
|
---|
346 | * active keyboard layout.
|
---|
347 | * Parameters: LPTSTR pwszKLID address of buffer for layout name
|
---|
348 | * Variables :
|
---|
349 | * Result : If the function succeeds, the return value is TRUE.
|
---|
350 | * If the function fails, the return value is FALSE. To get extended
|
---|
351 | * error information, call GetLastError.
|
---|
352 | * Remark : Based on Wine version (991031)
|
---|
353 | * Status : UNTESTED STUB
|
---|
354 | *
|
---|
355 | * Author : Patrick Haller [Thu, 1998/02/26 11:55]
|
---|
356 | *****************************************************************************/
|
---|
357 | INT WIN32API GetKeyboardLayoutNameA(LPTSTR pwszKLID)
|
---|
358 | {
|
---|
359 | dprintf(("USER32:GetKeyboardLayoutNameA"));
|
---|
360 |
|
---|
361 | sprintf(pwszKLID, "%08x",GetKeyboardLayout(0));
|
---|
362 | return 1;
|
---|
363 | }
|
---|
364 | /*****************************************************************************
|
---|
365 | * Name : BOOL WIN32API GetKeyboardLayoutNameW
|
---|
366 | * Purpose : The GetKeyboardLayoutName function retrieves the name of the
|
---|
367 | * active keyboard layout.
|
---|
368 | * Parameters: LPTSTR pwszKLID address of buffer for layout name
|
---|
369 | * Variables :
|
---|
370 | * Result : If the function succeeds, the return value is TRUE.
|
---|
371 | * If the function fails, the return value is FALSE. To get extended
|
---|
372 | * error information, call GetLastError.
|
---|
373 | * Remark : Based on Wine version (991031)
|
---|
374 | * Status : UNTESTED STUB
|
---|
375 | *
|
---|
376 | * Author : Patrick Haller [Thu, 1998/02/26 11:55]
|
---|
377 | *****************************************************************************/
|
---|
378 | INT WIN32API GetKeyboardLayoutNameW(LPWSTR pwszKLID)
|
---|
379 | {
|
---|
380 | LPSTR buf = (LPSTR)HEAP_xalloc( GetProcessHeap(), 0, strlen("00000409")+1);
|
---|
381 |
|
---|
382 | dprintf(("USER32:GetKeyboardLayoutNameA"));
|
---|
383 | int res = GetKeyboardLayoutNameA(buf);
|
---|
384 | lstrcpyAtoW(pwszKLID,buf);
|
---|
385 | HeapFree( GetProcessHeap(), 0, buf );
|
---|
386 | return res;
|
---|
387 | }
|
---|
388 | /***********************************************************************
|
---|
389 | * GetKeyboardLayoutList (USER32.251)
|
---|
390 | *
|
---|
391 | * FIXME: Supports only the system default language and layout and
|
---|
392 | * returns only 1 value.
|
---|
393 | *
|
---|
394 | * Return number of values available if either input parm is
|
---|
395 | * 0, per MS documentation.
|
---|
396 | *
|
---|
397 | * Remark : Based on Wine version (991031)
|
---|
398 | */
|
---|
399 | INT WINAPI GetKeyboardLayoutList(INT nBuff,HKL *layouts)
|
---|
400 | {
|
---|
401 | dprintf(("GetKeyboardLayoutList(%d,%p)\n",nBuff,layouts));
|
---|
402 | if (!nBuff || !layouts)
|
---|
403 | return 1;
|
---|
404 | if (layouts)
|
---|
405 | layouts[0] = GetKeyboardLayout(0);
|
---|
406 | return 1;
|
---|
407 | }
|
---|
408 | /*****************************************************************************
|
---|
409 | * Name : int WIN32API ToAscii
|
---|
410 | * Purpose : The ToAscii function translates the specified virtual-key code
|
---|
411 | * and keyboard state to the corresponding Windows character or characters.
|
---|
412 | * Parameters: UINT uVirtKey virtual-key code
|
---|
413 | * UINT uScanCode scan code
|
---|
414 | * PBYTE lpbKeyState address of key-state array
|
---|
415 | * LPWORD lpwTransKey buffer for translated key
|
---|
416 | * UINT fuState active-menu flag
|
---|
417 | * Variables :
|
---|
418 | * Result : 0 The specified virtual key has no translation for the current
|
---|
419 | * state of the keyboard.
|
---|
420 | * 1 One Windows character was copied to the buffer.
|
---|
421 | * 2 Two characters were copied to the buffer. This usually happens
|
---|
422 | * when a dead-key character (accent or diacritic) stored in the
|
---|
423 | * keyboard layout cannot be composed with the specified virtual
|
---|
424 | * key to form a single character.
|
---|
425 | * Remark :
|
---|
426 | * Status : UNTESTED STUB
|
---|
427 | *
|
---|
428 | * Author : Based on Wine code (windows\x11drv\keyboard.c
|
---|
429 | * Copyright 1993 Bob Amstadt
|
---|
430 | * Copyright 1996 Albrecht Kleine
|
---|
431 | * Copyright 1997 David Faure
|
---|
432 | * Copyright 1998 Morten Welinder
|
---|
433 | * Copyright 1998 Ulrich Weigand
|
---|
434 | * Copyright 1999 Ove Kåven
|
---|
435 | *
|
---|
436 | *****************************************************************************/
|
---|
437 | int WIN32API ToAscii(UINT uVirtKey,
|
---|
438 | UINT uScanCode,
|
---|
439 | PBYTE lpbKeyState,
|
---|
440 | LPWORD lpwTransKey,
|
---|
441 | UINT fuState)
|
---|
442 | {
|
---|
443 | dprintf(("USER32:ToAscii (%u,%u,%08xh,%08xh,%u) not implemented.\n",
|
---|
444 | uVirtKey,
|
---|
445 | uScanCode,
|
---|
446 | lpbKeyState,
|
---|
447 | lpwTransKey,
|
---|
448 | fuState));
|
---|
449 |
|
---|
450 | INT ret;
|
---|
451 |
|
---|
452 | if (uScanCode == 0) {
|
---|
453 | /* This happens when doing Alt+letter : a fake 'down arrow' key press
|
---|
454 | event is generated by windows. Just ignore it. */
|
---|
455 | dprintf2(("scanCode=0, doing nothing"));
|
---|
456 | return 0;
|
---|
457 | }
|
---|
458 | if (uScanCode & 0x8000)
|
---|
459 | {
|
---|
460 | dprintf2(("Key UP, doing nothing"));
|
---|
461 | return 0;
|
---|
462 | }
|
---|
463 | /* We have a special case to handle : Shift + arrow, shift + home, ...
|
---|
464 | X returns a char for it, but Windows doesn't. Let's eat it. */
|
---|
465 | if(!(lpbKeyState[VK_NUMLOCK] & 0x01) /* NumLock is off */
|
---|
466 | && (lpbKeyState[VK_SHIFT] & 0x80) /* Shift is pressed */
|
---|
467 | && (uVirtKey >= VK_0) && (uVirtKey >= VK_9))
|
---|
468 | {
|
---|
469 | *(char*)lpwTransKey = 0;
|
---|
470 | ret = 0;
|
---|
471 | }
|
---|
472 | else
|
---|
473 | /* We have another special case for delete key (XK_Delete) on an
|
---|
474 | extended keyboard. X returns a char for it, but Windows doesn't */
|
---|
475 | if (uVirtKey == VK_DELETE)
|
---|
476 | {
|
---|
477 | *(char*)lpwTransKey = 0;
|
---|
478 | ret = 0;
|
---|
479 | }
|
---|
480 | else {
|
---|
481 | *(char*)lpwTransKey = uVirtKey;
|
---|
482 | ret = 1;
|
---|
483 | }
|
---|
484 | return ret;
|
---|
485 | }
|
---|
486 | /*****************************************************************************
|
---|
487 | * Name : int WIN32API ToAsciiEx
|
---|
488 | * Purpose : The ToAscii function translates the specified virtual-key code
|
---|
489 | * and keyboard state to the corresponding Windows character or characters.
|
---|
490 | * Parameters: UINT uVirtKey virtual-key code
|
---|
491 | * UINT uScanCode scan code
|
---|
492 | * PBYTE lpbKeyState address of key-state array
|
---|
493 | * LPWORD lpwTransKey buffer for translated key
|
---|
494 | * UINT fuState active-menu flag
|
---|
495 | * HLK hlk keyboard layout handle
|
---|
496 | * Variables :
|
---|
497 | * Result : 0 The specified virtual key has no translation for the current
|
---|
498 | * state of the keyboard.
|
---|
499 | * 1 One Windows character was copied to the buffer.
|
---|
500 | * 2 Two characters were copied to the buffer. This usually happens
|
---|
501 | * when a dead-key character (accent or diacritic) stored in the
|
---|
502 | * keyboard layout cannot be composed with the specified virtual
|
---|
503 | * key to form a single character.
|
---|
504 | * Remark :
|
---|
505 | * Status : UNTESTED STUB
|
---|
506 | *
|
---|
507 | * Author : Patrick Haller [Thu, 1998/02/26 11:55]
|
---|
508 | *****************************************************************************/
|
---|
509 | int WIN32API ToAsciiEx(UINT uVirtKey,
|
---|
510 | UINT uScanCode,
|
---|
511 | PBYTE lpbKeyState,
|
---|
512 | LPWORD lpwTransKey,
|
---|
513 | UINT fuState,
|
---|
514 | HKL hkl)
|
---|
515 | {
|
---|
516 | dprintf(("USER32:ToAsciiEx (%u,%u,%08xh,%08xh,%u,%08x) not implemented.\n",
|
---|
517 | uVirtKey,
|
---|
518 | uScanCode,
|
---|
519 | lpbKeyState,
|
---|
520 | lpwTransKey,
|
---|
521 | fuState,
|
---|
522 | hkl));
|
---|
523 |
|
---|
524 | return (0);
|
---|
525 | }
|
---|
526 | //******************************************************************************
|
---|
527 | //******************************************************************************
|
---|