kbdcalls.pas 83 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732
  1. {Set tabsize to 4.}
  2. {****************************************************************************
  3. KBDCALLS interface unit
  4. Free Pascal Runtime Library for OS/2
  5. Copyright (c) 1999-2000 by Florian Kl„mpfl
  6. Copyright (c) 1999-2000 by Daniel Mantione
  7. Copyright (c) 1999-2000 by Tomas Hajny
  8. The Free Pascal runtime library is distributed under the Library GNU Public
  9. License v2. So is this unit. The Library GNU Public License requires you to
  10. distribute the source code of this unit with any product that uses it.
  11. Because the EMX library isn't under the LGPL, we grant you an exception to
  12. this, and that is, when you compile a program with the Free Pascal Compiler,
  13. you do not need to ship source code with that program, AS LONG AS YOU ARE
  14. USING UNMODIFIED CODE! If you modify this code, you MUST change the next
  15. line:
  16. <This is an official, unmodified Free Pascal source code file.>
  17. Send us your modified files, we can work together if you want!
  18. Free Pascal is distributed in the hope that it will be useful,
  19. but WITHOUT ANY WARRANTY; without even the implied warranty of
  20. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  21. Library GNU General Public License for more details.
  22. You should have received a copy of the Library GNU General Public License
  23. along with Free Pascal; see the file COPYING.LIB. If not, write to
  24. the Free Software Foundation, 51 Franklin Street, Fifth Floor,
  25. Boston, MA 02110-1301, USA.
  26. ****************************************************************************}
  27. {$IFNDEF FPC_DOTTEDUNITS}
  28. unit KbdCalls;
  29. {$ENDIF FPC_DOTTEDUNITS}
  30. { Interface library to KBDCALLS.DLL (through EMXWRAP.DLL)
  31. Variant records and aliases for some record types created to maintain highest
  32. possible level of compatibility with other existing OS/2 compilers.
  33. Changelog:
  34. People:
  35. TH - Tomas Hajny ([email protected] on Internet)
  36. Date: Description of change: Changed by:
  37. - First released version 1.0 TH
  38. Coding style:
  39. I have tried to use the same coding style as Daniel Mantione in unit
  40. DOSCALLS, although I can't say I would write it the same way otherwise
  41. (I would write much more spaces myself, at least). Try to use it as well,
  42. please. Original note by Daniel Mantione follows:
  43. It may be well possible that coding style feels a bit strange to you.
  44. Nevertheless I friendly ask you to try to make your changes not look all
  45. to different. To make life easier, set your IDE to use tab characters,
  46. turn optimal fill, autoindent and backspace unindents on and set a
  47. tabsize of 4.}
  48. {***************************************************************************}
  49. interface
  50. {***************************************************************************}
  51. {$IFDEF FPC}
  52. {$PACKRECORDS 1}
  53. {$ENDIF FPC}
  54. const
  55. {return codes / error constants (those marked with * shouldn't occur under
  56. normal conditions)}
  57. No_Error = 0;
  58. Error_Invalid_Parameter = 87;
  59. Error_Sem_TimeOut =121;
  60. Error_Kbd_Parameter =373;
  61. Error_Kbd_No_Device =374; {*}
  62. Error_Kbd_Invalid_IOWait =375; {*}
  63. Error_Kbd_Invalid_Length =376;
  64. Error_Kbd_Invalid_Echo_Mask =377;
  65. Error_Kbd_Invalid_Input_Mask =378;
  66. Error_Kbd_Smg_Only =407; {*}
  67. Error_Kbd_Invalid_ASCIIZ =408;
  68. Error_Kbd_Invalid_Mask =409;
  69. Error_Kbd_Register =410;
  70. Error_Kbd_Deregister =411;
  71. Error_Kbd_Invalid_Handle =439;
  72. Error_Kbd_No_more_Handle =440;
  73. Error_Kbd_Cannot_Create_KCB =441;
  74. Error_Kbd_Codepage_Load_Incompl =442; {*}
  75. Error_Kbd_Invalid_CodePage_ID =443; {*}
  76. Error_Kbd_No_CodePage_Support =444; {*}
  77. Error_Kbd_Focus_Required =445;
  78. Error_Kbd_Focus_Already_Active =446; {*}
  79. Error_Kbd_Keyboard_Busy =447;
  80. Error_Kbd_Invalid_CodePage =448;
  81. Error_Kbd_Unable_To_Focus =449; {*}
  82. Error_Kbd_Detached =464;
  83. Error_Kbd_No_Console =500; {*}
  84. Error_Kbd_Extended_SG =504;
  85. {FnMask}
  86. kr_KbdCharIn =$00000001;
  87. kr_KbdPeek =$00000002;
  88. kr_KbdFlushBuffer =$00000004;
  89. kr_KbdGetStatus =$00000008;
  90. kr_KbdSetStatus =$00000010;
  91. kr_KbdStringIn =$00000020;
  92. kr_KbdOpen =$00000040;
  93. kr_KbdClose =$00000080;
  94. kr_KbdGetFocus =$00000100;
  95. kr_KbdFreeFocus =$00000200;
  96. kr_KbdGetCP =$00000400;
  97. kr_KbdSetCP =$00000800;
  98. kr_KbdXLate =$00001000;
  99. kr_KbdSetCustXT =$00002000;
  100. {WaitFlag}
  101. IO_Wait =0;
  102. {KbdCharIn: wait for a character if one is not available}
  103. {KbdGetFocus: wait for the focus}
  104. {KbdStringIn: in binary input mode, wait until CharBuf is full, in }
  105. { ASCII input mode wait until a carriage return is pressed}
  106. IO_NoWait =1;
  107. {KbdCharIn: immediate return if no character is available}
  108. {KbdGetFocus: do not wait for the focus}
  109. {KbdStringIn: send an immediate return if no characters are available,}
  110. { if characters available, send them (up to the maximum }
  111. { length); not supported in ASCII input mode }
  112. {TKbdInfo.fsMask}
  113. Keyboard_Echo_On =$0001; {echo is on}
  114. Keyboard_Echo_Off =$0002; {echo is off}
  115. Keyboard_Binary_Mode =$0004; {binary mode is on}
  116. Keyboard_ASCII_Mode =$0008; {ASCII mode is on}
  117. Keyboard_Modify_State =$0010; {shift state is modified}
  118. Keyboard_Modify_Interim =$0020; {interim character flags are modified}
  119. Keyboard_Modify_TurnAround =$0040; {turn-around character is modified}
  120. Keyboard_2B_TurnAround =$0080; {length of the turn-around character }
  121. {(meaningful only if }
  122. {Keyboard_Modify_TurnAround bit is on)}
  123. Keyboard_Shift_Report =$0100; {shift return is on}
  124. {TKbdInfo.fsState/TKbdKeyInfo.fsState/TKbdTrans.fsState}
  125. KbdStF_RightShift =$0001;
  126. KbdStF_LeftShift =$0002;
  127. KbdStF_Control =$0004;
  128. KbdStF_Alt =$0008;
  129. KbdStF_ScrollLock_On =$0010;
  130. KbdStF_Numlock_On =$0020;
  131. KbdStF_Capslock_On =$0040;
  132. KbdStF_Insert_On =$0080;
  133. KbdStF_LeftControl =$0100;
  134. KbdStF_LeftAlt =$0200;
  135. KbdStF_RightControl =$0400;
  136. KbdStF_RightAlt =$0800;
  137. KbdStF_ScrollLock =$1000;
  138. KbdStF_NumLock =$2000;
  139. KbdStF_CapsLock =$4000;
  140. KbdStF_SysReq =$8000;
  141. {TKbdTrans.fbStatus}
  142. KbdTrF_Shift_Key_In =$01; {shift status returned}
  143. {without character }
  144. KbdTrF_Extended_Key_In =$02; {extended key code }
  145. {from the keyboard,}
  146. {not a character }
  147. KbdTrF_Conversion_Request =$20; {immediate conversion}
  148. {requested }
  149. KbdTrF_Final_Char_In =$40; {either $40 or $80 or both}
  150. KbdTrF_Interim_Char_In =$80; {must be present }
  151. {TKbdHWID.idKbd}
  152. Keyboard_Undetermined =$0000; {undetermined keyboard type}
  153. Keyboard_AT_Compatible =$0001; {PC-AT Standard Keyboard}
  154. Keyboard_Enhanced_101 =$AB41; {101 Key Enhanced Keyboard}
  155. Keyboard_Enhanced_102 =$AB41; {102 Key Enhanced Keyboard}
  156. Keyboard_Enhanced_88_89 =$AB54; {88 and 89 Key Enhanced Keyboards}
  157. Keyboard_Enhanced_122 =$AB85; {122 Key Enhanced Keyboard}
  158. Keyboard_AT_Compatable=Keyboard_AT_Compatible;
  159. Keyboard_SpaceSaver=Keyboard_Enhanced_88_89;
  160. type
  161. {TKbdKeyInfo - record type for character data for KbdCharIn and KbdPeek}
  162. (* #pragma pack(2) ??? *)
  163. TKbdKeyInfo=record
  164. chChar:AnsiChar; {ASCII character code; the scan code received}
  165. {from the keyboard is translated to the ASCII}
  166. {character code }
  167. case boolean of
  168. false:(
  169. chScan:byte; {scan Code received from the keyboard}
  170. fbStatus:byte; {state of the keystroke event, see KbdTrF_* constants}
  171. bNlsShift:byte; {NLS shift status (always 0?)}
  172. fsState:word; {shift key status, see KbdStF_* constants}
  173. Time:cardinal); {time stamp indicating when a key was pressed,}
  174. {specified in milliseconds from the time }
  175. {the system was started }
  176. true:(
  177. chScan2:AnsiChar; (* should be chScan, fbStatus and bNlsShift, *)
  178. fbStatus2:byte; (* but this construct is unsupported currently *)
  179. bNlsShift2:AnsiChar);
  180. end;
  181. PKbdKeyInfo=^TKbdKeyInfo;
  182. KbdKeyInfo=TKbdKeyInfo; {for better compatibility with other compilers}
  183. {record type for KbdStringIn}
  184. TStringInBuf=record
  185. cb:word; {length of the input buffer, maximum length is 255}
  186. cchIn:word; {number of bytes actually read into the buffer}
  187. end;
  188. PStringInBuf=^TStringInBuf;
  189. StringInBuf=TStringInBuf;
  190. {TKbdInfo record type, for KbdSet/GetStatus}
  191. TKbdInfo=record
  192. cb, {total length in bytes, 10 is the only valid value }
  193. fsMask, {see TKbdInfo.fsMask constants, higher bits reserved}
  194. {and set to 0 }
  195. chTurnAround, {definition of the turn-around character, in ASCII }
  196. {and extended-ASCII format, the turn-around character}
  197. {is defined as the carriage return, in ASCII format }
  198. {only, the turn-around character is defined in the }
  199. {low-order byte; usually $000D }
  200. fsInterim, {interim character flags: bits 0-4 and 6 - reserved }
  201. { and set to 0,}
  202. { bit 5 - application}
  203. { requested }
  204. { immediate }
  205. { conversion }
  206. { bit 7 - interim }
  207. { character }
  208. { flag is on }
  209. { bits 8-15 - NLS shift }
  210. { state }
  211. fsState:word; {shift state, see TKbdInfo.fsState constants}
  212. end;
  213. PKbdInfo=^TKbdInfo;
  214. KbdInfo=TKbdInfo;
  215. {record type for KbdGetHWID}
  216. TKbdHWID=record
  217. cb, {length in bytes, on input length of the TKbdHWID}
  218. {record (at least 2), on output the actual number}
  219. {of bytes returned }
  220. idKbd, {keyboard type: $0000 = undetermined keyboard type}
  221. { $0001 = PC-AT Standard Keyboard }
  222. { $AB41 = 101 Key Enhanced Keyboard }
  223. { $AB41 = 102 Key Enhanced Keyboard }
  224. { $AB54 = 88 and 89 Key Enhanced }
  225. { Keyboards }
  226. { $AB85 = 122 Key Enhanced Keyboard }
  227. {- see Keyboard_* constants }
  228. usReserved1, {reserved, returned set to zero (secondary ID?)}
  229. usReserved2:word; {reserved, returned set to zero}
  230. end;
  231. PKbdHWID=^TKbdHWID;
  232. KbdHWID=TKbdHWID;
  233. {record type for KbdXlate}
  234. (* #pragma pack(2) ???*)
  235. TKbdTrans=record
  236. case boolean of
  237. false:(
  238. CharData:TKbdKeyInfo);
  239. true:(
  240. chChar:AnsiChar; {ASCII character code; the scan code received}
  241. {from the keyboard is translated to the ASCII}
  242. {character code }
  243. case boolean of
  244. false:(
  245. chScan, {scan Code received from the keyboard}
  246. fbStatus, {state of the keystroke event,}
  247. {see KbdTrF_* constants }
  248. bNlsShift:byte; {NLS shift status (always 0?)}
  249. fsState:word; {shift key status, see KbdStF_* constants}
  250. Time:cardinal; {time stamp indicating when a key was pressed,}
  251. {specified in milliseconds from the time }
  252. {the system was started }
  253. fsDD:word; {device driver returned flag, }
  254. {see KbdDDFlagWord notes below}
  255. fsXlate:word; {translation flag: 0 - translation incomplete,}
  256. { 1 - translation complete }
  257. fsShift:word; {identifies the state of translation across }
  258. {successive calls, initially the value should }
  259. {be zero; it may take several calls to this }
  260. {function to complete a character, the value }
  261. {should not be changed unless a new translation}
  262. {is required (that is, reset value to zero) }
  263. sZero:word); {reserved, set to 0}
  264. true:(
  265. chScan2, (* should be chScan, fbStatus and bNlsShift, *)
  266. fbStatus2, (* but this construct is unsupported currently *)
  267. bNlsShift2:AnsiChar));
  268. end;
  269. PKbdTrans=^TKbdTrans;
  270. KbdTrans=TKbdTrans;
  271. {KbdDDFlagWord notes:
  272. bits 15-14 Available. These bits are available for communication between
  273. monitors; they are not used by the physical device driver. The
  274. monitor applications coordinate the use of these flags.
  275. Bits 13-10 Reserved, set to zero. Monitors must pass these flags as is.
  276. They must set these flags to 0 in packets they create.
  277. Bit 9 Accented. This key is translated using the previous key passed,
  278. which is an accent key. Where an accent key is pressed, and the
  279. following key does not use the accent, a packet containing the
  280. accent character itself is first passed with this bit set. The
  281. scan code field of MonFlagWord (see above) would be 0,
  282. indicating a non-key generated record. A valid packet
  283. containing that following keystroke is then passed without this
  284. bit set.
  285. Bit 8 Multimake. The translation process sees this scan code as
  286. a typematic repeat of a toggle key or a shift key. Because
  287. toggle and shift keys only change state on the first make after
  288. each key-break, no state information is changed. For example,
  289. the NumLock toggle bit in the shift status word is not changed,
  290. even though this can be the NumLock key. If this key is a valid
  291. character, it does not go into the Keyboard Input Buffer (KIB)
  292. once this bit is set.
  293. Bit 7 Secondary. The scan code prior to the one in this packet was
  294. the Secondary Key Prefix (see below).
  295. Bit 6 Key break. This record is generated by the release (the break)
  296. of the key involved.
  297. Bits 5-0 Key type. This numeric field flags the physical device driver
  298. and reports that this is a key that requires action. The number
  299. in this field is filled in during the translation of the scan
  300. code. The value allows the driver to act on keystrokes without
  301. regard for what scan codes the keyboard uses or character codes
  302. that the current translation process may be using. The
  303. following values are currently defined:
  304. - Value for keys that are always placed in the KIB.
  305. Zero = no special action, always place in KIB.
  306. - Values acted on prior to passing packet to monitors.
  307. Except for the final keystroke of the DUMP key sequences,
  308. all of these values are passed on to the monitors. They
  309. are not placed in the KIB. The XlatedChar and XlatedScan
  310. fields are undefined for these values:
  311. 01h ACK. This scan code is a keyboard acknowledge.
  312. Personal Computer IBM* AT* attached keyboards
  313. set this value on an FAh scan code.
  314. 02h Secondary key prefix. This scan code is a prefix
  315. generated by the Enhanced Keyboard. It indicates
  316. that the next scan code coming is one of the
  317. secondary keys that exists on that keyboard.
  318. Usually set on an E0h scan code or an E1h scan
  319. code.
  320. 03h Kbd overrun. This scan code is an overrun
  321. indication from the keyboard. On an IBM Personal
  322. Computer AT-attached keyboard, this value would be
  323. set on an FFh scan code.
  324. 04h Resend. This scan code is a resend request from the
  325. keyboard. On an IBM Personal Computer AT-attached
  326. keyboard, this value would be set on an FEh scan
  327. code.
  328. 05h Reboot key. This scan code completes the multi-key
  329. restart sequence. On an IBM Personal Computer AT
  330. attached-keyboard, this value would be used when
  331. the Ctrl+Alt+Delete sequence is used.
  332. 06h Dump key. This scan code completes the multi-key
  333. Stand Alone Dump request sequence. On an IBM
  334. Personal Computer AT-attached keyboard, this value
  335. would be used on completion of the second
  336. consecutive press of Ctrl+Alt+NumLock or
  337. Ctrl+Alt+F10 without other keystrokes between the
  338. two presses.
  339. 07h-
  340. 0Ah See entries below.
  341. 0Bh Invalid accent combination. This scan code follows
  342. an accent scan code but the combination is not
  343. valid, and neither key is put in the KIB.
  344. (Note: This is set if the Canadian-French code
  345. pages are in use.)
  346. 0Ch System-defined hot keys.
  347. 0Dh
  348. -0Fh Reserved. Treated as undefined. See entry 3Fh.
  349. - Values acted on after passing packet to monitors. Except
  350. where noted, these values are placed in the KIB when the
  351. physical device driver is in binary mode; they are not
  352. placed in the KIB when the physical device driver is in
  353. ASCII mode. (Also listed are those that never get placed
  354. in the KIB.)
  355. 07h Shift key. This scan code translates as a shift key
  356. and affects the shift status fields of the CharData
  357. record, but does not generate a defined character.
  358. It is not placed in the KIB. The XlatedChar field
  359. is undefined. The scan code field is 0.
  360. 08h Pause key. This scan code is translated as the key
  361. sequence meaning pause. On an IBM Personal Computer
  362. AT-attached keyboard, this value is used when the
  363. Ctrl+NumLock sequence is used. The key itself is
  364. not placed in the KIB.
  365. 09h Pseudo-Pause key. This scan code is translated into
  366. the value that is treated as the Pause key when the
  367. physical device driver is in ASCII mode. On most
  368. keyboards, this would be when the Ctrl+S
  369. combination is used. The key itself is not placed
  370. in the KIB.
  371. 0Ah Wake-up key. This scan code follows a Pause key or
  372. Pseudo-Pause key, which causes the Pause state to
  373. end. The key itself is not placed in the KIB.
  374. 10h Accent key. This scan code is translated and used
  375. as a key to alter the translation of the next key
  376. to come in. The packet containing this value is
  377. passed when the accent key is pressed, but it is
  378. not put into the KIB, unless the Accented bit is
  379. ON. The next key determines this decision. If the
  380. next key is one that can be accented, then it is
  381. passed by itself with the Accented bit ON. If that
  382. next key cannot be accented by this accent, then
  383. two packets are passed. The first contains the
  384. character to print for the accent itself. It has
  385. the Accent key value and the Accented flag (which
  386. allows the packet to be put in the KIB). The second
  387. packet contains a regular translation of that
  388. following key.
  389. (Note: The two packets get passed for every
  390. language except Canadian-French - see entry 0Bh.)
  391. 11h Break key. This scan code is translated as the key
  392. sequence meaning break. On the IBM Personal
  393. Computer AT-attached keyboard, this value is used
  394. where the Ctrl+Break sequence is used.
  395. 12h Pseudo-Break key. This scan code is translated into
  396. the value that is treated as the Break key when the
  397. physical device driver is in ASCII mode. On most
  398. keyboards, this would be when the Ctrl+C
  399. combination is used. Notice that the event
  400. generated by this key is separate from the one
  401. generated by the Break key when in the binary mode.
  402. 13h Print Screen key. This scan code is translated as
  403. the key sequence meaning Print Screen. On an IBM
  404. Personal Computer AT-attached keyboard, this value
  405. is used where the Shift+PrtSc sequence is used.
  406. 14h Print Echo key. This scan code is translated as the
  407. key sequence meaning Print Echo. This value is used
  408. where the Ctrl+PrtSc sequence is used.
  409. 15h Pseudo-Print Echo key. This scan code is translated
  410. into the value that is treated as the Print Echo
  411. key when the physical device driver is in ASCII
  412. mode. On most keyboards, this would show as the
  413. Ctrl+P combination.
  414. 16h Print-Flush key. This scan code is translated into
  415. the key sequence Print-Flush. This value is used
  416. where the Ctrl+Alt+PrtSc sequence is used.
  417. 17h
  418. -2Fh Reserved, set to zero. Treated as undefined. See
  419. entry 3Fh.
  420. - Values for packets not generated by a keystroke:
  421. 30h
  422. -37h Reserved.
  423. 38h
  424. -3Eh Reserved. Treated as undefined. See entry 3Fh.
  425. - Value for keys the translation process does not recognize:
  426. 3Fh Undefined. This scan code, or its combination with
  427. the current shift state, is not recognized in the
  428. translation process.
  429. }
  430. {header of TXLateTbl}
  431. TXHeader=record
  432. XTableID:word; {code page number}
  433. XTableFlags1:word; {bits 0-2 determine which shift key or key }
  434. {combination affects Char3 of each TXLateKeyDef }
  435. {element, bits 7-10 determine which shift key or}
  436. {key combination causes Char5 to be used in each}
  437. {TXLateKeyDef element }
  438. {bit 0 - ShiftAlt (use Shift+Alt instead of }
  439. { Ctrl+Alt) }
  440. {bit 1 - AltGrafL (use left Alt key as }
  441. { Alt+Graphics) }
  442. {bit 2 - AltGrafR (use right Alt key as }
  443. { Alt+Graphics) }
  444. {bit 3 - ShiftLock (treat Caps Lock as }
  445. { ShiftLock) }
  446. {bit 4 - DefaultTable (default table for the }
  447. { language) }
  448. {bit 5 - ShiftToggle (1 = toggle ShiftLock, }
  449. { 0 = latch it) }
  450. {bit 6 - AccentPass (pass accent and non-accent }
  451. { key through; 1 = pass on accent keys}
  452. { and beep, 0 = beep only }
  453. {bit 7 - CapsShift (Caps+Shift uses Char5) }
  454. {bit 8 - MachDep (machine-dependent table) }
  455. {bits 9-10 reserved }
  456. {bits 11-15 reserved }
  457. XTableFlags2:word; {reserved, set to zero}
  458. KbdType:word; {keyboard type, 1 for extended (all common types)}
  459. KbdSubType:word; {reserved}
  460. XtableLen:word; {length of table}
  461. EntryCount:word; {number of KeyDef entries}
  462. EntryWidth:word; {width of KeyDef entries}
  463. Country:word; {language ID}
  464. TableTypeID:word; {the table type; 1st byte (type): 01X 00X }
  465. { 2nd byte (sub-type): 00X reserved}
  466. SubCountryID:cardinal;
  467. {sub-language identifier}
  468. Reserved:array[1..8] of word;
  469. end;
  470. PXHeader=^TXHeader;
  471. {element of TXLateTbl, not all entries are used (unused entries are zero)}
  472. TXLateKeyDef=record
  473. XlateOp:word; {translate operation specifier; }
  474. {bits 0- 6 - AccentFlags (see Notes 1 and 8)}
  475. {bits 7-15 - KeyType (see Note 2) }
  476. Char1:AnsiChar;
  477. Char2:AnsiChar;
  478. Char3:AnsiChar;
  479. Char4:AnsiChar;
  480. Char5:AnsiChar;
  481. end;
  482. PXLateKeyDef=^TXLateKeyDef;
  483. {record type for character definition in TAccentEntry}
  484. TKeyCode=record
  485. CharCode:AnsiChar;
  486. ScanCode:byte;
  487. end;
  488. {accent entry definitions for TAccentTable, see Notes 1 and 9}
  489. TAccentEntry=record
  490. NonAccent:TKeyCode; {char/scan code when}
  491. {not used as accent }
  492. CtlAccent:TKeyCode; {char/scan code when}
  493. {used with Ctrl key }
  494. AltAccent:TKeyCode; {char/scan code when}
  495. {used with Alt key }
  496. Maps:array[1..20] of TKeyCode; {from char-to-char for translation}
  497. end;
  498. PAccentEntry=^TAccentEntry;
  499. {table of accent key definitions for TXLateTbl}
  500. TAccentTable=array[1..7] of TAccentEntry;
  501. PAccentTable=^TAccentTable;
  502. {record type for SetCustXT, one element for each possible scan code
  503. (entries are in scan code order, based on the remapped scan codes
  504. returned by the keyboard controller)}
  505. TXLateTbl=record
  506. XHeader:TXHeader;
  507. KeyDefs:array [1..127] of TXLateKeyDef;
  508. AccentTbl:TAccentTable;
  509. end;
  510. PXLateTbl=^TXLateTbl;
  511. {Remarks for TXLateTbl record type:
  512. The request changes the device driver resident code page for the system
  513. and updates the zero entry of the Code Page Control Block.
  514. * Note 1
  515. The AccentFlags field of the KeyDef record has seven flags that are
  516. individually set if a corresponding entry in the accent table applies to this
  517. scan code. If the key pressed immediately before the current one was an
  518. accent key and the bit for that accent is set in the AccentFlags field for
  519. the current key, the corresponding AccentTable entry is searched for the
  520. replacement character value to use. If no replacement is found and bit 6 of
  521. the XlateFlags1 field is set, the not-an-accent beep is sounded and the
  522. accent character and current character are passed as two separate
  523. characters. Also see Note 8.
  524. * Note 2
  525. The KeyType field of the KeyDef record currently has the following values
  526. defined. The remaining values up to 1Fh are undefined. The effect of each
  527. type of shift is defined below. Except where otherwise noted, when no
  528. shifts are active, Char1 is the translated character. (See Note 3.) Notice
  529. that any of the Alt, Alt+Char, Alt+Shift, or Alt+Gr keys (or all of them) can
  530. be present on a keyboard based on the AltGrafL and AltGrafR bits in the
  531. XTableFlags1 flag word in the table header.
  532. 01h AlphaKey. Alphabetical character key:
  533. Shift Uses Char2. If Caps Lock, uses Char1.
  534. Caps Lock Uses Char2. If Shift, uses Char1.
  535. Ctrl Set standard control code for this key's Char1 value.
  536. See Note 4.
  537. Alt Standard extended code. See Note 7.
  538. Alt+Char Uses Char3, if it is not 0.
  539. Alt+Shift Uses Char3, if it is not 0.
  540. Alt+Gr Uses Char3, if it is not 0.
  541. 02h SpecKey. Special nonalphabetic character key, no Caps Lock or Alt:
  542. Shift Uses Char2.
  543. Caps Lock No effect, only depends on Shift, or Ctrl.
  544. Ctrl See Note 4.
  545. Alt Marked undefined.
  546. Alt+Char Uses Char3, if it is not 0.
  547. Alt+Shift Uses Char3, if it is not 0.
  548. Alt+Gr Uses Char3, if it is not 0.
  549. 03h SpecKeyC. Special nonalphabetic character key with Caps Lock. See
  550. Note 15.
  551. Shift Uses Char2. If Caps Lock, uses Char1.
  552. Caps Lock Uses Char2. If Shift, uses Char1.
  553. Ctrl See Note 4.
  554. Alt Uses Char4, if not zero. See Note 7.
  555. Alt+Char Uses Char3, if it is not 0.
  556. Alt+Shift Uses Char3, if it is not 0.
  557. Alt+Gr Uses Char3, if it is not 0.
  558. 04h SpecKeyA. Special nonalphabetic character key with Alt (no Caps
  559. Lock):
  560. Shift Uses Char2.
  561. Caps Lock No effect; depends on Shift, Ctrl, or Alt only.
  562. Ctrl See Notes 5 and 9.
  563. Alt See Notes 7 and 10.
  564. Alt+Char Uses Char3, if it is not 0.
  565. Alt+Shift Uses Char3, if it is not 0.
  566. Alt+Gr Uses Char3, if it is not 0.
  567. 05h SpecKeyCA. Special nonalphabetic character key with Caps Lock and
  568. Alt:
  569. Shift Uses Char2. If Caps Lock, uses Char1.
  570. Caps Lock Uses Char2. If Shift, uses Char1.
  571. Ctrl See Note 4.
  572. Alt See Note 7.
  573. Alt+Char Uses Char3, if it is not 0.
  574. Alt+Shift Uses Char3, if it is not 0.
  575. Alt+Gr Uses Char3, if it is not 0.
  576. 06h FuncKey. Function keys. Char1 = n in Fn; Char2 ignored. Sets
  577. extended codes 58+Char1, if no shift; if F11 or F12, uses 139 and 140.
  578. Shift Sets extended codes 83+Char1. F11 and F12 use 141
  579. and 142, respectively.
  580. Caps Lock No effect on function keys.
  581. Ctrl Sets extended codes 93+Char1. F11 and F12 use 143
  582. and 144, respectively.
  583. Alt Sets extended codes 103+Char1. F11 and F12 use 145
  584. and 146, respectively.
  585. Alt+Char Uses Char3, if it is not 0.
  586. Alt+Shift Uses Char3, if it is not 0.
  587. Alt+Gr Uses Char3, if it is not 0.
  588. 07h PadKey. Keypad keys (see Note 5 for definition of Char1). Note that
  589. nonshifted use of these keys is fixed to the extended codes:
  590. Shift Uses Char2, unless Num Lock. See Note 5.
  591. Caps Lock No effect on pad keys, unless Num Lock. See Note 5.
  592. Ctrl Sets extended codes. See Note 5.
  593. Alt Used to build a character. See Note 5.
  594. Alt+Char Uses Char3, if it is not 0.
  595. Alt+Shift Uses Char3, if it is not 0.
  596. Alt+Gr Uses Char3, if it is not 0.
  597. 08h SpecCtlKey. Special action keys, when used with Ctrl pressed:
  598. Shift No effect on these keys.
  599. Caps Lock No effect on these keys.
  600. Ctrl Uses Char2.
  601. Alt See Note 7.
  602. Alt+Char Uses Char3, if it is not 0.
  603. Alt+Shift Uses Char3, if it is not 0.
  604. Alt+Gr Uses Char3, if it is not 0.
  605. 09h PrtSc. Print Screen key; sets Char1 normally (see Note 17):
  606. Shift Signal the Print Screen function.
  607. Caps Lock No effect on this key.
  608. Ctrl Sets extended code and signals the Print Echo function.
  609. Alt Marked undefined.
  610. Alt+Char Uses Char3, if it is not 0.
  611. Alt+Shift Uses Char3, if it is not 0.
  612. Alt+Gr Uses Char3, if it is not 0.
  613. 0Ah SysReq. System Request key; treated like a shift key. See Note 6.
  614. 0Bh AccentKey. Keys that affect the next key pressed (also known as
  615. dead keys). Char1 is an index into the AccentTbl field of the
  616. XlateTable, selecting the AccentEntry that corresponds to this key.
  617. Char2 and Char3 do the same for the shifted Accent character. See
  618. Note 15.
  619. Shift Uses Char2 to index to applicable AccentEntry.
  620. Caps Lock No effect on this key.
  621. Ctrl Uses CtlAccent character from AccentEntry. See Note 8.
  622. Alt Uses AltAccent character from AccentEntry. See Note 8.
  623. Alt+Char Uses Char3 to index to applicable AccentEntry.
  624. Alt+Shift Uses Char3 to index to applicable AccentEntry.
  625. Alt+Gr Uses Char3 to index to applicable AccentEntry.
  626. Note: Key types 0Ch - 13h set Char1 and Char2 to mask values as defined
  627. in Note 6.
  628. 0Ch ShiftKeys. Shift or Ctrl key, sets and clears flags. Char1 holds the
  629. bits in the lower byte of the shift status word to set when the
  630. key is down and clear when the key is released. Char2 does the
  631. same thing for the upper byte of the shift status word unless the
  632. secondary key prefix (hex E0) is seen immediately prior to this key,
  633. in which case Char3 is used in place of Char2.
  634. 0Dh ToggleKey. General toggle key (like Caps Lock). Char1 holds the
  635. bits in the lower byte of the shift status word to toggle on the
  636. first make of the key after it is pressed. Char2 holds the bits in
  637. the upper byte of the shift status word to set when the key is
  638. down and clear when the key is released unless the secondary key
  639. prefix (hex E0) is seen immediately prior to this key, in which case
  640. Char3 is used in place of Char2.
  641. 0Eh AltKey. Treated just like ShiftKeys above, but has its own key
  642. type, because when seen, the accumulator used for Alt+PadKey
  643. entry is zeroed to prepare such entry (see Note 5). Sometimes this
  644. key is treated as the AltC/S/G key (that is, either Alt+Char,
  645. Alt+Shift, or Alt+Gr) if one of the AltGraf bits is on in XTableFlags1.
  646. 0Fh Num Lock. Normally behaves like ToggleKey, but the physical
  647. keyboard device driver sets a pause screen indication when this
  648. key is used with the Ctrl key pressed. The pause is cleared on the
  649. following keystroke if that stroke is a character-generating key.
  650. 10h Caps Lock. This key is treated as a type 0Dh toggle key. It has a
  651. separate entry here so that it can be processed like a Shift Lock
  652. key when that flag is set in the XTableFlags1 word in the header.
  653. When treated as a Shift Lock, the Caps Lock flag in the shift
  654. status word is set on on any make of this key, and only cleared
  655. when the left or right shift key is pressed. Char2 and Char3 are
  656. processed the same as ToggleKey.
  657. 11h Scroll Lock. Normally behaves like ToggleKey but has a separate
  658. entry here. When used with Ctrl, it can be recognized as
  659. Ctrl+Break.
  660. 12h XShiftKey. Extended Shift Key (for Country support). See Note 9.
  661. 13h XToggleKey. Extended Toggle Key (for Country support). See Note 9.
  662. 14h SpecKeyCS. Special key 1 for country keyboard processing. See Note 15.
  663. Shift Uses Char2.
  664. Caps Lock Uses Char4.
  665. Ctrl See Note 4.
  666. Alt See Note 7.
  667. Alt+Char Uses Char3.
  668. Alt+Shift Uses Char3.
  669. Alt+Gr Uses Char3.
  670. Caps+Shift Uses Char5.
  671. 15h SpecKeyAS. Special key 2 for country keyboard processing. See Note 15.
  672. Shift Uses Char2.
  673. Caps Lock No effect on this key.
  674. Ctrl See Note 4.
  675. Alt Uses Char 4. See Note 14.
  676. Alt+Char Uses Char 3. See Note 14.
  677. Alt+Shift Uses Char 3. See Note 14.
  678. Alt+Gr Uses Char 3. See Note 14.
  679. 1Ah Extended Extended key. This corresponds to the BIOS level support
  680. provided for INT 16h, Functions 20h, 21h, and 22h.
  681. Shift Uses Char2.
  682. Caps Lock No effect on this key.
  683. Ctrl Uses Char4.
  684. Alt Uses Char5.
  685. Alt+Char Uses Char 3, if not 0.
  686. Alt+Shift Uses Char 3, if not 0.
  687. Alt+Gr Uses Char 3, if not 0.
  688. 16h-
  689. 1FFh Reserved, except for 1Ah, the Extended Extended key (see above).
  690. * Note 3
  691. Undefined Character Code. Any key combination that does not fall into any
  692. of the defined categories. For example, the Ctrl key pressed along with a
  693. key that has no defined control mapping is mapped to the value 0, and the
  694. key type is set in the KeyPacket record indicating undefined translation.
  695. The KeyPacket record passed to the monitors, if installed, contain the
  696. original scan code in the ScanCode field and the 0 in the Character field for
  697. this key. Notice that no character data records with an undefined character
  698. code are placed in the keyboard input buffer.
  699. * Note 4
  700. Ctrl Key. The six possible situations that can occur when a key is pressed
  701. with only the Ctrl+shift key are shown below:
  702. - The key pressed is an AlphaKey character. In this case, the Ctrl plus
  703. Char1 combination defines one of the standard defined control codes
  704. (all numbers are decimal):
  705. Ctrl- Mapping Code Name Ctrl- Mapping Code Name
  706. ----- ------- --------- ----- ------- ---------
  707. a 1 SOH n 14 SO
  708. b 2 STX o 15 SI
  709. c 3 ETX p 16 DLE
  710. d 4 EOT q 17 DC1
  711. e 5 ENQ r 18 DC2
  712. f 6 ACK s 19 DC3
  713. g 7 BEL t 20 DC4
  714. h 8 BS u 21 NAK
  715. i 9 HT v 22 SYN
  716. j 10 LF w 23 ETB
  717. k 11 VT x 24 CAN
  718. l 12 FF y 25 EM
  719. m 13 CR z 26 SUB
  720. Notice that any key defined as AlphaKey uses the Char1 code value
  721. minus 96 (ASCII code for a) plus 1 to set the mapping shown above.
  722. Any scan code defined as AlphaKey must assign to Char1 one of the
  723. allowed lower case letters.
  724. - The key pressed is a nonalpha character, such as [, but is not an action
  725. key, such as Enter, Backspace, or an arrow key. This is a
  726. SpecKey[C][A] in the list of key types in the previous example. In this
  727. case, with one exception, the mapping is based on the scan code of the
  728. key. Though the key can be relabeled, the Ctrl+Char combination is
  729. always mapped based on the scan code of the key using the following
  730. table (all numbers are decimal):
  731. }(*
  732. Scan US Kbd Mapped Name of
  733. Code Legend Value New Code
  734. ---- ------ ------ --------
  735. 3 2 @ 0 Null
  736. 7 6 ^ 30 RS
  737. 12 - _ 31 US (see Note below)
  738. 26 [ { 27 Esc
  739. 27 ] } 29 GS
  740. 43 \ | 28 FS
  741. *){
  742. Note: The mapping for the hyphen character (-) is the one exception.
  743. The scan code for it is ignored; only the ASCII code for hyphen
  744. (decimal 45) is looked for in Char1 when mapping the Ctrl+-
  745. combination. This is because there can be more than one
  746. occurrence of the hyphen (-) key on the keyboard. The Ctrl+-
  747. (PadKey minus) combination produces character/scan code values
  748. of 00/8Eh, respectively.
  749. - The key pressed is an action key such as Enter, Backspace, or an arrow
  750. key. These keys generate special values when used in conjunction with
  751. the Ctrl key. Those actions are defined in other notes where they
  752. apply. Two particular keys in this category are:
  753. Ctrl+Enter = LF(010)
  754. Ctrl+Backspace = Del(127)
  755. - The key pressed is a function key, F1 - F12. See the FuncKey
  756. description in Note 2.
  757. - The key pressed is an accent key. See Note 8.
  758. - The key is not defined in conjunction with Ctrl. In this case, the key
  759. is treated as undefined, as described in Note 3.
  760. * Note 5
  761. PadKey. The pad keys have several uses that depend on various shift
  762. states. Some of them are based on their position on the keyboard. Because
  763. keyboard layouts change, the hard-coded assumed positions of the keypad
  764. keys, with the offset value that must be coded into Char1, are defined
  765. below. Any remapping must use the Char1 values shown below for the keys
  766. that correspond to the pad keys given by the Legend or Char2 values:
  767. US Kbd Scan Char1 Char2
  768. Legend Code Required US Kbd With Ctrl
  769. ------- ---- --------- ------- -----------
  770. Home 7 71 Decimal 0 ASCII 7 Decimal 119
  771. Up 8 72 " 1 " 8 " 141
  772. PgUp 9 73 " 2 " 9 " 132
  773. - 74 " 3 " - " 142
  774. Left 4 75 " 4 " 4 " 115
  775. 5 76 " 5 " 5 " 143
  776. Right 6 77 " 6 " 6 " 116
  777. + 78 " 7 " + " 144
  778. End 1 79 " 8 " 1 " 117
  779. Down 2 80 " 9 " 2 " 145
  780. PgDn 3 81 " 10 " 3 " 118
  781. Ins 0 82 " 11 " 0 " 146
  782. Del . 83 " 12 " . " 147
  783. Notice that when Num Lock is off, or if Shift is active and Num Lock on, the
  784. code returned is the extended code. The code returned corresponds to the
  785. Legends above (Home, PgUp, and so forth). When Num Lock is on, or if
  786. Shift is active and Num Lock is off, the code returned is Char2. Notice that
  787. the + and - keys also return Char2 when the shift key is down.
  788. When the Alt key is used with the PadKeys, the absolute value of the
  789. pressed key (looked up using the required Char1 value) is added to the
  790. accumulated value of any of the previous numeric keys pressed, without
  791. releasing the Alt key. Before adding the new number to the accumulated
  792. value, that accumulation is multiplied by ten, with overflow beyond 255
  793. ignored. When Alt is released, the accumulation becomes a Character code
  794. and is passed along with a scan code of zero. Notice that if any key other
  795. than the 10 numeric keys is pressed, the accumulated value is reset to zero.
  796. When the keypad *, -, or + keys are pressed while the Alt key is down, the
  797. extended characters 55, 74, and 78 (decimal) are returned, respectively.
  798. When AltGraphics is used with the PadKeys, the Char3 value is returned if it
  799. is nonzero, and if an AltGraf bit is set in XTableFlags1; otherwise, it is
  800. treated the same as the Alt key.
  801. On the Enhanced keyboard, the secondary keypad keys return, as an
  802. extended character, the scan code of the key plus 80 (decimal) when
  803. pressed in conjunction with the Alt key. The secondary / key returns an
  804. extended character of 164, when pressed in conjunction with the Alt key.
  805. * Note 6
  806. State Key. Each state key entry has Char1, Char2, and Char3 defined as
  807. follows:
  808. - Char1. A mask to set the appropriate bit in the low byte of the
  809. keyboard Shift Flags when the state key is pressed. When the state
  810. key is a toggle key, the set bit is toggled each additional time the key
  811. is pressed. When the state key is not a toggle key, the set bit is
  812. cleared when the key is released.
  813. - Char2. A mask to set the appropriate bit in the high byte of the
  814. Keyboard Shift Flags when the key is pressed.
  815. - Char3. Used in place of Char2 when the secondary key prefix is seen
  816. immediately prior to this key.
  817. The masks are shown below (numbers are in hex):
  818. Key Char1 Char2 Char3
  819. ----------- ----- ----- -----
  820. Right Shift 01 00 00
  821. Left Shift 02 00 00
  822. Ctrl Shift 04 01 04
  823. Alt Shift 08 02 08
  824. Scroll Lock 10 10 10
  825. Num Lock 20 20 20
  826. Caps Lock 40 40 40
  827. SysReq 00 80 80
  828. Notice that the INS key is not treated as a state key, but as a pad key.
  829. Also, SysReq is included here because it is treated as a shift key.
  830. * Note 7
  831. Alt Character. Most of the keys defined in a category that allows the Alt
  832. key (AlphaKey, SpecKeyA, SpecKeyCA) return a value called an extended
  833. character. This value is a character code of 00H or E0H, with a second byte
  834. (using the ScanCode field of the CharData record) defining the extended
  835. code. In most cases, this value is the scan code of the key. Since the
  836. legend on these keys can be remapped on a foreign language keyboard, the
  837. Alt-based extended code is hard to define in a general sense. The following
  838. rules are used:
  839. - AlphaKey. The extended code is derived from Char1 (the lower-case
  840. character) as it was originally mapped on the PC keyboard. The
  841. original scan code value is the extended code that a character returns.
  842. These keys can be moved and will still return their original Alt
  843. extended codes.
  844. - SpecKeyA and SpecKeyCA. This category is used for all keys that are
  845. not an alphabetic character or an action code (like Enter or Backspace,
  846. the only exception being the Tab key, which is treated as a character).
  847. On foreign keyboards, these keys can be moved around and can have
  848. new values assigned to them, such as special punctuation symbols.
  849. Therefore, the Alt mappings must be based on the real scan code as
  850. any keys defined by the SpecKey_ classification will have only an Alt
  851. mapping, if it is in one of the positions defined below. In that case,
  852. the Alt extended code is as shown:
  853. }(*
  854. Scan US Kbd Alt Scan US Kbd Alt
  855. Code Legend Value Code Legend Value
  856. ---- ------ ----- ---- ------ -----
  857. 2 1 ! 120 15 Tab 165
  858. 3 2 @ 121 26 [ { 26
  859. 4 3 # 122 27 ] } 27
  860. 5 4 $ 123 28 Enter 28
  861. 6 5 % 124 39 ; : 39
  862. 7 6 ^ 125 40 ' " 40
  863. 8 7 & 126 41 ' ~ 41
  864. 9 8 * 127 43 \ | 43 (equals W.T.C. key number 42)
  865. 10 9 ( 128 51 , < 51
  866. 11 0 ) 129 52 . > 52
  867. 12 - _ 130 53 / ? 53
  868. 13 = + 131
  869. *){
  870. The secondary / key returns an extended character of 164 when
  871. pressed while Alt is down.
  872. - FuncKey. Defined in Note 2.
  873. - SpecCtlKey. The Alt+ values of the Escape, Backspace, and Enter keys
  874. are extended characters equaling 1, 14, and 28 (decimal), respectively.
  875. When AltGraphics is used, the Char3 value is returned if it is nonzero and if
  876. an AltGraf bit is set in XTableFlags1. Otherwise, it is treated the same as
  877. the Alt key.
  878. * Note 8
  879. Accent Key. When an accent key is pressed with Ctrl or Alt, it is treated as
  880. a regular key. The character it translates to is the one in the CtlAccent or
  881. AltAccent field of the AccentEntry pointed to by the Char5 value of the
  882. KeyDef. If the key being defined has no defined value with Ctrl or Alt, it
  883. should have zeros in the field of the undefined combination.
  884. When an accent key is pressed by itself (or with Right Shift, Left Shift, or
  885. AltGraphics), it is not translated immediately. The Char1 (or Char2, when
  886. Left or Right Shift or AltGraphics is used) index in the KeyDef record is
  887. used with the next key received to check if the next key has an accent
  888. mapping. If that next key has no mapping for this accent (that is, if it has
  889. no bit set in its AccentFlags), or if that next key is not found in this
  890. accent's AccentEntry, then the character value in the NonAccent field of the
  891. AccentEntry is used as the character to display. It is followed by the
  892. translation of that next key after the not-an-accent beep is sounded.
  893. Notice that if a key doesn't change when a Left or Right Shift key is
  894. pressed, it should use the same value for Char1 and Char2 so the accent
  895. applies in both the shifted and nonshifted cases. If the accent value is
  896. undefined when used with a shift key or AltGraphics, the value in Char2 or
  897. Char3 should be 0.
  898. Any accent key that doesn't have an Alt or Ctrl mapping should put zeros in
  899. the AltAccent and CtlAccent fields of its AccentEntry. If the value in the
  900. table is between 1 and 7, then the key is considered an accent key and
  901. further accent key processing is indicated. See Note 1 for more information.
  902. * Note 9
  903. Extended State Key. For special Country support, the keyboard device
  904. driver maintains another byte of shift status. Key types 12h and 13h are
  905. provided for manipulation of that byte. The other fields of the KeyDef are:
  906. - Char1. A mask in which bits that are on define the field being used for
  907. the Char2 value. Only bits in the NLS shift status byte that correspond
  908. to the bits in this byte are altered by the Char2 value.
  909. - Char2. For KeyType 12h (Extended Shift), the value to OR into the
  910. byte when the make code is seen. Also, the inverted value is ANDed
  911. when the break code is seen. For KeyType 13h (Extended Toggle), the
  912. value XORed into the byte on each make code seen (break code
  913. ignored).
  914. - Char3. Use in place of the Char2 when the secondary key prefix (hex
  915. E0) is seen immediately prior to this key.
  916. For example, Char1 or Char2 can define single shift status bits to
  917. set/clear/toggle. Char2 can be a set of coded bits, delineated by Char1, that
  918. are set to a numeric value when the key is pressed and cleared to zero
  919. when released (or on the next press, if toggled). The whole byte can be
  920. set to Char2 when Char1 has all bits on.
  921. * Note 10
  922. Space Key. The key treated as the space character should have a flag set
  923. in its AccentFlags field for each possible accent (that is, for each defined
  924. AccentEntry in the AccentTable). And each AccentEntry should have the
  925. Space character defined as one of its accented characters, with the
  926. translation having the same value as the accent character itself. The reason
  927. for this is that, by definition, an Accent Key followed by the space
  928. character maps to the accent character alone. If the table is not set up as
  929. just described, a not-an-accent beep is sounded whenever the accent key
  930. followed by a space is pressed.
  931. Notice that the space key is defined as a SpecKeyA (type 4) because its
  932. use, in conjunction with the Alt key, is allowed. In this case, and when
  933. used with the Ctrl key, it returns the ASCII space character. This works
  934. correctly, except in the case of the diaresis accent (double-dot) in code
  935. page 437. The space is treated as an invalid character and the beep result
  936. occurs, with the diaresis represented by double quotation marks. The
  937. characters displayed depend upon the language in effect when the invalid
  938. diaresis is encountered. For some languages, the character substituted is
  939. the double-quotation marks; for others, the character used is the F9h
  940. character.
  941. * Note 11
  942. KbdType identifies the hardware-specific keyboard used by this table. The
  943. values and allowable types are the same as those specified in IOCTL call
  944. KBD_GETKEYBDTYPE (1 means extended keyboard, which is used for all common
  945. keyboard types).
  946. * Note 12
  947. The DefaultTable flag in XtableFlags1 is used by the KEYB utility in loading
  948. code pages when changing from one language to another. It identifies the
  949. default code page to KEYB, should KEYB not find one or both CODEPAGE=
  950. defined code pages.
  951. * Note 13
  952. The Language IDs and Subcountry IDs used are as follows:
  953. ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÂÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÂÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿
  954. ³Keyboard Layout ³Keyboard Layout ³Country ³
  955. ³Country Code ³SubCountry Code ³ ³
  956. ÃÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ´
  957. ³ AR ³ 785 ³Arabic-speaking ³
  958. ÃÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ´
  959. ³ BE ³ 120 ³Belgium ³
  960. ÃÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ´
  961. ³ CF ³ 058 ³Canadian-French ³
  962. ÃÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ´
  963. ³ CS ³ 243 ³Czech Republic ³
  964. ÃÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ´
  965. ³ CS ³ 245 ³Czech Republic ³
  966. ÃÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ´
  967. ³ DK ³ 159 ³Denmark ³
  968. ÃÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ´
  969. ³ SU ³ 153 ³Finland ³
  970. ÃÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ´
  971. ³ FR ³ 120 ³France ³
  972. ÃÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ´
  973. ³ FR ³ 189 ³France ³
  974. ÃÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ´
  975. ³ GR ³ 129 ³Germany ³
  976. ÃÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ´
  977. ³ HE ³ 972 ³Hebrew-speaking ³
  978. ÃÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ´
  979. ³ HU ³ 208 ³Hungary ³
  980. ÃÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ´
  981. ³ IS ³ 197 ³Iceland ³
  982. ÃÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ´
  983. ³ IT ³ 141 ³Italy ³
  984. ÃÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ´
  985. ³ IT ³ 142 ³Italy ³
  986. ÃÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ´
  987. ³ LA ³ 171 ³Latin-American ³
  988. ³ ³ ³Spanish ³
  989. ÃÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ´
  990. ³ NL ³ 143 ³Netherlands ³
  991. ÃÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ´
  992. ³ NO ³ 155 ³Norway ³
  993. ÃÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ´
  994. ³ PL ³ 214 ³Poland ³
  995. ÃÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ´
  996. ³ PO ³ 163 ³Portugal ³
  997. ÃÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ´
  998. ³ SP ³ 172 ³Spain ³
  999. ÃÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ´
  1000. ³ SV ³ 153 ³Sweden ³
  1001. ÃÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ´
  1002. ³ SF ³ 150F ³Swiss-French ³
  1003. ÃÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ´
  1004. ³ SG ³ 150G ³Swiss-German ³
  1005. ÃÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ´
  1006. ³ TR ³ 179 ³Turkey ³
  1007. ÃÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ´
  1008. ³ UK ³ 166 ³United Kingdom ³
  1009. ÃÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ´
  1010. ³ UK ³ 168 ³United Kingdom ³
  1011. ÃÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ´
  1012. ³ US ³ 103 ³United States ³
  1013. ÃÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ´
  1014. ³ YU ³ 234 ³Former Yugoslavia ³
  1015. ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÁÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÁÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ
  1016. * Note 14
  1017. Keytype 15. When the Alt or Alt+Shift keys are pressed, both XlatedChar
  1018. and XlatedScan in the CharData record will have the same value.
  1019. * Note 15
  1020. If the Charx value is in the range of 1-7, then Charx identifies an accent
  1021. key. Otherwise, Charx is treated as a valid ASCII character. This does not
  1022. apply to Ctrl+Charx sequences.
  1023. Note 16
  1024. If Alt+Gr, Alt+Shift, or Alt+Ctrl are pressed, and Char3 is 0, the Alt key is
  1025. used to translate to a valid result.
  1026. Note 17
  1027. The * key on the keypad of the Enhanced keyboard, although producing the
  1028. same scan code/character as that of the IBM Personal Computer AT*
  1029. keyboard, is treated differently because a dedicated Print Screen key exists
  1030. on the Enhanced keyboard. The following scan codes/characters are
  1031. returned by the physical keyboard device driver for the Enhanced keyboard
  1032. * key on the keypad:
  1033. Unshifted 37H/2AH
  1034. Shifted 37H/2AH
  1035. Ctrl 96H/00
  1036. Alt 37H/00
  1037. * Note 18
  1038. Size. The code page described here has the following dimensions:
  1039. Xlate Header = 40
  1040. 127 KeyDefs @ 7 bytes = 889
  1041. 7 AccentEntries @ 46 bytes = 322
  1042. ----
  1043. 1251 bytes
  1044. If more than 6 AccentEntries are needed, then the following format is used:
  1045. In the first 6 AccentEntries, the length is set at 20, with unused elements
  1046. set to zero. For each AccentEntry of 7 and greater, up to 120 element pairs
  1047. may exist, and the length is dynamic.
  1048. For each AccentEntry of 7 and greater, the first byte in the record will
  1049. contain the LENGTH of the AccentEntry record. The LENGTH value is defined
  1050. as the total length in bytes of the AccentEntry record including the LENGTH
  1051. byte.
  1052. The record is defined as follows:
  1053. AccEnt <l,a,b,c,d,e,f,c1,s1,c2,s2..c120,s120>
  1054. where....
  1055. l is the total length in bytes of the AccEnt including itself.
  1056. a &b are the scan code &char to use when the key following this accent
  1057. is not affected by the accent so the accent itself must be used.
  1058. c &d are the scan code &char to use when Ctl+[accent] is pressed.
  1059. e &f do the same for Alt+[accent].
  1060. c1,s1 - c120,s120 are the char/scan code mapping for accented translation.
  1061. Adding more than 7 accents will make the standard 1251-byte table an
  1062. extended variable size.
  1063. }
  1064. {Register a keyboard subsystem within a session.}
  1065. {ModuleName - dynamic link module name, maximum length is 8 bytes, ProcName is
  1066. a dynamic link entry point name of a routine that receives control when any of
  1067. the registered functions are called. Maximum length is 32 bytes, FnMask - see
  1068. KR_* constants}
  1069. {Possible return codes:
  1070. 0 No_Error
  1071. 408 Error_Kbd_Invalid_ASCIIZ
  1072. 409 Error_Kbd_Invalid_Mask
  1073. 410 Error_Kbd_Register
  1074. 464 Error_Kbd_Detached
  1075. 504 Error_Kbd_Extended_SG}
  1076. {Remarks:
  1077. * There can be only one KbdRegister call outstanding for each session without
  1078. an intervening KbdDeRegister. KbdDeRegister must be issued by the same
  1079. process that issued the KbdRegister.}
  1080. function KbdRegister(ModuleName,ProcName:PAnsiChar;FnMask:cardinal):word; cdecl;
  1081. function KbdRegister(ModuleName,ProcName:string;FnMask:cardinal):word;
  1082. {Deregister a keyboard subsystem previously registered within a session - only
  1083. the process that issued the KbdRegister may issue KbdDeRegister.}
  1084. {Possible return codes:
  1085. 0 No_Error
  1086. 411 Error_Kbd_Deregister
  1087. 464 Error_Kbd_Detached
  1088. 504 Error_Kbd_Extended_SG}
  1089. function KbdDeRegister:word; cdecl;
  1090. {Return a character data record from the keyboard.}
  1091. {Key - see TKbdKeyInfo record type, WaitFlag - see IO_Wait and IO_NoWait
  1092. constants, KbdHandle is the default keyboard (0) or a logical keyboard.}
  1093. {Possible return codes are:
  1094. 0 No_Error
  1095. 375 Error_Kbd_Invalid_IOWait
  1096. 439 Error_Kbd_Invalid_Handle
  1097. 445 Error_Kbd_Focus_Required
  1098. 447 Error_Kbd_Keyboard_Busy
  1099. 464 Error_Kbd_Detached
  1100. 504 Error_Kbd_Extended_SG}
  1101. {Remarks:
  1102. * On an enhanced keyboard, the secondary enter key returns the normal
  1103. character 0Dh and a scan code of E0h.
  1104. * Double-byte character codes (DBCS) require two function calls to obtain the
  1105. entire code.
  1106. * If shift report is set with KbdSetStatus, the CharData record returned
  1107. reflects changed shift information only.
  1108. * Extended ASCII codes are identified with the status byte, bit 1 on and the
  1109. ASCII character code being either 00h or E0h. Both conditions must be
  1110. satisfied for the character to be an extended keystroke. For extended
  1111. ASCII codes, the scan code byte returned is the second code (extended
  1112. code). Usually the extended ASCII code is the scan code of the primary key
  1113. that was pressed.
  1114. * A thread in the foreground session that repeatedly polls the keyboard with
  1115. KbdCharIn (with no wait), can prevent all regular priority class threads
  1116. from executing. If polling must be used and a minimal amount of other
  1117. processing is being performed, the thread should periodically yield to the
  1118. CPU by issuing a DosSleep call for an interval of at least 5 milliseconds.}
  1119. function KbdCharIn(var Key:TKbdKeyInfo;WaitFlag,KbdHandle:word):word; cdecl;
  1120. {Return any available character data record from the keyboard
  1121. without removing it from the buffer.}
  1122. {Key - see TKbdKeyInfo record type, KbdHandle is the default keyboard (0)
  1123. or a logical keyboard.}
  1124. {Possible return codes are:
  1125. 0 No_Error
  1126. 439 Error_Kbd_Invalid_Handle
  1127. 445 Error_Kbd_Focus_Required
  1128. 447 Error_Kbd_Keyboard_Busy
  1129. 464 Error_Kbd_Detached
  1130. 504 Error_Kbd_Extended_SG}
  1131. {Remarks:
  1132. * On an enhanced keyboard, the secondary enter key returns the normal
  1133. character 0Dh and a scan code of E0h.
  1134. * Double-byte character codes (DBCS) require two function calls to obtain the
  1135. entire code.
  1136. * If shift report is set with KbdSetStatus the CharData record returned,
  1137. reflects changed shift information only.
  1138. * Extended ASCII codes are identified with the status byte, bit 1 on and the
  1139. ASCII character code being either 00h or E0h. Both conditions must be
  1140. satisfied for the character to be an extended keystroke. For extended
  1141. ASCII codes, the scan code byte returned is the second code (extended
  1142. code). Usually the extended ASCII code is the scan code of the primary key
  1143. that was pressed.
  1144. * A thread in the foreground session that repeatedly polls the keyboard with
  1145. KbdCharIn (with no wait), can prevent all regular priority class threads
  1146. from executing. If polling must be used and a minimal amount of other
  1147. processing is being performed, the thread should periodically yield the CPU
  1148. by issuing a DosSleep call for an interval of at least 5 milliseconds.}
  1149. function KbdPeek(var Key:TKbdKeyInfo;KbdHandle:word):word; cdecl;
  1150. {Read a character string (character codes only) from the keyboard.}
  1151. {CharBuf is a buffer for returned characters, LenInOut - see TStringInBuf
  1152. record type, WaitFlag - see IO_Wait and IO_NoWait constants, KbdHandle is the
  1153. default keyboard (0) or a logical keyboard.}
  1154. {Possible return codes are:
  1155. 0 No_Error
  1156. 375 Error_Kbd_Invalid_IOWait
  1157. 439 Error_Kbd_Invalid_Handle
  1158. 445 Error_Kbd_Focus_Required
  1159. 464 Error_Kbd_Detached
  1160. 504 Error_Kbd_Extended_SG}
  1161. {Remarks:
  1162. * The character strings may be optionally echoed on the display if echo mode
  1163. is set. When echo is on each character is echoed as it is read from the
  1164. keyboard. Echo mode and binary mode are mutually exclusive. Reference
  1165. KbdSetStatus and KbdGetStatus for more information.
  1166. * The default input mode is ASCII. In ASCII mode, 2-byte character codes only
  1167. return in complete form. An extended ASCII code is returned in a 2-byte
  1168. string. The first byte is 0Dh or E0h and the next byte is an extended code.
  1169. * In input mode (binary, ASCII), the following returns can be set and
  1170. retrieved with KbdSetStatus and KbdGetStatus:
  1171. Turnaround Character
  1172. Echo Mode
  1173. Interim Character Flag
  1174. Shift State
  1175. * The received input length is also used by the KbdStringIn line edit
  1176. functions for re-displaying and entering a caller specified string. On the
  1177. next KbdStringIn call the received input length indicates the length of the
  1178. input buffer that may be recalled by the user using the line editing keys.
  1179. A value of 0 inhibits the line editing function for the current KbdStringIn
  1180. request.
  1181. * KbdStringIn completes when the handle has access to the physical keyboard
  1182. (focus), or is equal to zero and no other handle has the focus.}
  1183. function KbdStringIn(var CharBuf;var LenInOut:TStringInBuf;WaitFlag:word;
  1184. KbdHandle:word):word; cdecl;
  1185. function KbdStringIn(CharBuf:PAnsiChar;LenInOutP:PStringInBuf;WaitFlag:word;
  1186. KbdHandle:word):word; cdecl;
  1187. {Clear the keystroke buffer.}
  1188. {KbdHandle is the default keyboard (0) or a logical keyboard.}
  1189. {Possible return codes are:
  1190. 0 No_Error
  1191. 439 Error_Kbd_Invalid_Handle
  1192. 445 Error_Kbd_Focus_Required
  1193. 447 Error_Kbd_Keyboard_Busy
  1194. 464 Error_Kbd_Detached
  1195. 504 Error_Kbd_Extended_SG}
  1196. {Remarks:
  1197. * KbdFlushBuffer completes when the handle has access to the physical
  1198. keyboard (focus), or is equal to zero and no other handle has the focus.}
  1199. function KbdFlushBuffer(KbdHandle:word):word; cdecl;
  1200. {Set the characteristics of the keyboard.}
  1201. {Status - see TKbdInfo record type, KbdHandle is the default keyboard (0) or
  1202. a logical keyboard.}
  1203. {Possible return codes are:
  1204. 0 No_Error
  1205. 376 Error_Kbd_Invalid_length
  1206. 377 Error_Kbd_Invalid_Echo_Mask
  1207. 378 Error_Kbd_Invalid_Input_Mask
  1208. 439 Error_Kbd_Invalid_Handle
  1209. 445 Error_Kbd_Focus_Required
  1210. 447 Error_Kbd_Keyboard_Busy
  1211. 464 Error_Kbd_Detached
  1212. 504 Error_Kbd_Extended_SG}
  1213. {Remarks:
  1214. * Shift return (bit 8 in sysstate) must be disabled in ASCII mode.
  1215. * KbdSetStatus is ignored for a Vio-windowed application.}
  1216. function KbdSetStatus(var Status:TKbdInfo;KbdHandle:word):word; cdecl;
  1217. {Get the current state of the keyboard.}
  1218. {Status - see TKbdInfo record type, KbdHandle is the default keyboard (0) or
  1219. a logical keyboard.}
  1220. {Possible return codes:
  1221. 0 No_Error
  1222. 376 Error_Kbd_Invalid_Length
  1223. 439 Error_Kbd_Invalid_Handle
  1224. 445 Error_Kbd_Focus_Required
  1225. 447 Error_Kbd_Keyboard_Busy
  1226. 464 Error_Kbd_Detached
  1227. 504 Error_Kbd_Extended_SG}
  1228. {Remarks:
  1229. * The initial state of the keyboard is established by the system at
  1230. application load time. Some default states may be modified by the
  1231. application through KbdSetStatus. KbdGetStatus returns only those keyboard
  1232. parameters initially set by KbdSetStatus. The returned parameters are:
  1233. Input Mode, Interim Character Flags, Shift State, Echo State, TurnAround
  1234. Character
  1235. * KbdGetStatus completes only when the handle has access to the physical
  1236. keyboard (focus) or the handle is 0 and no other handle has the focus.}
  1237. function KbdGetStatus(var Status:TKbdInfo;KbdHandle:word):word; cdecl;
  1238. {Set the code page used to translate key strokes received from the keyboard for
  1239. current process.}
  1240. {Reserved - reserved, must be set to 0, CodePage - code-page ID in the
  1241. application's data area, must be equivalent to one of the code-page IDs
  1242. specified on the CONFIG.SYS CODEPAGE= statement or 0, an error results
  1243. otherwise, KbdHandle is the default keyboard (0) or a logical keyboard.}
  1244. {Possible return codes:
  1245. 0 No_Error
  1246. 439 Error_Kbd_Invalid_Handle
  1247. 445 Error_Kbd_Focus_Required
  1248. 447 Error_Kbd_Keyboard_Busy
  1249. 448 Error_Kbd_Invalid_CodePage
  1250. 464 Error_Kbd_Detached
  1251. 504 Error_Kbd_Extended_SG}
  1252. {Remarks:
  1253. * Keyboard code page support is not available without the DEVINFO=KBD
  1254. statement in the CONFIG.SYS file.}
  1255. function KbdSetCp(Reserved,CodePage,KbdHandle:word):word; cdecl;
  1256. {Query the code page being used to translate scan codes to ASCII characters.}
  1257. {Reserved must be set to 0. The keyboard support returns the current code
  1258. page for a specified keyboard handle in CodePage, it is one of the code page
  1259. IDs specified in the CONFIG.SYS CODEPAGE= statement or 0000. KbdHandle is
  1260. the default keyboard (0) or a logical keyboard.}
  1261. {Possible return codes:
  1262. 0 No_Error
  1263. 373 Error_Kbd_Parameter
  1264. 439 Error_Kbd_Invalid_Handle
  1265. 445 Error_Kbd_Focus_Required
  1266. 447 Error_Kbd_Keyboard_Busy
  1267. 464 Error_Kbd_Detached
  1268. 504 Error_Kbd_Extended_SG}
  1269. {Remarks:
  1270. * CodePage is set to the currently active keyboard code page. A value of 0
  1271. indicates the code page translation table in use is the ROM code page
  1272. translation table provided by the hardware.}
  1273. function KbdGetCp(Reserved:cardinal;var CodePage:word;KbdHandle:word):word;
  1274. cdecl;
  1275. {Create a new logical keyboard.}
  1276. {Handle for the new logical keyboard returned in KbdHandle.}
  1277. {Possible return codes:
  1278. 0 No_Error
  1279. 440 Error_Kbd_No_More_Handle
  1280. 441 Error_Kbd_Cannot_Create_KCB
  1281. 464 Error_Kbd_Detached
  1282. 504 Error_Kbd_Extended_SG}
  1283. {Remarks:
  1284. * KbdOpen blocks while another thread has the keyboard focus (by way of
  1285. KbdGetFocus) until the thread with the focus issues KbdFreeFocus.
  1286. Therefore, to prevent KbdOpen from blocking, it is recommended that KbdOpen
  1287. be issued only while the current thread has the focus. For example:
  1288. KbdGetFocus wait until focus available on handle 0
  1289. KbdOpen get a logical keyboard handle
  1290. KbdFreeFocus give up the focus on handle 0}
  1291. function KbdOpen(var KbdHandle:word):word; cdecl;
  1292. {Close the existing logical keyboard identified by the keyboard handle}
  1293. {KbdHandle is the default keyboard (0) or a logical keyboard}
  1294. {Possible return codes:
  1295. 0 No_Error
  1296. 439 Error_Kbd_Invalid_Handle
  1297. 464 Error_Kbd_Detached
  1298. 504 Error_Kbd_Extended_SG}
  1299. {Remarks:
  1300. * KbdClose blocks while another thread has the keyboard focus (by way of
  1301. KbdGetFocus) until the thread with the focus issues KbdFreeFocus.
  1302. Therefore, to prevent KbdClose from blocking, it is recommended that
  1303. KbdClose be issued only while the current thread has the focus. For
  1304. example:
  1305. KbdGetFocus wait until focus available on handle 0
  1306. KbdClose close a logical keyboard handle
  1307. KbdFreeFocus give up the focus on handle 0}
  1308. function KbdClose(KbdHandle:word):word; cdecl;
  1309. {Bind the logical keyboard to the physical keyboard.}
  1310. {KbdHandle is the default keyboard (0) or a logical keyboard}
  1311. {Possible return codes:
  1312. 0 No_Error
  1313. 439 Error_Kbd_Invalid_Handle
  1314. 445 Error_Kbd_Focus_Required
  1315. 464 Error_Kbd_Detached
  1316. 504 Error_Kbd_Extended_SG}
  1317. function KbdGetFocus(WaitFlag,KbdHandle:word):word; cdecl;
  1318. {Free the logical-to-physical keyboard bond created by KbdGetFocus.}
  1319. {KbdHandle is the default keyboard (0) or a logical keyboard}
  1320. {Possible return codes:
  1321. 0 No_Error
  1322. 439 Error_Kbd_Invalid_Handle
  1323. 445 Error_Kbd_Focus_Required
  1324. 464 Error_Kbd_Detached
  1325. 504 Error_Kbd_Extended_SG}
  1326. {Remarks:
  1327. * KbdFreeFocus may be replaced by issuing KbdRegister. Unlike other keyboard
  1328. subsystem functions, the replaced KbdFreeFocus is called only if there is
  1329. an outstanding focus.}
  1330. function KbdFreeFocus(KbdHandle:word):word; cdecl;
  1331. {Synchronize access from a keyboard subsystem to the keyboard device driver.}
  1332. {WaitFlag - see IO_Wait and IO_NoWait constants (wait / don't wait for access
  1333. to the device driver.}
  1334. {Possible return codes:
  1335. 0 No_Error
  1336. 121 Error_Sem_TimeOut}
  1337. {Remarks:
  1338. * KbdSynch blocks all other threads within a session until return from the
  1339. subsystem to the router. To ensure proper synchronization, KbdSynch should
  1340. be issued by a keyboard subsystem if it intends to issue a DosDevIOCtl or
  1341. access dynamically shared data. KbdSynch does not protect globally shared
  1342. data from threads in other sessions.}
  1343. function KbdSynch (WaitFlag:word):word; cdecl;
  1344. {Raise the priority of the foreground keyboard's thread.}
  1345. {Possible return codes:
  1346. 0 No_Error
  1347. 447 Error_Kbd_Keyboard_Busy
  1348. 504 Error_Kbd_Extended_SG}
  1349. {Remarks:
  1350. * KbdSetFgnd marks the current process that owns the keyboard. Threads in
  1351. this process receive a priority boost. The previous foreground keyboard
  1352. threads lose their priority boost.
  1353. * This function should only be issued by a Keyboard Subsystem during
  1354. KbdCharIn or KbdStringIn processing.}
  1355. function KbdSetFgnd:word; cdecl;
  1356. {Return the attached keyboard's hardware-generated identification value.}
  1357. {HWID is a pointer to the caller's data area, see TKbdHWID, KbdHandle is the
  1358. default keyboard (0) or a logical keyboard.}
  1359. {Possible return codes:
  1360. 0 No_Error
  1361. 373 Error_Kbd_Parameter
  1362. 447 Error_Kbd_Keyboard_Busy
  1363. 464 Error_Kbd_Detached
  1364. 504 Error_Kbd_Extended_SG}
  1365. {Remarks:
  1366. * In past OS/2 releases, all keyboards could be supported by knowing the
  1367. hardware family information available with keyboard IOCTL 77h. However,
  1368. with the addition of the 122-key keyboard, recognition was not containable
  1369. by hardware family information alone. The 122-key keyboard has a number of
  1370. differences from other keyboards. Therefore, applications performing
  1371. keystroke specific functions may need to determine specifically which
  1372. keyboard is attached.
  1373. * This function is of particular usefulness for applications providing Custom
  1374. Translate Tables and mapping keyboard layouts.}
  1375. function KbdGetHWID(var HWID:TKbdHWID;KbdHandle:word):word; cdecl;
  1376. {Undocumented in official IBM documentation}
  1377. function KbdSetHWID(var HWID:TKbdHWID;KbdHandle:word):word; cdecl;
  1378. function KbdSetHWID(HWIDP:PKbdHWID;KbdHandle:word):word; cdecl;
  1379. {Translate scan codes with shift states into ASCII codes.}
  1380. {TransData - see TKbdTransData, KbdHandle is the default keyboard (0) or a
  1381. logical keyboard.}
  1382. {Possible return codes:
  1383. 0 No_Error
  1384. 439 Error_Kbd_Invalid_Handle
  1385. 445 Error_Kbd_Focus_Required
  1386. 447 Error_Kbd_Keyboard_Busy
  1387. 464 Error_Kbd_Detached
  1388. 504 Error_Kbd_Extended_SG}
  1389. {Remarks:
  1390. * It may take several calls to complete a translation because of accent key
  1391. combinations, or other complex operations.
  1392. * The fsShift and sZero are for use by the keyboard translation routines.
  1393. These fields are reserved and must only be accessed by the caller prior
  1394. to starting a translation sequence and then they must be set to zero.
  1395. The KbdXlate function is intended to be used for translating a particular
  1396. scan code for a given shift state. The KbdXlate function is not intended
  1397. to be a replacement for the OS/2 system keystroke translation function.}
  1398. function KbdXlate(var TransData:TKbdTrans;KbdHandle:word):word; cdecl;
  1399. {Install, on the specified handle, the translate table which this call points
  1400. to. This translate table affects only this handle.}
  1401. {XLateTbl is the translation table used to translate scan code to ASCII code
  1402. for a specified handle (the format of the translation table is documented in
  1403. the Set Code Page IOCTL 50h), KbdHandle is the default keyboard (0) or a
  1404. logical keyboard.}
  1405. {Possible return codes:
  1406. 0 No_Error
  1407. 377 Error_Kbd_Invalid_Echo_Mask
  1408. 378 Error_Kbd_Invalid_Input_Mask
  1409. 439 Error_Kbd_Invalid_Handle
  1410. 445 Error_Kbd_Focus_Required
  1411. 447 Error_Kbd_Keyboard_Busy
  1412. 464 Error_Kbd_Detached
  1413. 504 Error_Kbd_Extended_SG}
  1414. {Remarks:
  1415. * The translate table must be maintained in the caller's memory. No copy of
  1416. the translate table is made by KbdSetCustXt.
  1417. * KbdSetCp reverses the action of KbdSetCustXt and sets the handle equal to
  1418. one of the system translate tables. If memory is dynamically allocated by
  1419. the caller for the translate table and is freed before the KbdSetCp is
  1420. performed, KbdSetCp and future translations may fail.}
  1421. function KbdSetCustXt(var XLateTbl:TXLateTbl;KbdHandle:word):word; cdecl;
  1422. function KbdSetCustXt(var CodePage:word;KbdHandle:word):word; cdecl;
  1423. function KbdSetCustXt(var XLateTblP:pointer;KbdHandle:word):word; cdecl;
  1424. (* Following routines are not supported
  1425. (just have a look in some C header
  1426. file - you probably won't find it there either).
  1427. KbdInit (index 2)
  1428. KbdLoadInstance (index 6)
  1429. KbdSwitchFgnd (index 15)
  1430. KbdShellInit (index 16)
  1431. KbdFree (index 19)
  1432. *)
  1433. {***************************************************************************}
  1434. implementation
  1435. {***************************************************************************}
  1436. function KbdRegister(ModuleName,ProcName:PAnsiChar;FnMask:cardinal):word; cdecl;
  1437. external 'EMXWRAP' index 208;
  1438. {external 'KBDCALLS' index 8;}
  1439. function KbdRegister(ModuleName,ProcName:string;FnMask:cardinal):word;
  1440. begin
  1441. if byte(ModuleName[0])>8 then byte(ModuleName[0]):=8;
  1442. ModuleName[Succ(byte(ModuleName[0]))]:=#0;
  1443. if byte(ProcName[0])>32 then byte(ProcName[0]):=32;
  1444. ProcName[Succ(byte(ProcName[0]))]:=#0;
  1445. KbdRegister:=KbdRegister(@ModuleName[1],@ProcName[1],FnMask);
  1446. end;
  1447. function KbdDeRegister:word; cdecl;
  1448. external 'EMXWRAP' index 220;
  1449. {external 'KBDCALLS' index 20;}
  1450. function KbdCharIn(var Key:TKbdKeyInfo;WaitFlag,KbdHandle:word):word; cdecl;
  1451. external 'EMXWRAP' index 204;
  1452. {external 'KBDCALLS' index 4;}
  1453. function KbdPeek(var Key:TKbdKeyInfo;KbdHandle:word):word; cdecl;
  1454. external 'EMXWRAP' index 222;
  1455. {external 'KBDCALLS' index 22;}
  1456. function KbdStringIn(var CharBuf;var LenInOut:TStringInBuf;WaitFlag:word;
  1457. KbdHandle:word):word; cdecl;
  1458. external 'EMXWRAP' index 209;
  1459. {external 'KBDCALLS' index 9;}
  1460. function KbdStringIn(CharBuf:PAnsiChar;LenInOutP:PStringInBuf;WaitFlag:word;
  1461. KbdHandle:word):word; cdecl;
  1462. external 'EMXWRAP' index 209;
  1463. {external 'KBDCALLS' index 9;}
  1464. function KbdFlushBuffer(KbdHandle:word):word; cdecl;
  1465. external 'EMXWRAP' index 213;
  1466. {external 'KBDCALLS' index 13;}
  1467. function KbdSetStatus(var Status:TKbdInfo;KbdHandle:word):word; cdecl;
  1468. external 'EMXWRAP' index 211;
  1469. {external 'KBDCALLS' index 11;}
  1470. function KbdGetStatus(var Status:TKbdInfo;KbdHandle:word):word; cdecl;
  1471. external 'EMXWRAP' index 210;
  1472. {external 'KBDCALLS' index 10;}
  1473. function KbdSetCp(Reserved,CodePage,KbdHandle:word):word; cdecl;
  1474. external 'EMXWRAP' index 205;
  1475. {external 'KBDCALLS' index 5;}
  1476. function KbdGetCp(Reserved:cardinal;var CodePage:word;KbdHandle:word):word;
  1477. cdecl;
  1478. external 'EMXWRAP' index 203;
  1479. {external 'KBDCALLS' index 3;}
  1480. function KbdOpen(var KbdHandle:word):word; cdecl;
  1481. external 'EMXWRAP' index 223;
  1482. {external 'KBDCALLS' index 23;}
  1483. function KbdClose(KbdHandle:word):word; cdecl;
  1484. external 'EMXWRAP' index 217;
  1485. {external 'KBDCALLS' index 17;}
  1486. function KbdGetFocus(WaitFlag,KbdHandle:word):word; cdecl;
  1487. external 'EMXWRAP' index 212;
  1488. {external 'KBDCALLS' index 12;}
  1489. function KbdFreeFocus(KbdHandle:word):word; cdecl;
  1490. external 'EMXWRAP' index 218;
  1491. {external 'KBDCALLS' index 18;}
  1492. function KbdSynch (WaitFlag:word):word; cdecl;
  1493. external 'EMXWRAP' index 207;
  1494. {external 'KBDCALLS' index 7;}
  1495. function KbdSetFgnd:word; cdecl;
  1496. external 'EMXWRAP' index 221;
  1497. {external 'KBDCALLS' index 21;}
  1498. function KbdGetHWID(var HWID:TKbdHWID;KbdHandle:word):word; cdecl;
  1499. external 'EMXWRAP' index 224;
  1500. {external 'KBDCALLS' index 24;}
  1501. function KbdSetHWID(var HWID:TKbdHWID;KbdHandle:word):word; cdecl;
  1502. external 'EMXWRAP' index 225;
  1503. {external 'KBDCALLS' index 25;}
  1504. function KbdSetHWID(HWIDP:PKbdHWID;KbdHandle:word):word; cdecl;
  1505. external 'EMXWRAP' index 225;
  1506. {external 'KBDCALLS' index 25;}
  1507. function KbdXlate(var TransData:TKbdTrans;KbdHandle:word):word; cdecl;
  1508. external 'EMXWRAP' index 214;
  1509. {external 'KBDCALLS' index 14;}
  1510. function KbdSetCustXt(var XLateTbl:TXLateTbl;KbdHandle:word):word; cdecl;
  1511. external 'EMXWRAP' index 201;
  1512. {external 'KBDCALLS' index 1;}
  1513. function KbdSetCustXt(var CodePage:word;KbdHandle:word):word; cdecl;
  1514. external 'EMXWRAP' index 201;
  1515. {external 'KBDCALLS' index 1;}
  1516. function KbdSetCustXt(var XLateTblP:pointer;KbdHandle:word):word; cdecl;
  1517. external 'EMXWRAP' index 201;
  1518. {external 'KBDCALLS' index 1;}
  1519. end.