2
{****************************************************************************
5
KBDCALLS interface unit
6
Free Pascal Runtime Library for OS/2
7
Copyright (c) 1999-2000 by Florian Kl�mpfl
8
Copyright (c) 1999-2000 by Daniel Mantione
9
Copyright (c) 1999-2000 by Tomas Hajny
11
The Free Pascal runtime library is distributed under the Library GNU Public
12
License v2. So is this unit. The Library GNU Public License requires you to
13
distribute the source code of this unit with any product that uses it.
14
Because the EMX library isn't under the LGPL, we grant you an exception to
15
this, and that is, when you compile a program with the Free Pascal Compiler,
16
you do not need to ship source code with that program, AS LONG AS YOU ARE
17
USING UNMODIFIED CODE! If you modify this code, you MUST change the next
20
<This is an official, unmodified Free Pascal source code file.>
22
Send us your modified files, we can work together if you want!
24
Free Pascal is distributed in the hope that it will be useful,
25
but WITHOUT ANY WARRANTY; without even the implied warranty of
26
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
27
Library GNU General Public License for more details.
29
You should have received a copy of the Library GNU General Public License
30
along with Free Pascal; see the file COPYING.LIB. If not, write to
31
the Free Software Foundation, 59 Temple Place - Suite 330,
32
Boston, MA 02111-1307, USA.
34
****************************************************************************}
38
{ Interface library to KBDCALLS.DLL (through EMXWRAP.DLL)
40
Variant records and aliases for some record types created to maintain highest
41
possible level of compatibility with other existing OS/2 compilers.
47
TH - Tomas Hajny (xhajt03@mbox.vol.cz on Internet)
49
Date: Description of change: Changed by:
51
- First released version 1.0 TH
55
I have tried to use the same coding style as Daniel Mantione in unit
56
DOSCALLS, although I can't say I would write it the same way otherwise
57
(I would write much more spaces myself, at least). Try to use it as well,
58
please. Original note by Daniel Mantione follows:
61
It may be well possible that coding style feels a bit strange to you.
62
Nevertheless I friendly ask you to try to make your changes not look all
63
to different. To make life easier, set your IDE to use tab characters,
64
turn optimal fill, autoindent and backspace unindents on and set a
67
{***************************************************************************}
69
{***************************************************************************}
76
{return codes / error constants (those marked with * shouldn't occur under
79
Error_Invalid_Parameter = 87;
80
Error_Sem_TimeOut =121;
81
Error_Kbd_Parameter =373;
82
Error_Kbd_No_Device =374; {*}
83
Error_Kbd_Invalid_IOWait =375; {*}
84
Error_Kbd_Invalid_Length =376;
85
Error_Kbd_Invalid_Echo_Mask =377;
86
Error_Kbd_Invalid_Input_Mask =378;
87
Error_Kbd_Smg_Only =407; {*}
88
Error_Kbd_Invalid_ASCIIZ =408;
89
Error_Kbd_Invalid_Mask =409;
90
Error_Kbd_Register =410;
91
Error_Kbd_Deregister =411;
92
Error_Kbd_Invalid_Handle =439;
93
Error_Kbd_No_more_Handle =440;
94
Error_Kbd_Cannot_Create_KCB =441;
95
Error_Kbd_Codepage_Load_Incompl =442; {*}
96
Error_Kbd_Invalid_CodePage_ID =443; {*}
97
Error_Kbd_No_CodePage_Support =444; {*}
98
Error_Kbd_Focus_Required =445;
99
Error_Kbd_Focus_Already_Active =446; {*}
100
Error_Kbd_Keyboard_Busy =447;
101
Error_Kbd_Invalid_CodePage =448;
102
Error_Kbd_Unable_To_Focus =449; {*}
103
Error_Kbd_Detached =464;
104
Error_Kbd_No_Console =500; {*}
105
Error_Kbd_Extended_SG =504;
108
kr_KbdCharIn =$00000001;
109
kr_KbdPeek =$00000002;
110
kr_KbdFlushBuffer =$00000004;
111
kr_KbdGetStatus =$00000008;
112
kr_KbdSetStatus =$00000010;
113
kr_KbdStringIn =$00000020;
114
kr_KbdOpen =$00000040;
115
kr_KbdClose =$00000080;
116
kr_KbdGetFocus =$00000100;
117
kr_KbdFreeFocus =$00000200;
118
kr_KbdGetCP =$00000400;
119
kr_KbdSetCP =$00000800;
120
kr_KbdXLate =$00001000;
121
kr_KbdSetCustXT =$00002000;
125
{KbdCharIn: wait for a character if one is not available}
126
{KbdGetFocus: wait for the focus}
127
{KbdStringIn: in binary input mode, wait until CharBuf is full, in }
128
{ ASCII input mode wait until a carriage return is pressed}
130
{KbdCharIn: immediate return if no character is available}
131
{KbdGetFocus: do not wait for the focus}
132
{KbdStringIn: send an immediate return if no characters are available,}
133
{ if characters available, send them (up to the maximum }
134
{ length); not supported in ASCII input mode }
137
Keyboard_Echo_On =$0001; {echo is on}
138
Keyboard_Echo_Off =$0002; {echo is off}
139
Keyboard_Binary_Mode =$0004; {binary mode is on}
140
Keyboard_ASCII_Mode =$0008; {ASCII mode is on}
141
Keyboard_Modify_State =$0010; {shift state is modified}
142
Keyboard_Modify_Interim =$0020; {interim character flags are modified}
143
Keyboard_Modify_TurnAround =$0040; {turn-around character is modified}
144
Keyboard_2B_TurnAround =$0080; {length of the turn-around character }
145
{(meaningful only if }
146
{Keyboard_Modify_TurnAround bit is on)}
147
Keyboard_Shift_Report =$0100; {shift return is on}
149
{TKbdInfo.fsState/TKbdKeyInfo.fsState/TKbdTrans.fsState}
150
KbdStF_RightShift =$0001;
151
KbdStF_LeftShift =$0002;
152
KbdStF_Control =$0004;
154
KbdStF_ScrollLock_On =$0010;
155
KbdStF_Numlock_On =$0020;
156
KbdStF_Capslock_On =$0040;
157
KbdStF_Insert_On =$0080;
158
KbdStF_LeftControl =$0100;
159
KbdStF_LeftAlt =$0200;
160
KbdStF_RightControl =$0400;
161
KbdStF_RightAlt =$0800;
162
KbdStF_ScrollLock =$1000;
163
KbdStF_NumLock =$2000;
164
KbdStF_CapsLock =$4000;
165
KbdStF_SysReq =$8000;
168
KbdTrF_Shift_Key_In =$01; {shift status returned}
170
KbdTrF_Extended_Key_In =$02; {extended key code }
173
KbdTrF_Conversion_Request =$20; {immediate conversion}
175
KbdTrF_Final_Char_In =$40; {either $40 or $80 or both}
176
KbdTrF_Interim_Char_In =$80; {must be present }
179
Keyboard_Undetermined =$0000; {undetermined keyboard type}
180
Keyboard_AT_Compatible =$0001; {PC-AT Standard Keyboard}
181
Keyboard_Enhanced_101 =$AB41; {101 Key Enhanced Keyboard}
182
Keyboard_Enhanced_102 =$AB41; {102 Key Enhanced Keyboard}
183
Keyboard_Enhanced_88_89 =$AB54; {88 and 89 Key Enhanced Keyboards}
184
Keyboard_Enhanced_122 =$AB85; {122 Key Enhanced Keyboard}
185
Keyboard_AT_Compatable=Keyboard_AT_Compatible;
186
Keyboard_SpaceSaver=Keyboard_Enhanced_88_89;
190
{TKbdKeyInfo - record type for character data for KbdCharIn and KbdPeek}
191
(* #pragma pack(2) ??? *)
193
chChar:char; {ASCII character code; the scan code received}
194
{from the keyboard is translated to the ASCII}
198
chScan:byte; {scan Code received from the keyboard}
199
fbStatus:byte; {state of the keystroke event, see KbdTrF_* constants}
200
bNlsShift:byte; {NLS shift status (always 0?)}
201
fsState:word; {shift key status, see KbdStF_* constants}
202
Time:cardinal); {time stamp indicating when a key was pressed,}
203
{specified in milliseconds from the time }
204
{the system was started }
206
chScan2:char; (* should be chScan, fbStatus and bNlsShift, *)
207
fbStatus2:byte; (* but this construct is unsupported currently *)
210
PKbdKeyInfo=^TKbdKeyInfo;
211
KbdKeyInfo=TKbdKeyInfo; {for better compatibility with other compilers}
213
{record type for KbdStringIn}
215
cb:word; {length of the input buffer, maximum length is 255}
216
cchIn:word; {number of bytes actually read into the buffer}
218
PStringInBuf=^TStringInBuf;
219
StringInBuf=TStringInBuf;
221
{TKbdInfo record type, for KbdSet/GetStatus}
223
cb, {total length in bytes, 10 is the only valid value }
224
fsMask, {see TKbdInfo.fsMask constants, higher bits reserved}
226
chTurnAround, {definition of the turn-around character, in ASCII }
227
{and extended-ASCII format, the turn-around character}
228
{is defined as the carriage return, in ASCII format }
229
{only, the turn-around character is defined in the }
230
{low-order byte; usually $000D }
231
fsInterim, {interim character flags: bits 0-4 and 6 - reserved }
233
{ bit 5 - application}
240
{ bits 8-15 - NLS shift }
242
fsState:word; {shift state, see TKbdInfo.fsState constants}
247
{record type for KbdGetHWID}
249
cb, {length in bytes, on input length of the TKbdHWID}
250
{record (at least 2), on output the actual number}
252
idKbd, {keyboard type: $0000 = undetermined keyboard type}
253
{ $0001 = PC-AT Standard Keyboard }
254
{ $AB41 = 101 Key Enhanced Keyboard }
255
{ $AB41 = 102 Key Enhanced Keyboard }
256
{ $AB54 = 88 and 89 Key Enhanced }
258
{ $AB85 = 122 Key Enhanced Keyboard }
259
{- see Keyboard_* constants }
260
usReserved1, {reserved, returned set to zero (secondary ID?)}
261
usReserved2:word; {reserved, returned set to zero}
266
{record type for KbdXlate}
267
(* #pragma pack(2) ???*)
271
CharData:TKbdKeyInfo);
273
chChar:char; {ASCII character code; the scan code received}
274
{from the keyboard is translated to the ASCII}
278
chScan, {scan Code received from the keyboard}
279
fbStatus, {state of the keystroke event,}
280
{see KbdTrF_* constants }
281
bNlsShift:byte; {NLS shift status (always 0?)}
282
fsState:word; {shift key status, see KbdStF_* constants}
283
Time:cardinal; {time stamp indicating when a key was pressed,}
284
{specified in milliseconds from the time }
285
{the system was started }
286
fsDD:word; {device driver returned flag, }
287
{see KbdDDFlagWord notes below}
288
fsXlate:word; {translation flag: 0 - translation incomplete,}
289
{ 1 - translation complete }
290
fsShift:word; {identifies the state of translation across }
291
{successive calls, initially the value should }
292
{be zero; it may take several calls to this }
293
{function to complete a character, the value }
294
{should not be changed unless a new translation}
295
{is required (that is, reset value to zero) }
296
sZero:word); {reserved, set to 0}
298
chScan2, (* should be chScan, fbStatus and bNlsShift, *)
299
fbStatus2, (* but this construct is unsupported currently *)
302
PKbdTrans=^TKbdTrans;
305
{KbdDDFlagWord notes:
306
bits 15-14 Available. These bits are available for communication between
307
monitors; they are not used by the physical device driver. The
308
monitor applications coordinate the use of these flags.
309
Bits 13-10 Reserved, set to zero. Monitors must pass these flags as is.
310
They must set these flags to 0 in packets they create.
311
Bit 9 Accented. This key is translated using the previous key passed,
312
which is an accent key. Where an accent key is pressed, and the
313
following key does not use the accent, a packet containing the
314
accent character itself is first passed with this bit set. The
315
scan code field of MonFlagWord (see above) would be 0,
316
indicating a non-key generated record. A valid packet
317
containing that following keystroke is then passed without this
319
Bit 8 Multimake. The translation process sees this scan code as
320
a typematic repeat of a toggle key or a shift key. Because
321
toggle and shift keys only change state on the first make after
322
each key-break, no state information is changed. For example,
323
the NumLock toggle bit in the shift status word is not changed,
324
even though this can be the NumLock key. If this key is a valid
325
character, it does not go into the Keyboard Input Buffer (KIB)
326
once this bit is set.
327
Bit 7 Secondary. The scan code prior to the one in this packet was
328
the Secondary Key Prefix (see below).
329
Bit 6 Key break. This record is generated by the release (the break)
331
Bits 5-0 Key type. This numeric field flags the physical device driver
332
and reports that this is a key that requires action. The number
333
in this field is filled in during the translation of the scan
334
code. The value allows the driver to act on keystrokes without
335
regard for what scan codes the keyboard uses or character codes
336
that the current translation process may be using. The
337
following values are currently defined:
339
- Value for keys that are always placed in the KIB.
340
Zero = no special action, always place in KIB.
342
- Values acted on prior to passing packet to monitors.
343
Except for the final keystroke of the DUMP key sequences,
344
all of these values are passed on to the monitors. They
345
are not placed in the KIB. The XlatedChar and XlatedScan
346
fields are undefined for these values:
347
01h ACK. This scan code is a keyboard acknowledge.
348
Personal Computer IBM* AT* attached keyboards
349
set this value on an FAh scan code.
350
02h Secondary key prefix. This scan code is a prefix
351
generated by the Enhanced Keyboard. It indicates
352
that the next scan code coming is one of the
353
secondary keys that exists on that keyboard.
354
Usually set on an E0h scan code or an E1h scan
356
03h Kbd overrun. This scan code is an overrun
357
indication from the keyboard. On an IBM Personal
358
Computer AT-attached keyboard, this value would be
359
set on an FFh scan code.
360
04h Resend. This scan code is a resend request from the
361
keyboard. On an IBM Personal Computer AT-attached
362
keyboard, this value would be set on an FEh scan
364
05h Reboot key. This scan code completes the multi-key
365
restart sequence. On an IBM Personal Computer AT
366
attached-keyboard, this value would be used when
367
the Ctrl+Alt+Delete sequence is used.
368
06h Dump key. This scan code completes the multi-key
369
Stand Alone Dump request sequence. On an IBM
370
Personal Computer AT-attached keyboard, this value
371
would be used on completion of the second
372
consecutive press of Ctrl+Alt+NumLock or
373
Ctrl+Alt+F10 without other keystrokes between the
376
0Ah See entries below.
378
0Bh Invalid accent combination. This scan code follows
379
an accent scan code but the combination is not
380
valid, and neither key is put in the KIB.
381
(Note: This is set if the Canadian-French code
383
0Ch System-defined hot keys.
385
-0Fh Reserved. Treated as undefined. See entry 3Fh.
386
- Values acted on after passing packet to monitors. Except
387
where noted, these values are placed in the KIB when the
388
physical device driver is in binary mode; they are not
389
placed in the KIB when the physical device driver is in
390
ASCII mode. (Also listed are those that never get placed
392
07h Shift key. This scan code translates as a shift key
393
and affects the shift status fields of the CharData
394
record, but does not generate a defined character.
395
It is not placed in the KIB. The XlatedChar field
396
is undefined. The scan code field is 0.
397
08h Pause key. This scan code is translated as the key
398
sequence meaning pause. On an IBM Personal Computer
399
AT-attached keyboard, this value is used when the
400
Ctrl+NumLock sequence is used. The key itself is
401
not placed in the KIB.
402
09h Pseudo-Pause key. This scan code is translated into
403
the value that is treated as the Pause key when the
404
physical device driver is in ASCII mode. On most
405
keyboards, this would be when the Ctrl+S
406
combination is used. The key itself is not placed
408
0Ah Wake-up key. This scan code follows a Pause key or
409
Pseudo-Pause key, which causes the Pause state to
410
end. The key itself is not placed in the KIB.
411
10h Accent key. This scan code is translated and used
412
as a key to alter the translation of the next key
413
to come in. The packet containing this value is
414
passed when the accent key is pressed, but it is
415
not put into the KIB, unless the Accented bit is
416
ON. The next key determines this decision. If the
417
next key is one that can be accented, then it is
418
passed by itself with the Accented bit ON. If that
419
next key cannot be accented by this accent, then
420
two packets are passed. The first contains the
421
character to print for the accent itself. It has
422
the Accent key value and the Accented flag (which
423
allows the packet to be put in the KIB). The second
424
packet contains a regular translation of that
426
(Note: The two packets get passed for every
427
language except Canadian-French - see entry 0Bh.)
428
11h Break key. This scan code is translated as the key
429
sequence meaning break. On the IBM Personal
430
Computer AT-attached keyboard, this value is used
431
where the Ctrl+Break sequence is used.
432
12h Pseudo-Break key. This scan code is translated into
433
the value that is treated as the Break key when the
434
physical device driver is in ASCII mode. On most
435
keyboards, this would be when the Ctrl+C
436
combination is used. Notice that the event
437
generated by this key is separate from the one
438
generated by the Break key when in the binary mode.
439
13h Print Screen key. This scan code is translated as
440
the key sequence meaning Print Screen. On an IBM
441
Personal Computer AT-attached keyboard, this value
442
is used where the Shift+PrtSc sequence is used.
443
14h Print Echo key. This scan code is translated as the
444
key sequence meaning Print Echo. This value is used
445
where the Ctrl+PrtSc sequence is used.
446
15h Pseudo-Print Echo key. This scan code is translated
447
into the value that is treated as the Print Echo
448
key when the physical device driver is in ASCII
449
mode. On most keyboards, this would show as the
451
16h Print-Flush key. This scan code is translated into
452
the key sequence Print-Flush. This value is used
453
where the Ctrl+Alt+PrtSc sequence is used.
455
-2Fh Reserved, set to zero. Treated as undefined. See
457
- Values for packets not generated by a keystroke:
461
-3Eh Reserved. Treated as undefined. See entry 3Fh.
462
- Value for keys the translation process does not recognize:
463
3Fh Undefined. This scan code, or its combination with
464
the current shift state, is not recognized in the
468
{header of TXLateTbl}
470
XTableID:word; {code page number}
471
XTableFlags1:word; {bits 0-2 determine which shift key or key }
472
{combination affects Char3 of each TXLateKeyDef }
473
{element, bits 7-10 determine which shift key or}
474
{key combination causes Char5 to be used in each}
475
{TXLateKeyDef element }
476
{bit 0 - ShiftAlt (use Shift+Alt instead of }
478
{bit 1 - AltGrafL (use left Alt key as }
480
{bit 2 - AltGrafR (use right Alt key as }
482
{bit 3 - ShiftLock (treat Caps Lock as }
484
{bit 4 - DefaultTable (default table for the }
486
{bit 5 - ShiftToggle (1 = toggle ShiftLock, }
488
{bit 6 - AccentPass (pass accent and non-accent }
489
{ key through; 1 = pass on accent keys}
490
{ and beep, 0 = beep only }
491
{bit 7 - CapsShift (Caps+Shift uses Char5) }
492
{bit 8 - MachDep (machine-dependent table) }
493
{bits 9-10 reserved }
494
{bits 11-15 reserved }
495
XTableFlags2:word; {reserved, set to zero}
496
KbdType:word; {keyboard type, 1 for extended (all common types)}
497
KbdSubType:word; {reserved}
498
XtableLen:word; {length of table}
499
EntryCount:word; {number of KeyDef entries}
500
EntryWidth:word; {width of KeyDef entries}
501
Country:word; {language ID}
502
TableTypeID:word; {the table type; 1st byte (type): 01X 00X }
503
{ 2nd byte (sub-type): 00X reserved}
504
SubCountryID:cardinal;
505
{sub-language identifier}
506
Reserved:array[1..8] of word;
510
{element of TXLateTbl, not all entries are used (unused entries are zero)}
512
XlateOp:word; {translate operation specifier; }
513
{bits 0- 6 - AccentFlags (see Notes 1 and 8)}
514
{bits 7-15 - KeyType (see Note 2) }
521
PXLateKeyDef=^TXLateKeyDef;
523
{record type for character definition in TAccentEntry}
529
{accent entry definitions for TAccentTable, see Notes 1 and 9}
531
NonAccent:TKeyCode; {char/scan code when}
532
{not used as accent }
533
CtlAccent:TKeyCode; {char/scan code when}
534
{used with Ctrl key }
535
AltAccent:TKeyCode; {char/scan code when}
537
Maps:array[1..20] of TKeyCode; {from char-to-char for translation}
539
PAccentEntry=^TAccentEntry;
541
{table of accent key definitions for TXLateTbl}
542
TAccentTable=array[1..7] of TAccentEntry;
543
PAccentTable=^TAccentTable;
545
{record type for SetCustXT, one element for each possible scan code
546
(entries are in scan code order, based on the remapped scan codes
547
returned by the keyboard controller)}
550
KeyDefs:array [1..127] of TXLateKeyDef;
551
AccentTbl:TAccentTable;
553
PXLateTbl=^TXLateTbl;
555
{Remarks for TXLateTbl record type:
557
The request changes the device driver resident code page for the system
558
and updates the zero entry of the Code Page Control Block.
561
The AccentFlags field of the KeyDef record has seven flags that are
562
individually set if a corresponding entry in the accent table applies to this
563
scan code. If the key pressed immediately before the current one was an
564
accent key and the bit for that accent is set in the AccentFlags field for
565
the current key, the corresponding AccentTable entry is searched for the
566
replacement character value to use. If no replacement is found and bit 6 of
567
the XlateFlags1 field is set, the not-an-accent beep is sounded and the
568
accent character and current character are passed as two separate
569
characters. Also see Note 8.
573
The KeyType field of the KeyDef record currently has the following values
574
defined. The remaining values up to 1Fh are undefined. The effect of each
575
type of shift is defined below. Except where otherwise noted, when no
576
shifts are active, Char1 is the translated character. (See Note 3.) Notice
577
that any of the Alt, Alt+Char, Alt+Shift, or Alt+Gr keys (or all of them) can
578
be present on a keyboard based on the AltGrafL and AltGrafR bits in the
579
XTableFlags1 flag word in the table header.
581
01h AlphaKey. Alphabetical character key:
583
Shift Uses Char2. If Caps Lock, uses Char1.
584
Caps Lock Uses Char2. If Shift, uses Char1.
585
Ctrl Set standard control code for this key's Char1 value.
587
Alt Standard extended code. See Note 7.
588
Alt+Char Uses Char3, if it is not 0.
589
Alt+Shift Uses Char3, if it is not 0.
590
Alt+Gr Uses Char3, if it is not 0.
592
02h SpecKey. Special nonalphabetic character key, no Caps Lock or Alt:
595
Caps Lock No effect, only depends on Shift, or Ctrl.
597
Alt Marked undefined.
598
Alt+Char Uses Char3, if it is not 0.
599
Alt+Shift Uses Char3, if it is not 0.
600
Alt+Gr Uses Char3, if it is not 0.
602
03h SpecKeyC. Special nonalphabetic character key with Caps Lock. See
605
Shift Uses Char2. If Caps Lock, uses Char1.
606
Caps Lock Uses Char2. If Shift, uses Char1.
608
Alt Uses Char4, if not zero. See Note 7.
609
Alt+Char Uses Char3, if it is not 0.
610
Alt+Shift Uses Char3, if it is not 0.
611
Alt+Gr Uses Char3, if it is not 0.
613
04h SpecKeyA. Special nonalphabetic character key with Alt (no Caps
617
Caps Lock No effect; depends on Shift, Ctrl, or Alt only.
618
Ctrl See Notes 5 and 9.
619
Alt See Notes 7 and 10.
620
Alt+Char Uses Char3, if it is not 0.
621
Alt+Shift Uses Char3, if it is not 0.
622
Alt+Gr Uses Char3, if it is not 0.
624
05h SpecKeyCA. Special nonalphabetic character key with Caps Lock and
627
Shift Uses Char2. If Caps Lock, uses Char1.
628
Caps Lock Uses Char2. If Shift, uses Char1.
631
Alt+Char Uses Char3, if it is not 0.
632
Alt+Shift Uses Char3, if it is not 0.
633
Alt+Gr Uses Char3, if it is not 0.
635
06h FuncKey. Function keys. Char1 = n in Fn; Char2 ignored. Sets
636
extended codes 58+Char1, if no shift; if F11 or F12, uses 139 and 140.
638
Shift Sets extended codes 83+Char1. F11 and F12 use 141
639
and 142, respectively.
640
Caps Lock No effect on function keys.
641
Ctrl Sets extended codes 93+Char1. F11 and F12 use 143
642
and 144, respectively.
643
Alt Sets extended codes 103+Char1. F11 and F12 use 145
644
and 146, respectively.
645
Alt+Char Uses Char3, if it is not 0.
646
Alt+Shift Uses Char3, if it is not 0.
647
Alt+Gr Uses Char3, if it is not 0.
649
07h PadKey. Keypad keys (see Note 5 for definition of Char1). Note that
650
nonshifted use of these keys is fixed to the extended codes:
652
Shift Uses Char2, unless Num Lock. See Note 5.
653
Caps Lock No effect on pad keys, unless Num Lock. See Note 5.
654
Ctrl Sets extended codes. See Note 5.
655
Alt Used to build a character. See Note 5.
656
Alt+Char Uses Char3, if it is not 0.
657
Alt+Shift Uses Char3, if it is not 0.
658
Alt+Gr Uses Char3, if it is not 0.
660
08h SpecCtlKey. Special action keys, when used with Ctrl pressed:
662
Shift No effect on these keys.
663
Caps Lock No effect on these keys.
666
Alt+Char Uses Char3, if it is not 0.
667
Alt+Shift Uses Char3, if it is not 0.
668
Alt+Gr Uses Char3, if it is not 0.
670
09h PrtSc. Print Screen key; sets Char1 normally (see Note 17):
672
Shift Signal the Print Screen function.
673
Caps Lock No effect on this key.
674
Ctrl Sets extended code and signals the Print Echo function.
675
Alt Marked undefined.
676
Alt+Char Uses Char3, if it is not 0.
677
Alt+Shift Uses Char3, if it is not 0.
678
Alt+Gr Uses Char3, if it is not 0.
680
0Ah SysReq. System Request key; treated like a shift key. See Note 6.
682
0Bh AccentKey. Keys that affect the next key pressed (also known as
683
dead keys). Char1 is an index into the AccentTbl field of the
684
XlateTable, selecting the AccentEntry that corresponds to this key.
685
Char2 and Char3 do the same for the shifted Accent character. See
688
Shift Uses Char2 to index to applicable AccentEntry.
689
Caps Lock No effect on this key.
690
Ctrl Uses CtlAccent character from AccentEntry. See Note 8.
691
Alt Uses AltAccent character from AccentEntry. See Note 8.
692
Alt+Char Uses Char3 to index to applicable AccentEntry.
693
Alt+Shift Uses Char3 to index to applicable AccentEntry.
694
Alt+Gr Uses Char3 to index to applicable AccentEntry.
696
Note: Key types 0Ch - 13h set Char1 and Char2 to mask values as defined
699
0Ch ShiftKeys. Shift or Ctrl key, sets and clears flags. Char1 holds the
700
bits in the lower byte of the shift status word to set when the
701
key is down and clear when the key is released. Char2 does the
702
same thing for the upper byte of the shift status word unless the
703
secondary key prefix (hex E0) is seen immediately prior to this key,
704
in which case Char3 is used in place of Char2.
706
0Dh ToggleKey. General toggle key (like Caps Lock). Char1 holds the
707
bits in the lower byte of the shift status word to toggle on the
708
first make of the key after it is pressed. Char2 holds the bits in
709
the upper byte of the shift status word to set when the key is
710
down and clear when the key is released unless the secondary key
711
prefix (hex E0) is seen immediately prior to this key, in which case
712
Char3 is used in place of Char2.
714
0Eh AltKey. Treated just like ShiftKeys above, but has its own key
715
type, because when seen, the accumulator used for Alt+PadKey
716
entry is zeroed to prepare such entry (see Note 5). Sometimes this
717
key is treated as the AltC/S/G key (that is, either Alt+Char,
718
Alt+Shift, or Alt+Gr) if one of the AltGraf bits is on in XTableFlags1.
720
0Fh Num Lock. Normally behaves like ToggleKey, but the physical
721
keyboard device driver sets a pause screen indication when this
722
key is used with the Ctrl key pressed. The pause is cleared on the
723
following keystroke if that stroke is a character-generating key.
725
10h Caps Lock. This key is treated as a type 0Dh toggle key. It has a
726
separate entry here so that it can be processed like a Shift Lock
727
key when that flag is set in the XTableFlags1 word in the header.
728
When treated as a Shift Lock, the Caps Lock flag in the shift
729
status word is set on on any make of this key, and only cleared
730
when the left or right shift key is pressed. Char2 and Char3 are
731
processed the same as ToggleKey.
733
11h Scroll Lock. Normally behaves like ToggleKey but has a separate
734
entry here. When used with Ctrl, it can be recognized as
737
12h XShiftKey. Extended Shift Key (for Country support). See Note 9.
739
13h XToggleKey. Extended Toggle Key (for Country support). See Note 9.
741
14h SpecKeyCS. Special key 1 for country keyboard processing. See Note 15.
744
Caps Lock Uses Char4.
748
Alt+Shift Uses Char3.
750
Caps+Shift Uses Char5.
752
15h SpecKeyAS. Special key 2 for country keyboard processing. See Note 15.
755
Caps Lock No effect on this key.
757
Alt Uses Char 4. See Note 14.
758
Alt+Char Uses Char 3. See Note 14.
759
Alt+Shift Uses Char 3. See Note 14.
760
Alt+Gr Uses Char 3. See Note 14.
762
1Ah Extended Extended key. This corresponds to the BIOS level support
763
provided for INT 16h, Functions 20h, 21h, and 22h.
766
Caps Lock No effect on this key.
769
Alt+Char Uses Char 3, if not 0.
770
Alt+Shift Uses Char 3, if not 0.
771
Alt+Gr Uses Char 3, if not 0.
773
1FFh Reserved, except for 1Ah, the Extended Extended key (see above).
777
Undefined Character Code. Any key combination that does not fall into any
778
of the defined categories. For example, the Ctrl key pressed along with a
779
key that has no defined control mapping is mapped to the value 0, and the
780
key type is set in the KeyPacket record indicating undefined translation.
781
The KeyPacket record passed to the monitors, if installed, contain the
782
original scan code in the ScanCode field and the 0 in the Character field for
783
this key. Notice that no character data records with an undefined character
784
code are placed in the keyboard input buffer.
788
Ctrl Key. The six possible situations that can occur when a key is pressed
789
with only the Ctrl+shift key are shown below:
791
- The key pressed is an AlphaKey character. In this case, the Ctrl plus
792
Char1 combination defines one of the standard defined control codes
793
(all numbers are decimal):
795
Ctrl- Mapping Code Name Ctrl- Mapping Code Name
796
----- ------- --------- ----- ------- ---------
811
Notice that any key defined as AlphaKey uses the Char1 code value
812
minus 96 (ASCII code for a) plus 1 to set the mapping shown above.
813
Any scan code defined as AlphaKey must assign to Char1 one of the
814
allowed lower case letters.
816
- The key pressed is a nonalpha character, such as [, but is not an action
817
key, such as Enter, Backspace, or an arrow key. This is a
818
SpecKey[C][A] in the list of key types in the previous example. In this
819
case, with one exception, the mapping is based on the scan code of the
820
key. Though the key can be relabeled, the Ctrl+Char combination is
821
always mapped based on the scan code of the key using the following
822
table (all numbers are decimal):
824
Scan US Kbd Mapped Name of
825
Code Legend Value New Code
826
---- ------ ------ --------
829
12 - _ 31 US (see Note below)
834
Note: The mapping for the hyphen character (-) is the one exception.
835
The scan code for it is ignored; only the ASCII code for hyphen
836
(decimal 45) is looked for in Char1 when mapping the Ctrl+-
837
combination. This is because there can be more than one
838
occurrence of the hyphen (-) key on the keyboard. The Ctrl+-
839
(PadKey minus) combination produces character/scan code values
840
of 00/8Eh, respectively.
842
- The key pressed is an action key such as Enter, Backspace, or an arrow
843
key. These keys generate special values when used in conjunction with
844
the Ctrl key. Those actions are defined in other notes where they
845
apply. Two particular keys in this category are:
848
Ctrl+Backspace = Del(127)
850
- The key pressed is a function key, F1 - F12. See the FuncKey
851
description in Note 2.
853
- The key pressed is an accent key. See Note 8.
855
- The key is not defined in conjunction with Ctrl. In this case, the key
856
is treated as undefined, as described in Note 3.
860
PadKey. The pad keys have several uses that depend on various shift
861
states. Some of them are based on their position on the keyboard. Because
862
keyboard layouts change, the hard-coded assumed positions of the keypad
863
keys, with the offset value that must be coded into Char1, are defined
864
below. Any remapping must use the Char1 values shown below for the keys
865
that correspond to the pad keys given by the Legend or Char2 values:
867
US Kbd Scan Char1 Char2
868
Legend Code Required US Kbd With Ctrl
869
------- ---- --------- ------- -----------
870
Home 7 71 Decimal 0 ASCII 7 Decimal 119
871
Up 8 72 " 1 " 8 " 141
872
PgUp 9 73 " 2 " 9 " 132
874
Left 4 75 " 4 " 4 " 115
876
Right 6 77 " 6 " 6 " 116
878
End 1 79 " 8 " 1 " 117
879
Down 2 80 " 9 " 2 " 145
880
PgDn 3 81 " 10 " 3 " 118
881
Ins 0 82 " 11 " 0 " 146
882
Del . 83 " 12 " . " 147
884
Notice that when Num Lock is off, or if Shift is active and Num Lock on, the
885
code returned is the extended code. The code returned corresponds to the
886
Legends above (Home, PgUp, and so forth). When Num Lock is on, or if
887
Shift is active and Num Lock is off, the code returned is Char2. Notice that
888
the + and - keys also return Char2 when the shift key is down.
890
When the Alt key is used with the PadKeys, the absolute value of the
891
pressed key (looked up using the required Char1 value) is added to the
892
accumulated value of any of the previous numeric keys pressed, without
893
releasing the Alt key. Before adding the new number to the accumulated
894
value, that accumulation is multiplied by ten, with overflow beyond 255
895
ignored. When Alt is released, the accumulation becomes a Character code
896
and is passed along with a scan code of zero. Notice that if any key other
897
than the 10 numeric keys is pressed, the accumulated value is reset to zero.
898
When the keypad *, -, or + keys are pressed while the Alt key is down, the
899
extended characters 55, 74, and 78 (decimal) are returned, respectively.
901
When AltGraphics is used with the PadKeys, the Char3 value is returned if it
902
is nonzero, and if an AltGraf bit is set in XTableFlags1; otherwise, it is
903
treated the same as the Alt key.
905
On the Enhanced keyboard, the secondary keypad keys return, as an
906
extended character, the scan code of the key plus 80 (decimal) when
907
pressed in conjunction with the Alt key. The secondary / key returns an
908
extended character of 164, when pressed in conjunction with the Alt key.
912
State Key. Each state key entry has Char1, Char2, and Char3 defined as
915
- Char1. A mask to set the appropriate bit in the low byte of the
916
keyboard Shift Flags when the state key is pressed. When the state
917
key is a toggle key, the set bit is toggled each additional time the key
918
is pressed. When the state key is not a toggle key, the set bit is
919
cleared when the key is released.
921
- Char2. A mask to set the appropriate bit in the high byte of the
922
Keyboard Shift Flags when the key is pressed.
924
- Char3. Used in place of Char2 when the secondary key prefix is seen
925
immediately prior to this key.
927
The masks are shown below (numbers are in hex):
929
Key Char1 Char2 Char3
930
----------- ----- ----- -----
940
Notice that the INS key is not treated as a state key, but as a pad key.
941
Also, SysReq is included here because it is treated as a shift key.
945
Alt Character. Most of the keys defined in a category that allows the Alt
946
key (AlphaKey, SpecKeyA, SpecKeyCA) return a value called an extended
947
character. This value is a character code of 00H or E0H, with a second byte
948
(using the ScanCode field of the CharData record) defining the extended
949
code. In most cases, this value is the scan code of the key. Since the
950
legend on these keys can be remapped on a foreign language keyboard, the
951
Alt-based extended code is hard to define in a general sense. The following
954
- AlphaKey. The extended code is derived from Char1 (the lower-case
955
character) as it was originally mapped on the PC keyboard. The
956
original scan code value is the extended code that a character returns.
957
These keys can be moved and will still return their original Alt
960
- SpecKeyA and SpecKeyCA. This category is used for all keys that are
961
not an alphabetic character or an action code (like Enter or Backspace,
962
the only exception being the Tab key, which is treated as a character).
963
On foreign keyboards, these keys can be moved around and can have
964
new values assigned to them, such as special punctuation symbols.
965
Therefore, the Alt mappings must be based on the real scan code as
966
any keys defined by the SpecKey_ classification will have only an Alt
967
mapping, if it is in one of the positions defined below. In that case,
968
the Alt extended code is as shown:
970
Scan US Kbd Alt Scan US Kbd Alt
971
Code Legend Value Code Legend Value
972
---- ------ ----- ---- ------ -----
976
5 4 $ 123 28 Enter 28
980
9 8 * 127 43 \ | 43 (equals W.T.C. key number 42)
986
The secondary / key returns an extended character of 164 when
987
pressed while Alt is down.
989
- FuncKey. Defined in Note 2.
991
- SpecCtlKey. The Alt+ values of the Escape, Backspace, and Enter keys
992
are extended characters equaling 1, 14, and 28 (decimal), respectively.
994
When AltGraphics is used, the Char3 value is returned if it is nonzero and if
995
an AltGraf bit is set in XTableFlags1. Otherwise, it is treated the same as
1000
Accent Key. When an accent key is pressed with Ctrl or Alt, it is treated as
1001
a regular key. The character it translates to is the one in the CtlAccent or
1002
AltAccent field of the AccentEntry pointed to by the Char5 value of the
1003
KeyDef. If the key being defined has no defined value with Ctrl or Alt, it
1004
should have zeros in the field of the undefined combination.
1006
When an accent key is pressed by itself (or with Right Shift, Left Shift, or
1007
AltGraphics), it is not translated immediately. The Char1 (or Char2, when
1008
Left or Right Shift or AltGraphics is used) index in the KeyDef record is
1009
used with the next key received to check if the next key has an accent
1010
mapping. If that next key has no mapping for this accent (that is, if it has
1011
no bit set in its AccentFlags), or if that next key is not found in this
1012
accent's AccentEntry, then the character value in the NonAccent field of the
1013
AccentEntry is used as the character to display. It is followed by the
1014
translation of that next key after the not-an-accent beep is sounded.
1016
Notice that if a key doesn't change when a Left or Right Shift key is
1017
pressed, it should use the same value for Char1 and Char2 so the accent
1018
applies in both the shifted and nonshifted cases. If the accent value is
1019
undefined when used with a shift key or AltGraphics, the value in Char2 or
1022
Any accent key that doesn't have an Alt or Ctrl mapping should put zeros in
1023
the AltAccent and CtlAccent fields of its AccentEntry. If the value in the
1024
table is between 1 and 7, then the key is considered an accent key and
1025
further accent key processing is indicated. See Note 1 for more information.
1029
Extended State Key. For special Country support, the keyboard device
1030
driver maintains another byte of shift status. Key types 12h and 13h are
1031
provided for manipulation of that byte. The other fields of the KeyDef are:
1033
- Char1. A mask in which bits that are on define the field being used for
1034
the Char2 value. Only bits in the NLS shift status byte that correspond
1035
to the bits in this byte are altered by the Char2 value.
1037
- Char2. For KeyType 12h (Extended Shift), the value to OR into the
1038
byte when the make code is seen. Also, the inverted value is ANDed
1039
when the break code is seen. For KeyType 13h (Extended Toggle), the
1040
value XORed into the byte on each make code seen (break code
1043
- Char3. Use in place of the Char2 when the secondary key prefix (hex
1044
E0) is seen immediately prior to this key.
1046
For example, Char1 or Char2 can define single shift status bits to
1047
set/clear/toggle. Char2 can be a set of coded bits, delineated by Char1, that
1048
are set to a numeric value when the key is pressed and cleared to zero
1049
when released (or on the next press, if toggled). The whole byte can be
1050
set to Char2 when Char1 has all bits on.
1054
Space Key. The key treated as the space character should have a flag set
1055
in its AccentFlags field for each possible accent (that is, for each defined
1056
AccentEntry in the AccentTable). And each AccentEntry should have the
1057
Space character defined as one of its accented characters, with the
1058
translation having the same value as the accent character itself. The reason
1059
for this is that, by definition, an Accent Key followed by the space
1060
character maps to the accent character alone. If the table is not set up as
1061
just described, a not-an-accent beep is sounded whenever the accent key
1062
followed by a space is pressed.
1064
Notice that the space key is defined as a SpecKeyA (type 4) because its
1065
use, in conjunction with the Alt key, is allowed. In this case, and when
1066
used with the Ctrl key, it returns the ASCII space character. This works
1067
correctly, except in the case of the diaresis accent (double-dot) in code
1068
page 437. The space is treated as an invalid character and the beep result
1069
occurs, with the diaresis represented by double quotation marks. The
1070
characters displayed depend upon the language in effect when the invalid
1071
diaresis is encountered. For some languages, the character substituted is
1072
the double-quotation marks; for others, the character used is the F9h
1077
KbdType identifies the hardware-specific keyboard used by this table. The
1078
values and allowable types are the same as those specified in IOCTL call
1079
KBD_GETKEYBDTYPE (1 means extended keyboard, which is used for all common
1084
The DefaultTable flag in XtableFlags1 is used by the KEYB utility in loading
1085
code pages when changing from one language to another. It identifies the
1086
default code page to KEYB, should KEYB not find one or both CODEPAGE=
1091
The Language IDs and Subcountry IDs used are as follows:
1093
������������������������������������������������������Ŀ
1094
�Keyboard Layout �Keyboard Layout �Country �
1095
�Country Code �SubCountry Code � �
1096
������������������������������������������������������Ĵ
1097
� AR � 785 �Arabic-speaking �
1098
������������������������������������������������������Ĵ
1099
� BE � 120 �Belgium �
1100
������������������������������������������������������Ĵ
1101
� CF � 058 �Canadian-French �
1102
������������������������������������������������������Ĵ
1103
� CS � 243 �Czech Republic �
1104
������������������������������������������������������Ĵ
1105
� CS � 245 �Czech Republic �
1106
������������������������������������������������������Ĵ
1107
� DK � 159 �Denmark �
1108
������������������������������������������������������Ĵ
1109
� SU � 153 �Finland �
1110
������������������������������������������������������Ĵ
1111
� FR � 120 �France �
1112
������������������������������������������������������Ĵ
1113
� FR � 189 �France �
1114
������������������������������������������������������Ĵ
1115
� GR � 129 �Germany �
1116
������������������������������������������������������Ĵ
1117
� HE � 972 �Hebrew-speaking �
1118
������������������������������������������������������Ĵ
1119
� HU � 208 �Hungary �
1120
������������������������������������������������������Ĵ
1121
� IS � 197 �Iceland �
1122
������������������������������������������������������Ĵ
1124
������������������������������������������������������Ĵ
1126
������������������������������������������������������Ĵ
1127
� LA � 171 �Latin-American �
1129
������������������������������������������������������Ĵ
1130
� NL � 143 �Netherlands �
1131
������������������������������������������������������Ĵ
1132
� NO � 155 �Norway �
1133
������������������������������������������������������Ĵ
1134
� PL � 214 �Poland �
1135
������������������������������������������������������Ĵ
1136
� PO � 163 �Portugal �
1137
������������������������������������������������������Ĵ
1139
������������������������������������������������������Ĵ
1140
� SV � 153 �Sweden �
1141
������������������������������������������������������Ĵ
1142
� SF � 150F �Swiss-French �
1143
������������������������������������������������������Ĵ
1144
� SG � 150G �Swiss-German �
1145
������������������������������������������������������Ĵ
1146
� TR � 179 �Turkey �
1147
������������������������������������������������������Ĵ
1148
� UK � 166 �United Kingdom �
1149
������������������������������������������������������Ĵ
1150
� UK � 168 �United Kingdom �
1151
������������������������������������������������������Ĵ
1152
� US � 103 �United States �
1153
������������������������������������������������������Ĵ
1154
� YU � 234 �Former Yugoslavia �
1155
��������������������������������������������������������
1159
Keytype 15. When the Alt or Alt+Shift keys are pressed, both XlatedChar
1160
and XlatedScan in the CharData record will have the same value.
1164
If the Charx value is in the range of 1-7, then Charx identifies an accent
1165
key. Otherwise, Charx is treated as a valid ASCII character. This does not
1166
apply to Ctrl+Charx sequences.
1170
If Alt+Gr, Alt+Shift, or Alt+Ctrl are pressed, and Char3 is 0, the Alt key is
1171
used to translate to a valid result.
1175
The * key on the keypad of the Enhanced keyboard, although producing the
1176
same scan code/character as that of the IBM Personal Computer AT*
1177
keyboard, is treated differently because a dedicated Print Screen key exists
1178
on the Enhanced keyboard. The following scan codes/characters are
1179
returned by the physical keyboard device driver for the Enhanced keyboard
1180
* key on the keypad:
1189
Size. The code page described here has the following dimensions:
1192
127 KeyDefs @ 7 bytes = 889
1193
7 AccentEntries @ 46 bytes = 322
1197
If more than 6 AccentEntries are needed, then the following format is used:
1198
In the first 6 AccentEntries, the length is set at 20, with unused elements
1199
set to zero. For each AccentEntry of 7 and greater, up to 120 element pairs
1200
may exist, and the length is dynamic.
1202
For each AccentEntry of 7 and greater, the first byte in the record will
1203
contain the LENGTH of the AccentEntry record. The LENGTH value is defined
1204
as the total length in bytes of the AccentEntry record including the LENGTH
1207
The record is defined as follows:
1209
AccEnt <l,a,b,c,d,e,f,c1,s1,c2,s2..c120,s120>
1211
l is the total length in bytes of the AccEnt including itself.
1212
a &b are the scan code &char to use when the key following this accent
1213
is not affected by the accent so the accent itself must be used.
1214
c &d are the scan code &char to use when Ctl+[accent] is pressed.
1215
e &f do the same for Alt+[accent].
1216
c1,s1 - c120,s120 are the char/scan code mapping for accented translation.
1218
Adding more than 7 accents will make the standard 1251-byte table an
1219
extended variable size.
1224
{Register a keyboard subsystem within a session.}
1225
{ModuleName - dynamic link module name, maximum length is 8 bytes, ProcName is
1226
a dynamic link entry point name of a routine that receives control when any of
1227
the registered functions are called. Maximum length is 32 bytes, FnMask - see
1229
{Possible return codes:
1231
408 Error_Kbd_Invalid_ASCIIZ
1232
409 Error_Kbd_Invalid_Mask
1233
410 Error_Kbd_Register
1234
464 Error_Kbd_Detached
1235
504 Error_Kbd_Extended_SG}
1237
* There can be only one KbdRegister call outstanding for each session without
1238
an intervening KbdDeRegister. KbdDeRegister must be issued by the same
1239
process that issued the KbdRegister.}
1240
function KbdRegister(ModuleName,ProcName:PChar;FnMask:cardinal):word; cdecl;
1241
function KbdRegister(ModuleName,ProcName:string;FnMask:cardinal):word;
1243
{Deregister a keyboard subsystem previously registered within a session - only
1244
the process that issued the KbdRegister may issue KbdDeRegister.}
1245
{Possible return codes:
1247
411 Error_Kbd_Deregister
1248
464 Error_Kbd_Detached
1249
504 Error_Kbd_Extended_SG}
1250
function KbdDeRegister:word; cdecl;
1252
{Return a character data record from the keyboard.}
1253
{Key - see TKbdKeyInfo record type, WaitFlag - see IO_Wait and IO_NoWait
1254
constants, KbdHandle is the default keyboard (0) or a logical keyboard.}
1255
{Possible return codes are:
1257
375 Error_Kbd_Invalid_IOWait
1258
439 Error_Kbd_Invalid_Handle
1259
445 Error_Kbd_Focus_Required
1260
447 Error_Kbd_Keyboard_Busy
1261
464 Error_Kbd_Detached
1262
504 Error_Kbd_Extended_SG}
1264
* On an enhanced keyboard, the secondary enter key returns the normal
1265
character 0Dh and a scan code of E0h.
1266
* Double-byte character codes (DBCS) require two function calls to obtain the
1268
* If shift report is set with KbdSetStatus, the CharData record returned
1269
reflects changed shift information only.
1270
* Extended ASCII codes are identified with the status byte, bit 1 on and the
1271
ASCII character code being either 00h or E0h. Both conditions must be
1272
satisfied for the character to be an extended keystroke. For extended
1273
ASCII codes, the scan code byte returned is the second code (extended
1274
code). Usually the extended ASCII code is the scan code of the primary key
1276
* A thread in the foreground session that repeatedly polls the keyboard with
1277
KbdCharIn (with no wait), can prevent all regular priority class threads
1278
from executing. If polling must be used and a minimal amount of other
1279
processing is being performed, the thread should periodically yield to the
1280
CPU by issuing a DosSleep call for an interval of at least 5 milliseconds.}
1281
function KbdCharIn(var Key:TKbdKeyInfo;WaitFlag,KbdHandle:word):word; cdecl;
1283
{Return any available character data record from the keyboard
1284
without removing it from the buffer.}
1285
{Key - see TKbdKeyInfo record type, KbdHandle is the default keyboard (0)
1286
or a logical keyboard.}
1287
{Possible return codes are:
1289
439 Error_Kbd_Invalid_Handle
1290
445 Error_Kbd_Focus_Required
1291
447 Error_Kbd_Keyboard_Busy
1292
464 Error_Kbd_Detached
1293
504 Error_Kbd_Extended_SG}
1295
* On an enhanced keyboard, the secondary enter key returns the normal
1296
character 0Dh and a scan code of E0h.
1297
* Double-byte character codes (DBCS) require two function calls to obtain the
1299
* If shift report is set with KbdSetStatus the CharData record returned,
1300
reflects changed shift information only.
1301
* Extended ASCII codes are identified with the status byte, bit 1 on and the
1302
ASCII character code being either 00h or E0h. Both conditions must be
1303
satisfied for the character to be an extended keystroke. For extended
1304
ASCII codes, the scan code byte returned is the second code (extended
1305
code). Usually the extended ASCII code is the scan code of the primary key
1307
* A thread in the foreground session that repeatedly polls the keyboard with
1308
KbdCharIn (with no wait), can prevent all regular priority class threads
1309
from executing. If polling must be used and a minimal amount of other
1310
processing is being performed, the thread should periodically yield the CPU
1311
by issuing a DosSleep call for an interval of at least 5 milliseconds.}
1312
function KbdPeek(var Key:TKbdKeyInfo;KbdHandle:word):word; cdecl;
1314
{Read a character string (character codes only) from the keyboard.}
1315
{CharBuf is a buffer for returned characters, LenInOut - see TStringInBuf
1316
record type, WaitFlag - see IO_Wait and IO_NoWait constants, KbdHandle is the
1317
default keyboard (0) or a logical keyboard.}
1318
{Possible return codes are:
1320
375 Error_Kbd_Invalid_IOWait
1321
439 Error_Kbd_Invalid_Handle
1322
445 Error_Kbd_Focus_Required
1323
464 Error_Kbd_Detached
1324
504 Error_Kbd_Extended_SG}
1326
* The character strings may be optionally echoed on the display if echo mode
1327
is set. When echo is on each character is echoed as it is read from the
1328
keyboard. Echo mode and binary mode are mutually exclusive. Reference
1329
KbdSetStatus and KbdGetStatus for more information.
1330
* The default input mode is ASCII. In ASCII mode, 2-byte character codes only
1331
return in complete form. An extended ASCII code is returned in a 2-byte
1332
string. The first byte is 0Dh or E0h and the next byte is an extended code.
1333
* In input mode (binary, ASCII), the following returns can be set and
1334
retrieved with KbdSetStatus and KbdGetStatus:
1335
Turnaround Character
1337
Interim Character Flag
1339
* The received input length is also used by the KbdStringIn line edit
1340
functions for re-displaying and entering a caller specified string. On the
1341
next KbdStringIn call the received input length indicates the length of the
1342
input buffer that may be recalled by the user using the line editing keys.
1343
A value of 0 inhibits the line editing function for the current KbdStringIn
1345
* KbdStringIn completes when the handle has access to the physical keyboard
1346
(focus), or is equal to zero and no other handle has the focus.}
1347
function KbdStringIn(var CharBuf;var LenInOut:TStringInBuf;WaitFlag:word;
1348
KbdHandle:word):word; cdecl;
1349
function KbdStringIn(CharBuf:PChar;LenInOutP:PStringInBuf;WaitFlag:word;
1350
KbdHandle:word):word; cdecl;
1352
{Clear the keystroke buffer.}
1353
{KbdHandle is the default keyboard (0) or a logical keyboard.}
1354
{Possible return codes are:
1356
439 Error_Kbd_Invalid_Handle
1357
445 Error_Kbd_Focus_Required
1358
447 Error_Kbd_Keyboard_Busy
1359
464 Error_Kbd_Detached
1360
504 Error_Kbd_Extended_SG}
1362
* KbdFlushBuffer completes when the handle has access to the physical
1363
keyboard (focus), or is equal to zero and no other handle has the focus.}
1364
function KbdFlushBuffer(KbdHandle:word):word; cdecl;
1366
{Set the characteristics of the keyboard.}
1367
{Status - see TKbdInfo record type, KbdHandle is the default keyboard (0) or
1368
a logical keyboard.}
1369
{Possible return codes are:
1371
376 Error_Kbd_Invalid_length
1372
377 Error_Kbd_Invalid_Echo_Mask
1373
378 Error_Kbd_Invalid_Input_Mask
1374
439 Error_Kbd_Invalid_Handle
1375
445 Error_Kbd_Focus_Required
1376
447 Error_Kbd_Keyboard_Busy
1377
464 Error_Kbd_Detached
1378
504 Error_Kbd_Extended_SG}
1380
* Shift return (bit 8 in sysstate) must be disabled in ASCII mode.
1381
* KbdSetStatus is ignored for a Vio-windowed application.}
1382
function KbdSetStatus(var Status:TKbdInfo;KbdHandle:word):word; cdecl;
1384
{Get the current state of the keyboard.}
1385
{Status - see TKbdInfo record type, KbdHandle is the default keyboard (0) or
1386
a logical keyboard.}
1387
{Possible return codes:
1389
376 Error_Kbd_Invalid_Length
1390
439 Error_Kbd_Invalid_Handle
1391
445 Error_Kbd_Focus_Required
1392
447 Error_Kbd_Keyboard_Busy
1393
464 Error_Kbd_Detached
1394
504 Error_Kbd_Extended_SG}
1396
* The initial state of the keyboard is established by the system at
1397
application load time. Some default states may be modified by the
1398
application through KbdSetStatus. KbdGetStatus returns only those keyboard
1399
parameters initially set by KbdSetStatus. The returned parameters are:
1400
Input Mode, Interim Character Flags, Shift State, Echo State, TurnAround
1402
* KbdGetStatus completes only when the handle has access to the physical
1403
keyboard (focus) or the handle is 0 and no other handle has the focus.}
1404
function KbdGetStatus(var Status:TKbdInfo;KbdHandle:word):word; cdecl;
1406
{Set the code page used to translate key strokes received from the keyboard for
1408
{Reserved - reserved, must be set to 0, CodePage - code-page ID in the
1409
application's data area, must be equivalent to one of the code-page IDs
1410
specified on the CONFIG.SYS CODEPAGE= statement or 0, an error results
1411
otherwise, KbdHandle is the default keyboard (0) or a logical keyboard.}
1412
{Possible return codes:
1414
439 Error_Kbd_Invalid_Handle
1415
445 Error_Kbd_Focus_Required
1416
447 Error_Kbd_Keyboard_Busy
1417
448 Error_Kbd_Invalid_CodePage
1418
464 Error_Kbd_Detached
1419
504 Error_Kbd_Extended_SG}
1421
* Keyboard code page support is not available without the DEVINFO=KBD
1422
statement in the CONFIG.SYS file.}
1423
function KbdSetCp(Reserved,CodePage,KbdHandle:word):word; cdecl;
1425
{Query the code page being used to translate scan codes to ASCII characters.}
1426
{Reserved must be set to 0. The keyboard support returns the current code
1427
page for a specified keyboard handle in CodePage, it is one of the code page
1428
IDs specified in the CONFIG.SYS CODEPAGE= statement or 0000. KbdHandle is
1429
the default keyboard (0) or a logical keyboard.}
1430
{Possible return codes:
1432
373 Error_Kbd_Parameter
1433
439 Error_Kbd_Invalid_Handle
1434
445 Error_Kbd_Focus_Required
1435
447 Error_Kbd_Keyboard_Busy
1436
464 Error_Kbd_Detached
1437
504 Error_Kbd_Extended_SG}
1439
* CodePage is set to the currently active keyboard code page. A value of 0
1440
indicates the code page translation table in use is the ROM code page
1441
translation table provided by the hardware.}
1442
function KbdGetCp(Reserved:cardinal;var CodePage:word;KbdHandle:word):word;
1445
{Create a new logical keyboard.}
1446
{Handle for the new logical keyboard returned in KbdHandle.}
1447
{Possible return codes:
1449
440 Error_Kbd_No_More_Handle
1450
441 Error_Kbd_Cannot_Create_KCB
1451
464 Error_Kbd_Detached
1452
504 Error_Kbd_Extended_SG}
1454
* KbdOpen blocks while another thread has the keyboard focus (by way of
1455
KbdGetFocus) until the thread with the focus issues KbdFreeFocus.
1456
Therefore, to prevent KbdOpen from blocking, it is recommended that KbdOpen
1457
be issued only while the current thread has the focus. For example:
1458
KbdGetFocus wait until focus available on handle 0
1459
KbdOpen get a logical keyboard handle
1460
KbdFreeFocus give up the focus on handle 0}
1461
function KbdOpen(var KbdHandle:word):word; cdecl;
1463
{Close the existing logical keyboard identified by the keyboard handle}
1464
{KbdHandle is the default keyboard (0) or a logical keyboard}
1465
{Possible return codes:
1467
439 Error_Kbd_Invalid_Handle
1468
464 Error_Kbd_Detached
1469
504 Error_Kbd_Extended_SG}
1471
* KbdClose blocks while another thread has the keyboard focus (by way of
1472
KbdGetFocus) until the thread with the focus issues KbdFreeFocus.
1473
Therefore, to prevent KbdClose from blocking, it is recommended that
1474
KbdClose be issued only while the current thread has the focus. For
1476
KbdGetFocus wait until focus available on handle 0
1477
KbdClose close a logical keyboard handle
1478
KbdFreeFocus give up the focus on handle 0}
1479
function KbdClose(KbdHandle:word):word; cdecl;
1481
{Bind the logical keyboard to the physical keyboard.}
1482
{KbdHandle is the default keyboard (0) or a logical keyboard}
1483
{Possible return codes:
1485
439 Error_Kbd_Invalid_Handle
1486
445 Error_Kbd_Focus_Required
1487
464 Error_Kbd_Detached
1488
504 Error_Kbd_Extended_SG}
1489
function KbdGetFocus(WaitFlag,KbdHandle:word):word; cdecl;
1491
{Free the logical-to-physical keyboard bond created by KbdGetFocus.}
1492
{KbdHandle is the default keyboard (0) or a logical keyboard}
1493
{Possible return codes:
1495
439 Error_Kbd_Invalid_Handle
1496
445 Error_Kbd_Focus_Required
1497
464 Error_Kbd_Detached
1498
504 Error_Kbd_Extended_SG}
1500
* KbdFreeFocus may be replaced by issuing KbdRegister. Unlike other keyboard
1501
subsystem functions, the replaced KbdFreeFocus is called only if there is
1502
an outstanding focus.}
1503
function KbdFreeFocus(KbdHandle:word):word; cdecl;
1505
{Synchronize access from a keyboard subsystem to the keyboard device driver.}
1506
{WaitFlag - see IO_Wait and IO_NoWait constants (wait / don't wait for access
1507
to the device driver.}
1508
{Possible return codes:
1510
121 Error_Sem_TimeOut}
1512
* KbdSynch blocks all other threads within a session until return from the
1513
subsystem to the router. To ensure proper synchronization, KbdSynch should
1514
be issued by a keyboard subsystem if it intends to issue a DosDevIOCtl or
1515
access dynamically shared data. KbdSynch does not protect globally shared
1516
data from threads in other sessions.}
1517
function KbdSynch (WaitFlag:word):word; cdecl;
1519
{Raise the priority of the foreground keyboard's thread.}
1520
{Possible return codes:
1522
447 Error_Kbd_Keyboard_Busy
1523
504 Error_Kbd_Extended_SG}
1525
* KbdSetFgnd marks the current process that owns the keyboard. Threads in
1526
this process receive a priority boost. The previous foreground keyboard
1527
threads lose their priority boost.
1528
* This function should only be issued by a Keyboard Subsystem during
1529
KbdCharIn or KbdStringIn processing.}
1530
function KbdSetFgnd:word; cdecl;
1532
{Return the attached keyboard's hardware-generated identification value.}
1533
{HWID is a pointer to the caller's data area, see TKbdHWID, KbdHandle is the
1534
default keyboard (0) or a logical keyboard.}
1535
{Possible return codes:
1537
373 Error_Kbd_Parameter
1538
447 Error_Kbd_Keyboard_Busy
1539
464 Error_Kbd_Detached
1540
504 Error_Kbd_Extended_SG}
1542
* In past OS/2 releases, all keyboards could be supported by knowing the
1543
hardware family information available with keyboard IOCTL 77h. However,
1544
with the addition of the 122-key keyboard, recognition was not containable
1545
by hardware family information alone. The 122-key keyboard has a number of
1546
differences from other keyboards. Therefore, applications performing
1547
keystroke specific functions may need to determine specifically which
1548
keyboard is attached.
1549
* This function is of particular usefulness for applications providing Custom
1550
Translate Tables and mapping keyboard layouts.}
1551
function KbdGetHWID(var HWID:TKbdHWID;KbdHandle:word):word; cdecl;
1553
{Undocumented in official IBM documentation}
1554
function KbdSetHWID(var HWID:TKbdHWID;KbdHandle:word):word; cdecl;
1555
function KbdSetHWID(HWIDP:PKbdHWID;KbdHandle:word):word; cdecl;
1557
{Translate scan codes with shift states into ASCII codes.}
1558
{TransData - see TKbdTransData, KbdHandle is the default keyboard (0) or a
1560
{Possible return codes:
1562
439 Error_Kbd_Invalid_Handle
1563
445 Error_Kbd_Focus_Required
1564
447 Error_Kbd_Keyboard_Busy
1565
464 Error_Kbd_Detached
1566
504 Error_Kbd_Extended_SG}
1568
* It may take several calls to complete a translation because of accent key
1569
combinations, or other complex operations.
1570
* The fsShift and sZero are for use by the keyboard translation routines.
1571
These fields are reserved and must only be accessed by the caller prior
1572
to starting a translation sequence and then they must be set to zero.
1573
The KbdXlate function is intended to be used for translating a particular
1574
scan code for a given shift state. The KbdXlate function is not intended
1575
to be a replacement for the OS/2 system keystroke translation function.}
1576
function KbdXlate(var TransData:TKbdTrans;KbdHandle:word):word; cdecl;
1578
{Install, on the specified handle, the translate table which this call points
1579
to. This translate table affects only this handle.}
1580
{XLateTbl is the translation table used to translate scan code to ASCII code
1581
for a specified handle (the format of the translation table is documented in
1582
the Set Code Page IOCTL 50h), KbdHandle is the default keyboard (0) or a
1584
{Possible return codes:
1586
377 Error_Kbd_Invalid_Echo_Mask
1587
378 Error_Kbd_Invalid_Input_Mask
1588
439 Error_Kbd_Invalid_Handle
1589
445 Error_Kbd_Focus_Required
1590
447 Error_Kbd_Keyboard_Busy
1591
464 Error_Kbd_Detached
1592
504 Error_Kbd_Extended_SG}
1594
* The translate table must be maintained in the caller's memory. No copy of
1595
the translate table is made by KbdSetCustXt.
1596
* KbdSetCp reverses the action of KbdSetCustXt and sets the handle equal to
1597
one of the system translate tables. If memory is dynamically allocated by
1598
the caller for the translate table and is freed before the KbdSetCp is
1599
performed, KbdSetCp and future translations may fail.}
1600
function KbdSetCustXt(var XLateTbl:TXLateTbl;KbdHandle:word):word; cdecl;
1601
function KbdSetCustXt(var CodePage:word;KbdHandle:word):word; cdecl;
1602
function KbdSetCustXt(var XLateTblP:pointer;KbdHandle:word):word; cdecl;
1605
(* Following routines are not supported
1606
(just have a look in some C header
1607
file - you probably won't find it there either).
1609
KbdLoadInstance (index 6)
1610
KbdSwitchFgnd (index 15)
1611
KbdShellInit (index 16)
1616
{***************************************************************************}
1618
{***************************************************************************}
1621
function KbdRegister(ModuleName,ProcName:PChar;FnMask:cardinal):word; cdecl;
1622
external 'EMXWRAP' index 208;
1623
{external 'KBDCALLS' index 8;}
1625
function KbdRegister(ModuleName,ProcName:string;FnMask:cardinal):word;
1627
if byte(ModuleName[0])>8 then byte(ModuleName[0]):=8;
1628
ModuleName[Succ(byte(ModuleName[0]))]:=#0;
1629
if byte(ProcName[0])>32 then byte(ProcName[0]):=32;
1630
ProcName[Succ(byte(ProcName[0]))]:=#0;
1631
KbdRegister:=KbdRegister(@ModuleName[1],@ProcName[1],FnMask);
1634
function KbdDeRegister:word; cdecl;
1635
external 'EMXWRAP' index 220;
1636
{external 'KBDCALLS' index 20;}
1638
function KbdCharIn(var Key:TKbdKeyInfo;WaitFlag,KbdHandle:word):word; cdecl;
1639
external 'EMXWRAP' index 204;
1640
{external 'KBDCALLS' index 4;}
1642
function KbdPeek(var Key:TKbdKeyInfo;KbdHandle:word):word; cdecl;
1643
external 'EMXWRAP' index 222;
1644
{external 'KBDCALLS' index 22;}
1646
function KbdStringIn(var CharBuf;var LenInOut:TStringInBuf;WaitFlag:word;
1647
KbdHandle:word):word; cdecl;
1648
external 'EMXWRAP' index 209;
1649
{external 'KBDCALLS' index 9;}
1651
function KbdStringIn(CharBuf:PChar;LenInOutP:PStringInBuf;WaitFlag:word;
1652
KbdHandle:word):word; cdecl;
1653
external 'EMXWRAP' index 209;
1654
{external 'KBDCALLS' index 9;}
1656
function KbdFlushBuffer(KbdHandle:word):word; cdecl;
1657
external 'EMXWRAP' index 213;
1658
{external 'KBDCALLS' index 13;}
1660
function KbdSetStatus(var Status:TKbdInfo;KbdHandle:word):word; cdecl;
1661
external 'EMXWRAP' index 211;
1662
{external 'KBDCALLS' index 11;}
1664
function KbdGetStatus(var Status:TKbdInfo;KbdHandle:word):word; cdecl;
1665
external 'EMXWRAP' index 210;
1666
{external 'KBDCALLS' index 10;}
1668
function KbdSetCp(Reserved,CodePage,KbdHandle:word):word; cdecl;
1669
external 'EMXWRAP' index 205;
1670
{external 'KBDCALLS' index 5;}
1672
function KbdGetCp(Reserved:cardinal;var CodePage:word;KbdHandle:word):word;
1674
external 'EMXWRAP' index 203;
1675
{external 'KBDCALLS' index 3;}
1677
function KbdOpen(var KbdHandle:word):word; cdecl;
1678
external 'EMXWRAP' index 223;
1679
{external 'KBDCALLS' index 23;}
1681
function KbdClose(KbdHandle:word):word; cdecl;
1682
external 'EMXWRAP' index 217;
1683
{external 'KBDCALLS' index 17;}
1685
function KbdGetFocus(WaitFlag,KbdHandle:word):word; cdecl;
1686
external 'EMXWRAP' index 212;
1687
{external 'KBDCALLS' index 12;}
1689
function KbdFreeFocus(KbdHandle:word):word; cdecl;
1690
external 'EMXWRAP' index 218;
1691
{external 'KBDCALLS' index 18;}
1693
function KbdSynch (WaitFlag:word):word; cdecl;
1694
external 'EMXWRAP' index 207;
1695
{external 'KBDCALLS' index 7;}
1697
function KbdSetFgnd:word; cdecl;
1698
external 'EMXWRAP' index 221;
1699
{external 'KBDCALLS' index 21;}
1701
function KbdGetHWID(var HWID:TKbdHWID;KbdHandle:word):word; cdecl;
1702
external 'EMXWRAP' index 224;
1703
{external 'KBDCALLS' index 24;}
1705
function KbdSetHWID(var HWID:TKbdHWID;KbdHandle:word):word; cdecl;
1706
external 'EMXWRAP' index 225;
1707
{external 'KBDCALLS' index 25;}
1709
function KbdSetHWID(HWIDP:PKbdHWID;KbdHandle:word):word; cdecl;
1710
external 'EMXWRAP' index 225;
1711
{external 'KBDCALLS' index 25;}
1713
function KbdXlate(var TransData:TKbdTrans;KbdHandle:word):word; cdecl;
1714
external 'EMXWRAP' index 214;
1715
{external 'KBDCALLS' index 14;}
1717
function KbdSetCustXt(var XLateTbl:TXLateTbl;KbdHandle:word):word; cdecl;
1718
external 'EMXWRAP' index 201;
1719
{external 'KBDCALLS' index 1;}
1721
function KbdSetCustXt(var CodePage:word;KbdHandle:word):word; cdecl;
1722
external 'EMXWRAP' index 201;
1723
{external 'KBDCALLS' index 1;}
1725
function KbdSetCustXt(var XLateTblP:pointer;KbdHandle:word):word; cdecl;
1726
external 'EMXWRAP' index 201;
1727
{external 'KBDCALLS' index 1;}