Events.pas 29 KB

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