source: trunk/src/emx/include/unikbd.h@ 706

Last change on this file since 706 was 247, checked in by bird, 22 years ago

Initial coding.

  • Property cvs2svn:cvs-rev set to 1.1
  • Property svn:eol-style set to native
  • Property svn:executable set to *
File size: 11.4 KB
Line 
1/* unikbd.h,v 1.1 2003/05/27 16:03:42 bird Exp */
2/** @file
3 * Legalesy-free Unicode API interface for OS/2
4 * Interface definitions for basic Unicode API functions
5 *
6 * Written by bird
7 *
8 * This file is put into public domain. You are free to do
9 * literally anything you wish with it: modify, print, sell,
10 * rent, eat, throw out of window: in all (esp. in later)
11 * cases I am not responsible for any damage it causes.
12 */
13#ifndef __UNIKBD_H__
14#define __UNIKBD_H__
15
16#ifdef __cplusplus
17extern "C" {
18#endif
19
20/*******************************************************************************
21* Header Files *
22*******************************************************************************/
23#include <unidef.h>
24
25#if !defined(OS2_INCLUDED) && !defined(_OS2EMX_H)
26#warning Including os2.h for you.
27#include <os2.h>
28#endif
29
30
31/*******************************************************************************
32* Defined Constants And Macros *
33*******************************************************************************/
34/** Linkage convetion for unikbd calls. */
35#define KBDLINK APIENTRY
36
37#ifndef INCL_WININPUT
38#define INCL_WININPUT
39/** @group Virtual Key defines - duplicates of os2emx.h
40 * @{ */
41#define VK_BUTTON1 0x0001
42#define VK_BUTTON2 0x0002
43#define VK_BUTTON3 0x0003
44#define VK_BREAK 0x0004
45#define VK_BACKSPACE 0x0005
46#define VK_TAB 0x0006
47#define VK_BACKTAB 0x0007
48#define VK_NEWLINE 0x0008
49#define VK_SHIFT 0x0009
50#define VK_CTRL 0x000a
51#define VK_ALT 0x000b
52#define VK_ALTGRAF 0x000c
53#define VK_PAUSE 0x000d
54#define VK_CAPSLOCK 0x000e
55#define VK_ESC 0x000f
56#define VK_SPACE 0x0010
57#define VK_PAGEUP 0x0011
58#define VK_PAGEDOWN 0x0012
59#define VK_END 0x0013
60#define VK_HOME 0x0014
61#define VK_LEFT 0x0015
62#define VK_UP 0x0016
63#define VK_RIGHT 0x0017
64#define VK_DOWN 0x0018
65#define VK_PRINTSCRN 0x0019
66#define VK_INSERT 0x001a
67#define VK_DELETE 0x001b
68#define VK_SCRLLOCK 0x001c
69#define VK_NUMLOCK 0x001d
70#define VK_ENTER 0x001e
71#define VK_SYSRQ 0x001f
72#define VK_F1 0x0020
73#define VK_F2 0x0021
74#define VK_F3 0x0022
75#define VK_F4 0x0023
76#define VK_F5 0x0024
77#define VK_F6 0x0025
78#define VK_F7 0x0026
79#define VK_F8 0x0027
80#define VK_F9 0x0028
81#define VK_F10 0x0029
82#define VK_F11 0x002a
83#define VK_F12 0x002b
84#define VK_F13 0x002c
85#define VK_F14 0x002d
86#define VK_F15 0x002e
87#define VK_F16 0x002f
88#define VK_F17 0x0030
89#define VK_F18 0x0031
90#define VK_F19 0x0032
91#define VK_F20 0x0033
92#define VK_F21 0x0034
93#define VK_F22 0x0035
94#define VK_F23 0x0036
95#define VK_F24 0x0037
96#define VK_ENDDRAG 0x0038
97#define VK_CLEAR 0x0039
98#define VK_EREOF 0x003a
99#define VK_PA1 0x003b
100#define VK_ATTN 0x003c
101#define VK_CRSEL 0x003d
102#define VK_EXSEL 0x003e
103#define VK_COPY 0x003f
104#define VK_BLK1 0x0040
105#define VK_BLK2 0x0041
106#define VK_MENU VK_F10
107#if defined (INCL_NLS)
108#define VK_DBCSFIRST 0x0080
109#define VK_DBCSLAST 0x00ff
110#define VK_BIDI_FIRST 0x00e0
111#define VK_BIDI_LAST 0x00ff
112#endif /* INCL_NLS */
113#define VK_USERFIRST 0x0100
114#define VK_USERLAST 0x01ff
115/** @} */
116#endif /* !INCL_WININPUT */
117
118
119/** @group Virtual Keys defines (Unikbd specific)
120 * @{ */
121#define VK_PA2 0x0050
122#define VK_PA3 0x0051
123#define VK_GROUP 0x0052
124#define VK_GROUPLOCK 0x0053
125#define VK_APPL 0x0054
126#define VK_WINLEFT 0x0055
127#define VK_WINRIGHT 0x0056
128#define VK_M_DOWNLEFT 0x0061
129#define VK_M_DOWN 0x0062
130#define VK_M_DOWNRIGHT 0x0063
131#define VK_M_LEFT 0x0064
132#define VK_M_CENTER 0x0065
133#define VK_M_RIGHT 0x0066
134#define VK_M_UPLEFT 0x0067
135#define VK_M_UP 0x0068
136#define VK_M_UPRIGHT 0x0069
137#define VK_M_BUTTONLOCK 0x006A
138#define VK_M_BUTTONRELEASE 0x006B
139#define VK_M_DOUBLECLICK 0x006C
140/** @} */
141
142/** @group Dead Key defines
143 * @{ */
144#define DK_MIN 0x1000
145#define DK_ACUTE 0x1001
146#define DK_GRAVE 0x1002
147#define DK_DIERESIS 0x1003
148#define DK_UMLAUT 0x1003
149#define DK_CIRCUMFLEX 0x1004
150#define DK_TILDE 0x1005
151#define DK_CEDILLA 0x1006
152#define DK_MACRON 0x1007
153#define DK_BREVE 0x1008
154#define DK_OGONEK 0x1009
155#define DK_DOT 0x100a
156#define DK_BAR 0x100b
157#define DK_RING 0x100c
158#define DK_CARON 0x100d
159#define DK_HACEK DK_CARON
160#define DK_HUNGARUMLAUT 0x100e
161#define DK_ACUTEDIA 0x100f
162#define DK_PSILI 0x1010
163#define DK_DASIA 0x1011
164#define DK_OVERLINE 0x1012
165#define DK_UNDERDOT 0x1013
166#define DK_MAX 0x1fff
167/** @} */
168
169/** @group Keyboard Shift and Effective flags.
170 * @{ */
171#define KBD_SHIFT 0x00000001
172#define KBD_CONTROL 0x00000002
173#define KBD_ALT 0x00000004
174#define KBD_ALTCTRLSHIFT 0x00000007
175#define KBD_ALTGR 0x00000008
176#define KBD_NLS1 0x00000010
177#define KBD_NLS2 0x00000020
178#define KBD_NLS3 0x00000040
179#define KBD_NLS4 0x00000080
180/** @} */
181
182/** @group Keyboard Shift and Effective flags - Japanese NLS usage
183 * @{ */
184#define KBD_WIDE KBD_NLS1
185#define KBD_KATAKANA KBD_NLS2
186#define KBD_HIRAGANA KBD_NLS3
187#define KBD_ROMANJI KBD_NLS4
188/** @} */
189
190/** @group Keyboard Shift and Effective flags - Korean NLS usage
191 * @{ */
192#define KBD_JAMO KBD_NLS2
193#define KBD_HANGEUL KBD_NLS3
194#define KBD_HANJACSR KBD_NLS4
195/** @} */
196
197/** @group Keyboard Shift and Effective flags - Taiwan NLS usage */
198#define KBD_PHONETIC KBD_NLS2
199#define KBD_TSANGJYE KBD_NLS3
200/** @} */
201
202
203/** @group Keyboard Lock States
204 * @{ */
205#define KBD_SCROLLLOCK 0x00000100
206#define KBD_NUMLOCK 0x00000200
207#define KBD_CAPSLOCK 0x00000400
208#define KBD_EXTRALOCK 0x00000800
209#define KBD_APPL 0x00001000
210#define KBD_DBCS 0x00008000
211/** @} */
212
213/** Bitmask for all the effective bits. */
214#define KBD_EFFECTIVE 0x0000ffff
215
216/** @group Keyboard Shift States Left/Right separation.
217 * @{ */
218#define KBD_LEFTSHIFT 0x00010000
219#define KBD_RIGHTSHIFT 0x00020000
220#define KBD_LEFTCONTROL 0x00040000
221#define KBD_RIGHTCONTROL 0x00080000
222#define KBD_LEFTALT 0x00100000
223#define KBD_RIGHTALT 0x00200000
224#define KBD_LEFTWINDOWS 0x00400000
225#define KBD_RIGHTWINDOWS 0x00800000
226/** @} */
227
228/** @group Keyboard LED and other status bits.
229 * @{ */
230#define KBD_NOROMANJI 0x04000000
231#define KBD_KANJI 0x08000000
232#define KBD_DEADKEY 0x10000000
233#define KBD_WAIT 0x20000000
234#define KBD_HOLD 0x40000000
235#define KBD_LOCK 0x80000000
236/** @} */
237
238/** @group Make/Break/Repeat defines.
239 * @{ */
240#define KEYEV_MAKEBREAK 0
241#define KEYEV_MAKE 1
242#define KEYEV_BREAK 2
243#define KEYEV_REPEAT 3
244/** @} */
245
246/** @group Keyboard Query Flags.
247 * @{ */
248#define KBDF_DEFAULTVKEY 0x0001
249#define KBDF_NOCTRLSHIFT 0x0002
250#define KBDF_NOALTGR 0x0004
251#define KBDF_SHIFTALTGR 0x0010
252#define KBDF_DEADGOOD 0x0020
253#define KBDF_DEADPRIVATE 0x0040
254#define KBDF_SYSTEM 0x8000
255#define KBDF_INTERNATIONAL 0x4000
256#define KBDF_DVORAK 0x2000
257#define KBDF_NATIONAL 0x1000
258#define KBDF_LETTERKEYS 0x3000
259#define KBDF_ISOKEYS 0x0800
260/** @} */
261
262/** @group Keyboard layout flags (advisory only)
263 * @{ */
264#define KBDF_LAYOUT101 0x0000
265#define KBDF_LAYOUT102 0x0100
266#define KBDF_LAYOUT106 0x0200
267#define KBDF_LAYOUT103 0x0300
268#define KBDF_LAYOUT100 0x0400
269#define KBDF_LAYOUTS 0x0700
270/** @} */
271
272/** @group UniResetShiftState types.
273 * @{ */
274#define KEYEV_SET 0
275#define KEYEV_RELEASE 1
276#define KEYEV_ZERO 2
277/** @} */
278
279
280
281
282/*******************************************************************************
283* Structures and Typedefs *
284*******************************************************************************/
285/** Translation table handle. */
286typedef unsigned int KHAND;
287/** Virtual scan code. */
288typedef unsigned char VSCAN;
289/** Virtual dead key. */
290typedef unsigned short VDKEY;
291/** Keyboard name. */
292typedef UniChar KBDNAME;
293
294/** Keyboard shift states. */
295typedef struct _USHIFTSTATE
296{
297 /** Actual shift and lock state. */
298 ULONG Shift;
299 /** Effective shift and lock state. */
300 ULONG Effective;
301 /** Keyboard indicators. */
302 ULONG Led;
303} USHIFTSTATE;
304
305/** Virtual key event. */
306typedef struct _INKEYEVENT
307{
308 /** Logical device (0=real). */
309 USHORT ldev;
310 /** Make/break indicator. */
311 BYTE makebreak;
312 /** Virtual scan code. */
313 VSCAN scan;
314 /** Timestamp. */
315 ULONG time;
316} INKEYEVENT;
317
318/** Query keyboard structure. */
319typedef struct _KEYBOARDINFO
320{
321 /** Length of structure. */
322 ULONG len;
323 /** Keyboard architecture id. */
324 USHORT kbid;
325 /** Version number. */
326 USHORT version;
327 /** Normal language. */
328 BYTE language[2];
329 /** Normal country. */
330 BYTE country[2];
331 /** Flags (KBDF_). */
332 USHORT flags;
333 /** Reserved. */
334 USHORT resv;
335 /** Description of keyboard. */
336 UniChar description[32];
337} KEYBOARDINFO;
338
339
340/*******************************************************************************
341* Internal Functions *
342*******************************************************************************/
343APIRET KBDLINK UniCreateKeyboard(KHAND * phKeyboard, const KBDNAME * puszName, ULONG ulMode);
344APIRET KBDLINK UniDestroyKeyboard(KHAND hKeyboard);
345APIRET KBDLINK UniQueryKeyboard(KHAND hKeyboard, KEYBOARDINFO * pKbdInfo);
346APIRET KBDLINK UniResetShiftState(KHAND hKeyboard, USHIFTSTATE * pKbdStat, ULONG ulType);
347APIRET KBDLINK UniUpdateShiftState(KHAND hKeyboard, USHIFTSTATE * pKbdStat, VSCAN uchScan, BYTE bMakeBreak);
348APIRET KBDLINK UniTranslateKey(KHAND hKeyboard, ULONG ulEShift, VSCAN bScan, UniChar * puc, VDKEY * pusDeadKey, BYTE * pbScan);
349APIRET KBDLINK UniTranslateDeadkey(KHAND hKeyboard, VDKEY usDead, UniChar ucIn, UniChar * pucOut, VDKEY * pusDeadKey);
350APIRET KBDLINK UniUntranslateKey(KHAND hKeyboard, UniChar uc, VDKEY vdkey, VSCAN * pscan, ULONG * eshift);
351
352#ifdef __cplusplus
353}
354#endif
355#endif
356
357
Note: See TracBrowser for help on using the repository browser.