2
0

kbdcalls.pas 83 KB

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