Events.pas 29 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080
  1. {
  2. File: HIToolbox/Events.h
  3. Contains: Event Manager Interfaces.
  4. Version: HIToolbox-624~3
  5. Copyright: © 1985-2008 by Apple Computer, Inc., all rights reserved
  6. Bugs?: For bug reports, consult the following page on
  7. the World Wide Web:
  8. http://bugs.freepascal.org
  9. }
  10. { Pascal Translation Updated: Peter N Lewis, <[email protected]>, August 2005 }
  11. { Pascal Translation Updated: Jonas Maebe, <[email protected]>, October 2009 }
  12. { Pascal Translation Updated: Gorazd Krosl, <[email protected]>, October 2009 }
  13. { Pascal Translation Updated: Jonas Maebe, <[email protected]>, October 2012 }
  14. {
  15. Modified for use with Free Pascal
  16. Version 308
  17. Please report any bugs to <[email protected]>
  18. }
  19. {$ifc not defined MACOSALLINCLUDE or not MACOSALLINCLUDE}
  20. {$mode macpas}
  21. {$packenum 1}
  22. {$macro on}
  23. {$inline on}
  24. {$calling mwpascal}
  25. unit Events;
  26. interface
  27. {$setc UNIVERSAL_INTERFACES_VERSION := $0400}
  28. {$setc GAP_INTERFACES_VERSION := $0308}
  29. {$ifc not defined USE_CFSTR_CONSTANT_MACROS}
  30. {$setc USE_CFSTR_CONSTANT_MACROS := TRUE}
  31. {$endc}
  32. {$ifc defined CPUPOWERPC and defined CPUI386}
  33. {$error Conflicting initial definitions for CPUPOWERPC and CPUI386}
  34. {$endc}
  35. {$ifc defined FPC_BIG_ENDIAN and defined FPC_LITTLE_ENDIAN}
  36. {$error Conflicting initial definitions for FPC_BIG_ENDIAN and FPC_LITTLE_ENDIAN}
  37. {$endc}
  38. {$ifc not defined __ppc__ and defined CPUPOWERPC32}
  39. {$setc __ppc__ := 1}
  40. {$elsec}
  41. {$setc __ppc__ := 0}
  42. {$endc}
  43. {$ifc not defined __ppc64__ and defined CPUPOWERPC64}
  44. {$setc __ppc64__ := 1}
  45. {$elsec}
  46. {$setc __ppc64__ := 0}
  47. {$endc}
  48. {$ifc not defined __i386__ and defined CPUI386}
  49. {$setc __i386__ := 1}
  50. {$elsec}
  51. {$setc __i386__ := 0}
  52. {$endc}
  53. {$ifc not defined __x86_64__ and defined CPUX86_64}
  54. {$setc __x86_64__ := 1}
  55. {$elsec}
  56. {$setc __x86_64__ := 0}
  57. {$endc}
  58. {$ifc not defined __arm__ and defined CPUARM}
  59. {$setc __arm__ := 1}
  60. {$elsec}
  61. {$setc __arm__ := 0}
  62. {$endc}
  63. {$ifc not defined __arm64__ and defined CPUAARCH64}
  64. {$setc __arm64__ := 1}
  65. {$elsec}
  66. {$setc __arm64__ := 0}
  67. {$endc}
  68. {$ifc defined cpu64}
  69. {$setc __LP64__ := 1}
  70. {$elsec}
  71. {$setc __LP64__ := 0}
  72. {$endc}
  73. {$ifc defined __ppc__ and __ppc__ and defined __i386__ and __i386__}
  74. {$error Conflicting definitions for __ppc__ and __i386__}
  75. {$endc}
  76. {$ifc defined __ppc__ and __ppc__}
  77. {$setc TARGET_CPU_PPC := TRUE}
  78. {$setc TARGET_CPU_PPC64 := FALSE}
  79. {$setc TARGET_CPU_X86 := FALSE}
  80. {$setc TARGET_CPU_X86_64 := FALSE}
  81. {$setc TARGET_CPU_ARM := FALSE}
  82. {$setc TARGET_CPU_ARM64 := FALSE}
  83. {$setc TARGET_OS_MAC := TRUE}
  84. {$setc TARGET_OS_IPHONE := FALSE}
  85. {$setc TARGET_IPHONE_SIMULATOR := FALSE}
  86. {$setc TARGET_OS_EMBEDDED := FALSE}
  87. {$elifc defined __ppc64__ and __ppc64__}
  88. {$setc TARGET_CPU_PPC := FALSE}
  89. {$setc TARGET_CPU_PPC64 := TRUE}
  90. {$setc TARGET_CPU_X86 := FALSE}
  91. {$setc TARGET_CPU_X86_64 := FALSE}
  92. {$setc TARGET_CPU_ARM := FALSE}
  93. {$setc TARGET_CPU_ARM64 := FALSE}
  94. {$setc TARGET_OS_MAC := TRUE}
  95. {$setc TARGET_OS_IPHONE := FALSE}
  96. {$setc TARGET_IPHONE_SIMULATOR := FALSE}
  97. {$setc TARGET_OS_EMBEDDED := FALSE}
  98. {$elifc defined __i386__ and __i386__}
  99. {$setc TARGET_CPU_PPC := FALSE}
  100. {$setc TARGET_CPU_PPC64 := FALSE}
  101. {$setc TARGET_CPU_X86 := TRUE}
  102. {$setc TARGET_CPU_X86_64 := FALSE}
  103. {$setc TARGET_CPU_ARM := FALSE}
  104. {$setc TARGET_CPU_ARM64 := FALSE}
  105. {$ifc defined(iphonesim)}
  106. {$setc TARGET_OS_MAC := FALSE}
  107. {$setc TARGET_OS_IPHONE := TRUE}
  108. {$setc TARGET_IPHONE_SIMULATOR := TRUE}
  109. {$elsec}
  110. {$setc TARGET_OS_MAC := TRUE}
  111. {$setc TARGET_OS_IPHONE := FALSE}
  112. {$setc TARGET_IPHONE_SIMULATOR := FALSE}
  113. {$endc}
  114. {$setc TARGET_OS_EMBEDDED := FALSE}
  115. {$elifc defined __x86_64__ and __x86_64__}
  116. {$setc TARGET_CPU_PPC := FALSE}
  117. {$setc TARGET_CPU_PPC64 := FALSE}
  118. {$setc TARGET_CPU_X86 := FALSE}
  119. {$setc TARGET_CPU_X86_64 := TRUE}
  120. {$setc TARGET_CPU_ARM := FALSE}
  121. {$setc TARGET_CPU_ARM64 := FALSE}
  122. {$ifc defined(iphonesim)}
  123. {$setc TARGET_OS_MAC := FALSE}
  124. {$setc TARGET_OS_IPHONE := TRUE}
  125. {$setc TARGET_IPHONE_SIMULATOR := TRUE}
  126. {$elsec}
  127. {$setc TARGET_OS_MAC := TRUE}
  128. {$setc TARGET_OS_IPHONE := FALSE}
  129. {$setc TARGET_IPHONE_SIMULATOR := FALSE}
  130. {$endc}
  131. {$setc TARGET_OS_EMBEDDED := FALSE}
  132. {$elifc defined __arm__ and __arm__}
  133. {$setc TARGET_CPU_PPC := FALSE}
  134. {$setc TARGET_CPU_PPC64 := FALSE}
  135. {$setc TARGET_CPU_X86 := FALSE}
  136. {$setc TARGET_CPU_X86_64 := FALSE}
  137. {$setc TARGET_CPU_ARM := TRUE}
  138. {$setc TARGET_CPU_ARM64 := FALSE}
  139. { will require compiler define when/if other Apple devices with ARM cpus ship }
  140. {$setc TARGET_OS_MAC := FALSE}
  141. {$setc TARGET_OS_IPHONE := TRUE}
  142. {$setc TARGET_IPHONE_SIMULATOR := FALSE}
  143. {$setc TARGET_OS_EMBEDDED := TRUE}
  144. {$elifc defined __arm64__ and __arm64__}
  145. {$setc TARGET_CPU_PPC := FALSE}
  146. {$setc TARGET_CPU_PPC64 := FALSE}
  147. {$setc TARGET_CPU_X86 := FALSE}
  148. {$setc TARGET_CPU_X86_64 := FALSE}
  149. {$setc TARGET_CPU_ARM := FALSE}
  150. {$setc TARGET_CPU_ARM64 := TRUE}
  151. { will require compiler define when/if other Apple devices with ARM cpus ship }
  152. {$setc TARGET_OS_MAC := FALSE}
  153. {$setc TARGET_OS_IPHONE := TRUE}
  154. {$setc TARGET_IPHONE_SIMULATOR := FALSE}
  155. {$setc TARGET_OS_EMBEDDED := TRUE}
  156. {$elsec}
  157. {$error __ppc__ nor __ppc64__ nor __i386__ nor __x86_64__ nor __arm__ nor __arm64__ is defined.}
  158. {$endc}
  159. {$ifc defined __LP64__ and __LP64__ }
  160. {$setc TARGET_CPU_64 := TRUE}
  161. {$elsec}
  162. {$setc TARGET_CPU_64 := FALSE}
  163. {$endc}
  164. {$ifc defined FPC_BIG_ENDIAN}
  165. {$setc TARGET_RT_BIG_ENDIAN := TRUE}
  166. {$setc TARGET_RT_LITTLE_ENDIAN := FALSE}
  167. {$elifc defined FPC_LITTLE_ENDIAN}
  168. {$setc TARGET_RT_BIG_ENDIAN := FALSE}
  169. {$setc TARGET_RT_LITTLE_ENDIAN := TRUE}
  170. {$elsec}
  171. {$error Neither FPC_BIG_ENDIAN nor FPC_LITTLE_ENDIAN are defined.}
  172. {$endc}
  173. {$setc ACCESSOR_CALLS_ARE_FUNCTIONS := TRUE}
  174. {$setc CALL_NOT_IN_CARBON := FALSE}
  175. {$setc OLDROUTINENAMES := FALSE}
  176. {$setc OPAQUE_TOOLBOX_STRUCTS := TRUE}
  177. {$setc OPAQUE_UPP_TYPES := TRUE}
  178. {$setc OTCARBONAPPLICATION := TRUE}
  179. {$setc OTKERNEL := FALSE}
  180. {$setc PM_USE_SESSION_APIS := TRUE}
  181. {$setc TARGET_API_MAC_CARBON := TRUE}
  182. {$setc TARGET_API_MAC_OS8 := FALSE}
  183. {$setc TARGET_API_MAC_OSX := TRUE}
  184. {$setc TARGET_CARBON := TRUE}
  185. {$setc TARGET_CPU_68K := FALSE}
  186. {$setc TARGET_CPU_MIPS := FALSE}
  187. {$setc TARGET_CPU_SPARC := FALSE}
  188. {$setc TARGET_OS_UNIX := FALSE}
  189. {$setc TARGET_OS_WIN32 := FALSE}
  190. {$setc TARGET_RT_MAC_68881 := FALSE}
  191. {$setc TARGET_RT_MAC_CFM := FALSE}
  192. {$setc TARGET_RT_MAC_MACHO := TRUE}
  193. {$setc TYPED_FUNCTION_POINTERS := TRUE}
  194. {$setc TYPE_BOOL := FALSE}
  195. {$setc TYPE_EXTENDED := FALSE}
  196. {$setc TYPE_LONGLONG := TRUE}
  197. uses MacTypes,OSUtils,QuickdrawTypes,Endian;
  198. {$endc} {not MACOSALLINCLUDE}
  199. {$ifc TARGET_OS_MAC}
  200. {$ALIGN MAC68K}
  201. type
  202. EventKind = UInt16;
  203. EventMask = UInt16;
  204. const
  205. nullEvent = 0;
  206. mouseDown = 1;
  207. mouseUp = 2;
  208. keyDown = 3;
  209. keyUp = 4;
  210. autoKey = 5;
  211. updateEvt = 6;
  212. diskEvt = 7; { Not sent in Carbon. See kEventClassVolume in CarbonEvents.h}
  213. activateEvt = 8;
  214. osEvt = 15;
  215. kHighLevelEvent = 23;
  216. const
  217. mDownMask = 1 shl mouseDown; { mouse button pressed}
  218. mUpMask = 1 shl mouseUp; { mouse button released}
  219. keyDownMask = 1 shl keyDown; { key pressed}
  220. keyUpMask = 1 shl keyUp; { key released}
  221. autoKeyMask = 1 shl autoKey; { key repeatedly held down}
  222. updateMask = 1 shl updateEvt; { window needs updating}
  223. diskMask = 1 shl diskEvt; { disk inserted}
  224. activMask = 1 shl activateEvt; { activate/deactivate window}
  225. highLevelEventMask = $0400; { high-level events (includes AppleEvents)}
  226. osMask = 1 shl osEvt; { operating system events (suspend, resume)}
  227. everyEvent = $FFFF; { all of the above}
  228. const
  229. charCodeMask = $000000FF;
  230. keyCodeMask = $0000FF00;
  231. adbAddrMask = $00FF0000;
  232. osEvtMessageMask = $FF000000;
  233. const
  234. { OS event messages. Event (sub)code is in the high byte of the message field.}
  235. mouseMovedMessage = $00FA;
  236. suspendResumeMessage = $0001;
  237. const
  238. resumeFlag = 1; { Bit 0 of message indicates resume vs suspend}
  239. {
  240. CARBON ALERT! BATTLESTATIONS!
  241. The EventModifiers bits defined here are also used in the newer Carbon Event
  242. key modifiers parameters. There are two main differences:
  243. 1) The Carbon key modifiers parameter is a UInt32, not a UInt16. Never try to
  244. extract the key modifiers parameter from a Carbon Event into an EventModifiers
  245. type. You will probably get your stack trashed.
  246. 2) The Carbon key modifiers is just that: key modifiers. That parameter will
  247. never contain the button state bit.
  248. }
  249. type
  250. EventModifiers = UInt16;
  251. const
  252. { modifiers }
  253. activeFlagBit = 0; { activate? (activateEvt and mouseDown)}
  254. btnStateBit = 7; { state of button?}
  255. cmdKeyBit = 8; { command key down?}
  256. shiftKeyBit = 9; { shift key down?}
  257. alphaLockBit = 10; { alpha lock down?}
  258. optionKeyBit = 11; { option key down?}
  259. controlKeyBit = 12; { control key down?}
  260. rightShiftKeyBit = 13; { right shift key down? Not supported on Mac OS X.}
  261. rightOptionKeyBit = 14; { right Option key down? Not supported on Mac OS X.}
  262. rightControlKeyBit = 15; { right Control key down? Not supported on Mac OS X.}
  263. const
  264. activeFlag = 1 shl activeFlagBit;
  265. btnState = 1 shl btnStateBit;
  266. cmdKey = 1 shl cmdKeyBit;
  267. shiftKey = 1 shl shiftKeyBit;
  268. alphaLock = 1 shl alphaLockBit;
  269. optionKey = 1 shl optionKeyBit;
  270. controlKey = 1 shl controlKeyBit;
  271. rightShiftKey = 1 shl rightShiftKeyBit; { Not supported on Mac OS X.}
  272. rightOptionKey = 1 shl rightOptionKeyBit; { Not supported on Mac OS X.}
  273. rightControlKey = 1 shl rightControlKeyBit; { Not supported on Mac OS X.}
  274. { MacRoman character codes}
  275. const
  276. kNullCharCode = 0;
  277. kHomeCharCode = 1;
  278. kEnterCharCode = 3;
  279. kEndCharCode = 4;
  280. kHelpCharCode = 5;
  281. kBellCharCode = 7;
  282. kBackspaceCharCode = 8;
  283. kTabCharCode = 9;
  284. kLineFeedCharCode = 10;
  285. kVerticalTabCharCode = 11;
  286. kPageUpCharCode = 11;
  287. kFormFeedCharCode = 12;
  288. kPageDownCharCode = 12;
  289. kReturnCharCode = 13;
  290. kFunctionKeyCharCode = 16;
  291. kCommandCharCode = 17; { glyph available only in system fonts}
  292. kCheckCharCode = 18; { glyph available only in system fonts}
  293. kDiamondCharCode = 19; { glyph available only in system fonts}
  294. kAppleLogoCharCode = 20; { glyph available only in system fonts}
  295. kEscapeCharCode = 27;
  296. kClearCharCode = 27;
  297. kLeftArrowCharCode = 28;
  298. kRightArrowCharCode = 29;
  299. kUpArrowCharCode = 30;
  300. kDownArrowCharCode = 31;
  301. kSpaceCharCode = 32;
  302. kDeleteCharCode = 127;
  303. kBulletCharCode = 165;
  304. kNonBreakingSpaceCharCode = 202;
  305. { useful Unicode code points}
  306. const
  307. kShiftUnicode = $21E7; { Unicode UPWARDS WHITE ARROW}
  308. kControlUnicode = $2303; { Unicode UP ARROWHEAD}
  309. kOptionUnicode = $2325; { Unicode OPTION KEY}
  310. kCommandUnicode = $2318; { Unicode PLACE OF INTEREST SIGN}
  311. kPencilUnicode = $270E; { Unicode LOWER RIGHT PENCIL; actually pointed left until Mac OS X 10.3}
  312. kPencilLeftUnicode = $F802; { Unicode LOWER LEFT PENCIL; available in Mac OS X 10.3 and later}
  313. kCheckUnicode = $2713; { Unicode CHECK MARK}
  314. kDiamondUnicode = $25C6; { Unicode BLACK DIAMOND}
  315. kBulletUnicode = $2022; { Unicode BULLET}
  316. kAppleLogoUnicode = $F8FF; { Unicode APPLE LOGO}
  317. {
  318. * Summary:
  319. * Virtual keycodes
  320. *
  321. * Discussion:
  322. * These constants are the virtual keycodes defined originally in
  323. * Inside Mac Volume V, pg. V-191. They identify physical keys on a
  324. * keyboard. Those constants with "ANSI" in the name are labeled
  325. * according to the key position on an ANSI-standard US keyboard.
  326. * For example, kVK_ANSI_A indicates the virtual keycode for the key
  327. * with the letter 'A' in the US keyboard layout. Other keyboard
  328. * layouts may have the 'A' key label on a different physical key;
  329. * in this case, pressing 'A' will generate a different virtual
  330. * keycode.
  331. }
  332. const
  333. kVK_ANSI_A = $00;
  334. kVK_ANSI_S = $01;
  335. kVK_ANSI_D = $02;
  336. kVK_ANSI_F = $03;
  337. kVK_ANSI_H = $04;
  338. kVK_ANSI_G = $05;
  339. kVK_ANSI_Z = $06;
  340. kVK_ANSI_X = $07;
  341. kVK_ANSI_C = $08;
  342. kVK_ANSI_V = $09;
  343. kVK_ANSI_B = $0B;
  344. kVK_ANSI_Q = $0C;
  345. kVK_ANSI_W = $0D;
  346. kVK_ANSI_E = $0E;
  347. kVK_ANSI_R = $0F;
  348. kVK_ANSI_Y = $10;
  349. kVK_ANSI_T = $11;
  350. kVK_ANSI_1 = $12;
  351. kVK_ANSI_2 = $13;
  352. kVK_ANSI_3 = $14;
  353. kVK_ANSI_4 = $15;
  354. kVK_ANSI_6 = $16;
  355. kVK_ANSI_5 = $17;
  356. kVK_ANSI_Equal = $18;
  357. kVK_ANSI_9 = $19;
  358. kVK_ANSI_7 = $1A;
  359. kVK_ANSI_Minus = $1B;
  360. kVK_ANSI_8 = $1C;
  361. kVK_ANSI_0 = $1D;
  362. kVK_ANSI_RightBracket = $1E;
  363. kVK_ANSI_O = $1F;
  364. kVK_ANSI_U = $20;
  365. kVK_ANSI_LeftBracket = $21;
  366. kVK_ANSI_I = $22;
  367. kVK_ANSI_P = $23;
  368. kVK_ANSI_L = $25;
  369. kVK_ANSI_J = $26;
  370. kVK_ANSI_Quote = $27;
  371. kVK_ANSI_K = $28;
  372. kVK_ANSI_Semicolon = $29;
  373. kVK_ANSI_Backslash = $2A;
  374. kVK_ANSI_Comma = $2B;
  375. kVK_ANSI_Slash = $2C;
  376. kVK_ANSI_N = $2D;
  377. kVK_ANSI_M = $2E;
  378. kVK_ANSI_Period = $2F;
  379. kVK_ANSI_Grave = $32;
  380. kVK_ANSI_KeypadDecimal = $41;
  381. kVK_ANSI_KeypadMultiply = $43;
  382. kVK_ANSI_KeypadPlus = $45;
  383. kVK_ANSI_KeypadClear = $47;
  384. kVK_ANSI_KeypadDivide = $4B;
  385. kVK_ANSI_KeypadEnter = $4C;
  386. kVK_ANSI_KeypadMinus = $4E;
  387. kVK_ANSI_KeypadEquals = $51;
  388. kVK_ANSI_Keypad0 = $52;
  389. kVK_ANSI_Keypad1 = $53;
  390. kVK_ANSI_Keypad2 = $54;
  391. kVK_ANSI_Keypad3 = $55;
  392. kVK_ANSI_Keypad4 = $56;
  393. kVK_ANSI_Keypad5 = $57;
  394. kVK_ANSI_Keypad6 = $58;
  395. kVK_ANSI_Keypad7 = $59;
  396. kVK_ANSI_Keypad8 = $5B;
  397. kVK_ANSI_Keypad9 = $5C;
  398. { keycodes for keys that are independent of keyboard layout}
  399. const
  400. kVK_Return = $24;
  401. kVK_Tab = $30;
  402. kVK_Space = $31;
  403. kVK_Delete = $33;
  404. kVK_Escape = $35;
  405. kVK_Command = $37;
  406. kVK_Shift = $38;
  407. kVK_CapsLock = $39;
  408. kVK_Option = $3A;
  409. kVK_Control = $3B;
  410. kVK_RightShift = $3C;
  411. kVK_RightOption = $3D;
  412. kVK_RightControl = $3E;
  413. kVK_Function = $3F;
  414. kVK_F17 = $40;
  415. kVK_VolumeUp = $48;
  416. kVK_VolumeDown = $49;
  417. kVK_Mute = $4A;
  418. kVK_F18 = $4F;
  419. kVK_F19 = $50;
  420. kVK_F20 = $5A;
  421. kVK_F5 = $60;
  422. kVK_F6 = $61;
  423. kVK_F7 = $62;
  424. kVK_F3 = $63;
  425. kVK_F8 = $64;
  426. kVK_F9 = $65;
  427. kVK_F11 = $67;
  428. kVK_F13 = $69;
  429. kVK_F16 = $6A;
  430. kVK_F14 = $6B;
  431. kVK_F10 = $6D;
  432. kVK_F12 = $6F;
  433. kVK_F15 = $71;
  434. kVK_Help = $72;
  435. kVK_Home = $73;
  436. kVK_PageUp = $74;
  437. kVK_ForwardDelete = $75;
  438. kVK_F4 = $76;
  439. kVK_End = $77;
  440. kVK_F2 = $78;
  441. kVK_PageDown = $79;
  442. kVK_F1 = $7A;
  443. kVK_LeftArrow = $7B;
  444. kVK_RightArrow = $7C;
  445. kVK_DownArrow = $7D;
  446. kVK_UpArrow = $7E;
  447. { ISO keyboards only}
  448. const
  449. kVK_ISO_Section = $0A;
  450. { JIS keyboards only}
  451. const
  452. kVK_JIS_Yen = $5D;
  453. kVK_JIS_Underscore = $5E;
  454. kVK_JIS_KeypadComma = $5F;
  455. kVK_JIS_Eisu = $66;
  456. kVK_JIS_Kana = $68;
  457. type
  458. EventRecord = record
  459. what: EventKind;
  460. message: UNSIGNEDLONG;
  461. when: UInt32;
  462. where: Point;
  463. modifiers: EventModifiers;
  464. end;
  465. EventRecordPtr = ^EventRecord;
  466. type
  467. FKEYProcPtr = procedure;
  468. FKEYUPP = FKEYProcPtr;
  469. {
  470. * NewFKEYUPP()
  471. *
  472. * Availability:
  473. * Mac OS X: not available
  474. * CarbonLib: not available
  475. * Non-Carbon CFM: available as macro/inline
  476. }
  477. {
  478. * DisposeFKEYUPP()
  479. *
  480. * Availability:
  481. * Mac OS X: not available
  482. * CarbonLib: not available
  483. * Non-Carbon CFM: available as macro/inline
  484. }
  485. {
  486. * InvokeFKEYUPP()
  487. *
  488. * Availability:
  489. * Mac OS X: not available
  490. * CarbonLib: not available
  491. * Non-Carbon CFM: available as macro/inline
  492. }
  493. {$ifc not TARGET_CPU_64}
  494. {
  495. * GetMouse() *** DEPRECATED ***
  496. *
  497. * Deprecated:
  498. * Use HIGetMousePosition instead.
  499. *
  500. * Mac OS X threading:
  501. * Not thread safe
  502. *
  503. * Availability:
  504. * Mac OS X: in version 10.0 and later in Carbon.framework [32-bit only] but deprecated in 10.5
  505. * CarbonLib: in CarbonLib 1.0 and later
  506. * Non-Carbon CFM: in InterfaceLib 7.1 and later
  507. }
  508. procedure GetMouse( var mouseLoc: Point ); external name '_GetMouse';
  509. (* AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_5 *)
  510. {$endc} {not TARGET_CPU_64}
  511. {
  512. * Button() *** DEPRECATED ***
  513. *
  514. * Deprecated:
  515. * Use GetCurrentButtonState or GetCurrentEventButtonState instead.
  516. *
  517. * Mac OS X threading:
  518. * Not thread safe
  519. *
  520. * Availability:
  521. * Mac OS X: in version 10.0 and later in Carbon.framework but deprecated in 10.6
  522. * CarbonLib: in CarbonLib 1.0 and later
  523. * Non-Carbon CFM: in InterfaceLib 7.1 and later
  524. }
  525. function Button: Boolean; external name '_Button';
  526. (* AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_6 *)
  527. {$ifc not TARGET_CPU_64}
  528. {
  529. * StillDown()
  530. *
  531. * Mac OS X threading:
  532. * Not thread safe
  533. *
  534. * Availability:
  535. * Mac OS X: in version 10.0 and later in Carbon.framework [32-bit only]
  536. * CarbonLib: in CarbonLib 1.0 and later
  537. * Non-Carbon CFM: in InterfaceLib 7.1 and later
  538. }
  539. function StillDown: Boolean; external name '_StillDown';
  540. (* AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER *)
  541. {
  542. * WaitMouseUp()
  543. *
  544. * Mac OS X threading:
  545. * Not thread safe
  546. *
  547. * Availability:
  548. * Mac OS X: in version 10.0 and later in Carbon.framework [32-bit only]
  549. * CarbonLib: in CarbonLib 1.0 and later
  550. * Non-Carbon CFM: in InterfaceLib 7.1 and later
  551. }
  552. function WaitMouseUp: Boolean; external name '_WaitMouseUp';
  553. (* AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER *)
  554. {
  555. * KeyTranslate() *** DEPRECATED ***
  556. *
  557. * Deprecated:
  558. * Use UCKeyTranslate instead.
  559. *
  560. * Mac OS X threading:
  561. * Not thread safe
  562. *
  563. * Availability:
  564. * Mac OS X: in version 10.0 and later in Carbon.framework [32-bit only] but deprecated in 10.6
  565. * CarbonLib: in CarbonLib 1.0 and later
  566. * Non-Carbon CFM: in InterfaceLib 7.1 and later
  567. }
  568. function KeyTranslate( transData: {const} UnivPtr; keycode: UInt16; var state: UInt32 ): UInt32; external name '_KeyTranslate';
  569. (* AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_6 *)
  570. {
  571. * GetCaretTime()
  572. *
  573. * Mac OS X threading:
  574. * Not thread safe
  575. *
  576. * Availability:
  577. * Mac OS X: in version 10.0 and later in Carbon.framework [32-bit only]
  578. * CarbonLib: in CarbonLib 1.0 and later
  579. * Non-Carbon CFM: in InterfaceLib 7.1 and later
  580. }
  581. function GetCaretTime: UInt32; external name '_GetCaretTime';
  582. (* AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER *)
  583. {$endc} {not TARGET_CPU_64}
  584. {
  585. QuickTime 3.0 supports GetKeys() on unix and win32
  586. }
  587. type
  588. KeyMap = packed array [0..127] of boolean;
  589. {
  590. * GetKeys()
  591. *
  592. * Mac OS X threading:
  593. * Not thread safe
  594. *
  595. * Availability:
  596. * Mac OS X: in version 10.0 and later in Carbon.framework
  597. * CarbonLib: in CarbonLib 1.0 and later
  598. * Non-Carbon CFM: in InterfaceLib 7.1 and later
  599. }
  600. procedure __GetKeys( var theKeys: KeyMap ); external name '_GetKeys';
  601. (* AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER *)
  602. {
  603. With GPC and FPC on PowerPC, the bytes of the KeyMap must be swapped
  604. }
  605. procedure GetKeys( var theKeys: KeyMap );
  606. { Obsolete event types & masks }
  607. const
  608. networkEvt = 10;
  609. driverEvt = 11;
  610. app1Evt = 12;
  611. app2Evt = 13;
  612. app3Evt = 14;
  613. app4Evt = 15;
  614. networkMask = $0400;
  615. driverMask = $0800;
  616. app1Mask = $1000;
  617. app2Mask = $2000;
  618. app3Mask = $4000;
  619. app4Mask = $8000;
  620. type
  621. EvQEl = record
  622. qLink: QElemPtr;
  623. qType: SInt16;
  624. evtQWhat: EventKind; { this part is identical to the EventRecord as defined above }
  625. evtQMessage: UNSIGNEDLONG;
  626. evtQWhen: UInt32;
  627. evtQWhere: Point;
  628. evtQModifiers: EventModifiers;
  629. end;
  630. EvQElPtr = ^EvQEl;
  631. type
  632. GetNextEventFilterProcPtr = procedure( var theEvent: EventRecord; var result: Boolean );
  633. GetNextEventFilterUPP = GetNextEventFilterProcPtr;
  634. {
  635. * NewGetNextEventFilterUPP()
  636. *
  637. * Availability:
  638. * Mac OS X: not available
  639. * CarbonLib: not available
  640. * Non-Carbon CFM: available as macro/inline
  641. }
  642. {
  643. * DisposeGetNextEventFilterUPP()
  644. *
  645. * Availability:
  646. * Mac OS X: not available
  647. * CarbonLib: not available
  648. * Non-Carbon CFM: available as macro/inline
  649. }
  650. {
  651. * InvokeGetNextEventFilterUPP()
  652. *
  653. * Availability:
  654. * Mac OS X: not available
  655. * CarbonLib: not available
  656. * Non-Carbon CFM: available as macro/inline
  657. }
  658. type
  659. GNEFilterUPP = GetNextEventFilterUPP;
  660. {$ifc not TARGET_CPU_64}
  661. {
  662. * GetDblTime()
  663. *
  664. * Summary:
  665. * Returns the maximum time (in units of 1/60th of a second) allowed
  666. * between two consecutive mouse-down events in order for the second
  667. * click to be considered a double-click.
  668. *
  669. * Discussion:
  670. * In 64-bit applications, you may replace calls to this API with
  671. * calls to NXClickTime (declared in
  672. * <IOKit/hidsystem/event_status_driver.h>) or with +[NSEvent
  673. * doubleClickInterval] (available in Mac OS X 10.6 and later).
  674. *
  675. * Mac OS X threading:
  676. * Not thread safe
  677. *
  678. * Result:
  679. * The maximum time between mouse-downs allowed for a double-click.
  680. *
  681. * Availability:
  682. * Mac OS X: in version 10.0 and later in Carbon.framework [32-bit only]
  683. * CarbonLib: in CarbonLib 1.0 and later
  684. * Non-Carbon CFM: in InterfaceLib 7.1 and later
  685. }
  686. function GetDblTime: UInt32; external name '_GetDblTime';
  687. (* AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER *)
  688. {
  689. * SetEventMask()
  690. *
  691. * Mac OS X threading:
  692. * Not thread safe
  693. *
  694. * Availability:
  695. * Mac OS X: in version 10.0 and later in Carbon.framework [32-bit only]
  696. * CarbonLib: in CarbonLib 1.0 and later
  697. * Non-Carbon CFM: in InterfaceLib 7.1 and later
  698. }
  699. procedure SetEventMask( value: EventMask ); external name '_SetEventMask';
  700. (* AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER *)
  701. {
  702. * GetNextEvent() *** DEPRECATED ***
  703. *
  704. * Deprecated:
  705. * Use ReceiveNextEvent instead.
  706. *
  707. * Mac OS X threading:
  708. * Not thread safe
  709. *
  710. * Availability:
  711. * Mac OS X: in version 10.0 and later in Carbon.framework [32-bit only] but deprecated in 10.6
  712. * CarbonLib: in CarbonLib 1.0 and later
  713. * Non-Carbon CFM: in InterfaceLib 7.1 and later
  714. }
  715. function GetNextEvent( eventMask_: EventMask; var theEvent: EventRecord ): Boolean; external name '_GetNextEvent';
  716. (* AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_6 *)
  717. {
  718. * WaitNextEvent() *** DEPRECATED ***
  719. *
  720. * Deprecated:
  721. * Use ReceiveNextEvent instead.
  722. *
  723. * Mac OS X threading:
  724. * Not thread safe
  725. *
  726. * Availability:
  727. * Mac OS X: in version 10.0 and later in Carbon.framework [32-bit only] but deprecated in 10.6
  728. * CarbonLib: in CarbonLib 1.0 and later
  729. * Non-Carbon CFM: in InterfaceLib 7.1 and later
  730. }
  731. function WaitNextEvent( eventMask_: EventMask; var theEvent: EventRecord; sleep: UInt32; mouseRgn: RgnHandle { can be NULL } ): Boolean; external name '_WaitNextEvent';
  732. (* AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_6 *)
  733. {
  734. * EventAvail() *** DEPRECATED ***
  735. *
  736. * Deprecated:
  737. * Use FindSpecificEventInQueue instead.
  738. *
  739. * Mac OS X threading:
  740. * Not thread safe
  741. *
  742. * Availability:
  743. * Mac OS X: in version 10.0 and later in Carbon.framework [32-bit only] but deprecated in 10.6
  744. * CarbonLib: in CarbonLib 1.0 and later
  745. * Non-Carbon CFM: in InterfaceLib 7.1 and later
  746. }
  747. function EventAvail( eventMask_: EventMask; var theEvent: EventRecord ): Boolean; external name '_EventAvail';
  748. (* AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_6 *)
  749. {
  750. * PostEvent() *** DEPRECATED ***
  751. *
  752. * Deprecated:
  753. * Use PostEventToQueue or CGEventPost instead.
  754. *
  755. * Mac OS X threading:
  756. * Not thread safe
  757. *
  758. * Availability:
  759. * Mac OS X: in version 10.0 and later in Carbon.framework [32-bit only] but deprecated in 10.6
  760. * CarbonLib: in CarbonLib 1.0 and later
  761. * Non-Carbon CFM: in InterfaceLib 7.1 and later
  762. }
  763. function PostEvent( eventNum: EventKind; eventMsg: UInt32 ): OSErr; external name '_PostEvent';
  764. (* AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_6 *)
  765. {$endc} {not TARGET_CPU_64}
  766. {
  767. * FlushEvents() *** DEPRECATED ***
  768. *
  769. * Deprecated:
  770. * Use FlushEventsMatchingListFromQueue,
  771. * FlushSpecificEventsFromQueue, or FlushEventQueue instead.
  772. *
  773. * Mac OS X threading:
  774. * Not thread safe
  775. *
  776. * Availability:
  777. * Mac OS X: in version 10.0 and later in Carbon.framework but deprecated in 10.6
  778. * CarbonLib: in CarbonLib 1.0 and later
  779. * Non-Carbon CFM: in InterfaceLib 7.1 and later
  780. }
  781. procedure FlushEvents( whichMask: EventMask; stopMask: EventMask ); external name '_FlushEvents';
  782. (* AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_6 *)
  783. (*
  784. #if OLDROUTINENAMES
  785. #define KeyTrans(transData, keycode, state) KeyTranslate(transData, keycode, state)
  786. #endif { OLDROUTINENAMES }
  787. *)
  788. {$ifc not TARGET_CPU_64}
  789. {
  790. * KeyScript() *** DEPRECATED ***
  791. *
  792. * Deprecated:
  793. * Use TISSelectInputSource API for positive verbs (ScriptCode).
  794. * Use TSMDocument properties to restrict input sources:
  795. * kTSMDocumentEnabledInputSourcesPropertyTag
  796. * kTSMDocumentInputSourceOverridePropertyTag
  797. *
  798. * Summary:
  799. * Switch to the specified script's default (last used) input source.
  800. *
  801. * Mac OS X threading:
  802. * Not thread safe
  803. *
  804. * Availability:
  805. * Mac OS X: in version 10.0 and later in Carbon.framework [32-bit only] but deprecated in 10.5
  806. * CarbonLib: in CarbonLib 1.0 and later
  807. * Non-Carbon CFM: in InterfaceLib 7.1 and later
  808. }
  809. procedure KeyScript( code: SInt16 ); external name '_KeyScript';
  810. (* AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_5 *)
  811. {$endc} {not TARGET_CPU_64}
  812. {
  813. * IsCmdChar() *** DEPRECATED ***
  814. *
  815. * Deprecated:
  816. * Use IsUserCancelEventRef or CheckEventQueueForUserCancel instead.
  817. *
  818. * Mac OS X threading:
  819. * Not thread safe
  820. *
  821. * Availability:
  822. * Mac OS X: in version 10.0 and later in Carbon.framework but deprecated in 10.6
  823. * CarbonLib: in CarbonLib 1.0 and later
  824. * Non-Carbon CFM: in InterfaceLib 7.1 and later
  825. }
  826. function IsCmdChar( const (*var*) event: EventRecord; test: SInt16 ): Boolean; external name '_IsCmdChar';
  827. (* AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_6 *)
  828. {
  829. LowMem accessor functions previously in LowMem.h
  830. }
  831. {
  832. * LMGetKeyThresh()
  833. *
  834. * Mac OS X threading:
  835. * Not thread safe
  836. *
  837. * Availability:
  838. * Mac OS X: in version 10.0 and later in Carbon.framework
  839. * CarbonLib: in CarbonLib 1.0 and later
  840. * Non-Carbon CFM: in InterfaceLib 7.1 and later
  841. }
  842. function LMGetKeyThresh: SInt16; external name '_LMGetKeyThresh';
  843. (* AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER *)
  844. {$ifc not TARGET_CPU_64}
  845. {
  846. * LMSetKeyThresh()
  847. *
  848. * Mac OS X threading:
  849. * Not thread safe
  850. *
  851. * Availability:
  852. * Mac OS X: in version 10.0 and later in Carbon.framework [32-bit only]
  853. * CarbonLib: in CarbonLib 1.0 and later
  854. * Non-Carbon CFM: in InterfaceLib 7.1 and later
  855. }
  856. procedure LMSetKeyThresh( value: SInt16 ); external name '_LMSetKeyThresh';
  857. (* AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER *)
  858. {$endc} {not TARGET_CPU_64}
  859. {
  860. * LMGetKeyRepThresh()
  861. *
  862. * Mac OS X threading:
  863. * Not thread safe
  864. *
  865. * Availability:
  866. * Mac OS X: in version 10.0 and later in Carbon.framework
  867. * CarbonLib: in CarbonLib 1.0 and later
  868. * Non-Carbon CFM: in InterfaceLib 7.1 and later
  869. }
  870. function LMGetKeyRepThresh: SInt16; external name '_LMGetKeyRepThresh';
  871. (* AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER *)
  872. {$ifc not TARGET_CPU_64}
  873. {
  874. * LMSetKeyRepThresh()
  875. *
  876. * Mac OS X threading:
  877. * Not thread safe
  878. *
  879. * Availability:
  880. * Mac OS X: in version 10.0 and later in Carbon.framework [32-bit only]
  881. * CarbonLib: in CarbonLib 1.0 and later
  882. * Non-Carbon CFM: in InterfaceLib 7.1 and later
  883. }
  884. procedure LMSetKeyRepThresh( value: SInt16 ); external name '_LMSetKeyRepThresh';
  885. (* AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER *)
  886. {$endc} {not TARGET_CPU_64}
  887. {
  888. * LMGetKbdLast()
  889. *
  890. * Mac OS X threading:
  891. * Not thread safe
  892. *
  893. * Availability:
  894. * Mac OS X: in version 10.0 and later in Carbon.framework
  895. * CarbonLib: in CarbonLib 1.0 and later
  896. * Non-Carbon CFM: in InterfaceLib 7.1 and later
  897. }
  898. function LMGetKbdLast: UInt8; external name '_LMGetKbdLast';
  899. (* AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER *)
  900. {$ifc not TARGET_CPU_64}
  901. {
  902. * LMSetKbdLast()
  903. *
  904. * Mac OS X threading:
  905. * Not thread safe
  906. *
  907. * Availability:
  908. * Mac OS X: in version 10.0 and later in Carbon.framework [32-bit only]
  909. * CarbonLib: in CarbonLib 1.0 and later
  910. * Non-Carbon CFM: in InterfaceLib 7.1 and later
  911. }
  912. procedure LMSetKbdLast( value: UInt8 ); external name '_LMSetKbdLast';
  913. (* AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER *)
  914. {$endc} {not TARGET_CPU_64}
  915. {
  916. * LMGetKbdType()
  917. *
  918. * Mac OS X threading:
  919. * Not thread safe
  920. *
  921. * Availability:
  922. * Mac OS X: in version 10.0 and later in Carbon.framework
  923. * CarbonLib: in CarbonLib 1.0 and later
  924. * Non-Carbon CFM: in InterfaceLib 7.1 and later
  925. }
  926. function LMGetKbdType: UInt8; external name '_LMGetKbdType';
  927. (* AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER *)
  928. {$ifc not TARGET_CPU_64}
  929. {
  930. * LMSetKbdType()
  931. *
  932. * Mac OS X threading:
  933. * Not thread safe
  934. *
  935. * Availability:
  936. * Mac OS X: in version 10.0 and later in Carbon.framework [32-bit only]
  937. * CarbonLib: in CarbonLib 1.0 and later
  938. * Non-Carbon CFM: in InterfaceLib 7.1 and later
  939. }
  940. procedure LMSetKbdType( value: UInt8 ); external name '_LMSetKbdType';
  941. (* AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER *)
  942. {$endc} {not TARGET_CPU_64}
  943. {$endc} {TARGET_OS_MAC}
  944. {$ifc not defined MACOSALLINCLUDE or not MACOSALLINCLUDE}
  945. implementation
  946. {$ifc TARGET_OS_MAC}
  947. {$ifc TARGET_RT_BIG_ENDIAN}
  948. procedure GetKeys( var theKeys: KeyMap );
  949. var
  950. theReverseKeys: KeyMap;
  951. theKey: 0..127;
  952. begin
  953. __GetKeys( theReverseKeys);
  954. for theKey:= 0 to 127 do
  955. theKeys[ theKey]:= theReverseKeys[ ((theKey div 8) * 8) + (7 - (theKey mod 8))]
  956. end;
  957. {$elsec}
  958. procedure GetKeys( var theKeys: KeyMap );
  959. begin
  960. __GetKeys( theKeys)
  961. end;
  962. {$endc}
  963. {$endc} {TARGET_OS_MAC}
  964. end.
  965. {$endc} {not MACOSALLINCLUDE}