CGEventTypes.pas 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520
  1. {
  2. * CGEventTypes.h
  3. * CoreGraphics
  4. *
  5. * Copyright (c) 2004 Apple Computer, Inc. All rights reserved.
  6. *
  7. }
  8. { Pascal Translation: Peter N Lewis, <[email protected]>, August 2005 }
  9. {
  10. Modified for use with Free Pascal
  11. Version 200
  12. Please report any bugs to <[email protected]>
  13. }
  14. {$mode macpas}
  15. {$packenum 1}
  16. {$macro on}
  17. {$inline on}
  18. {$CALLING MWPASCAL}
  19. unit CGEventTypes;
  20. interface
  21. {$setc UNIVERSAL_INTERFACES_VERSION := $0342}
  22. {$setc GAP_INTERFACES_VERSION := $0200}
  23. {$ifc not defined USE_CFSTR_CONSTANT_MACROS}
  24. {$setc USE_CFSTR_CONSTANT_MACROS := TRUE}
  25. {$endc}
  26. {$ifc defined CPUPOWERPC and defined CPUI386}
  27. {$error Conflicting initial definitions for CPUPOWERPC and CPUI386}
  28. {$endc}
  29. {$ifc defined FPC_BIG_ENDIAN and defined FPC_LITTLE_ENDIAN}
  30. {$error Conflicting initial definitions for FPC_BIG_ENDIAN and FPC_LITTLE_ENDIAN}
  31. {$endc}
  32. {$ifc not defined __ppc__ and defined CPUPOWERPC}
  33. {$setc __ppc__ := 1}
  34. {$elsec}
  35. {$setc __ppc__ := 0}
  36. {$endc}
  37. {$ifc not defined __i386__ and defined CPUI386}
  38. {$setc __i386__ := 1}
  39. {$elsec}
  40. {$setc __i386__ := 0}
  41. {$endc}
  42. {$ifc defined __ppc__ and __ppc__ and defined __i386__ and __i386__}
  43. {$error Conflicting definitions for __ppc__ and __i386__}
  44. {$endc}
  45. {$ifc defined __ppc__ and __ppc__}
  46. {$setc TARGET_CPU_PPC := TRUE}
  47. {$setc TARGET_CPU_X86 := FALSE}
  48. {$elifc defined __i386__ and __i386__}
  49. {$setc TARGET_CPU_PPC := FALSE}
  50. {$setc TARGET_CPU_X86 := TRUE}
  51. {$elsec}
  52. {$error Neither __ppc__ nor __i386__ is defined.}
  53. {$endc}
  54. {$setc TARGET_CPU_PPC_64 := FALSE}
  55. {$ifc defined FPC_BIG_ENDIAN}
  56. {$setc TARGET_RT_BIG_ENDIAN := TRUE}
  57. {$setc TARGET_RT_LITTLE_ENDIAN := FALSE}
  58. {$elifc defined FPC_LITTLE_ENDIAN}
  59. {$setc TARGET_RT_BIG_ENDIAN := FALSE}
  60. {$setc TARGET_RT_LITTLE_ENDIAN := TRUE}
  61. {$elsec}
  62. {$error Neither FPC_BIG_ENDIAN nor FPC_LITTLE_ENDIAN are defined.}
  63. {$endc}
  64. {$setc ACCESSOR_CALLS_ARE_FUNCTIONS := TRUE}
  65. {$setc CALL_NOT_IN_CARBON := FALSE}
  66. {$setc OLDROUTINENAMES := FALSE}
  67. {$setc OPAQUE_TOOLBOX_STRUCTS := TRUE}
  68. {$setc OPAQUE_UPP_TYPES := TRUE}
  69. {$setc OTCARBONAPPLICATION := TRUE}
  70. {$setc OTKERNEL := FALSE}
  71. {$setc PM_USE_SESSION_APIS := TRUE}
  72. {$setc TARGET_API_MAC_CARBON := TRUE}
  73. {$setc TARGET_API_MAC_OS8 := FALSE}
  74. {$setc TARGET_API_MAC_OSX := TRUE}
  75. {$setc TARGET_CARBON := TRUE}
  76. {$setc TARGET_CPU_68K := FALSE}
  77. {$setc TARGET_CPU_MIPS := FALSE}
  78. {$setc TARGET_CPU_SPARC := FALSE}
  79. {$setc TARGET_OS_MAC := TRUE}
  80. {$setc TARGET_OS_UNIX := FALSE}
  81. {$setc TARGET_OS_WIN32 := FALSE}
  82. {$setc TARGET_RT_MAC_68881 := FALSE}
  83. {$setc TARGET_RT_MAC_CFM := FALSE}
  84. {$setc TARGET_RT_MAC_MACHO := TRUE}
  85. {$setc TYPED_FUNCTION_POINTERS := TRUE}
  86. {$setc TYPE_BOOL := FALSE}
  87. {$setc TYPE_EXTENDED := FALSE}
  88. {$setc TYPE_LONGLONG := TRUE}
  89. uses MacTypes,MacOSXPosix,CGRemoteOperation,CGBase;
  90. {$ALIGN POWER}
  91. {
  92. * The CGEventRef object may be created or copied, retained, released, and
  93. * modified. The object provides an opaque representation of one low level
  94. * hardware event.
  95. }
  96. type
  97. CGEventRef = ^SInt32; { an opaque 32-bit type }
  98. {
  99. * Types common to both CGEvent.h and CGEventSource.h
  100. }
  101. type
  102. _CGMouseButton = SInt32;
  103. const
  104. kCGMouseButtonLeft = 0;
  105. kCGMouseButtonRight = 1;
  106. kCGMouseButtonCenter = 2;
  107. type
  108. CGMouseButton = UInt32;
  109. {
  110. * The flags field includes both modifier key state at the time the event was created,
  111. * as well as other event related state.
  112. *
  113. * Note that any bits not specified are reserved.
  114. }
  115. type
  116. _CGEventFlags = SInt32;
  117. (*
  118. Uncomment when IOKit is translated
  119. const { Masks for the bits in event flags }
  120. { device-independent modifier key bits }
  121. kCGEventFlagMaskAlphaShift = NX_ALPHASHIFTMASK;
  122. kCGEventFlagMaskShift = NX_SHIFTMASK;
  123. kCGEventFlagMaskControl = NX_CONTROLMASK;
  124. kCGEventFlagMaskAlternate = NX_ALTERNATEMASK;
  125. kCGEventFlagMaskCommand = NX_COMMANDMASK;
  126. { Special key identifiers }
  127. kCGEventFlagMaskHelp = NX_HELPMASK;
  128. kCGEventFlagMaskSecondaryFn = NX_SECONDARYFNMASK;
  129. { Identifies key events from numeric keypad area on extended keyboards }
  130. kCGEventFlagMaskNumericPad = NX_NUMERICPADMASK;
  131. { Indicates if mouse/pen movement events are not being coalesced }
  132. kCGEventFlagMaskNonCoalesced = NX_NONCOALSESCEDMASK;
  133. *)
  134. type
  135. CGEventFlags = UInt64; { Flags for events }
  136. {
  137. *
  138. * The following enumeration describes all event types currently presented
  139. * in this API. Apple reserves the right to extend or create new event
  140. * types at any time.
  141. *
  142. * Notes:
  143. * Tablet devices may generate mice events with embedded tablet
  144. * data, or tablet pointer and proximity events. The tablet
  145. * events as mouse events allow tablets to be used with programs
  146. * which are not tablet-aware.
  147. }
  148. { Event types }
  149. type
  150. _CGEventType = SInt32;
  151. (*
  152. Uncomment when IOKit is translated
  153. const
  154. kCGEventNull = NX_NULLEVENT; { Placeholder; the Null Event }
  155. { mouse events }
  156. kCGEventLeftMouseDown = NX_LMOUSEDOWN; { left mouse-down event }
  157. kCGEventLeftMouseUp = NX_LMOUSEUP; { left mouse-up event }
  158. kCGEventRightMouseDown = NX_RMOUSEDOWN; { right mouse-down event }
  159. kCGEventRightMouseUp = NX_RMOUSEUP; { right mouse-up event }
  160. kCGEventMouseMoved = NX_MOUSEMOVED; { mouse-moved event }
  161. kCGEventLeftMouseDragged = NX_LMOUSEDRAGGED; { left mouse-dragged event }
  162. kCGEventRightMouseDragged = NX_RMOUSEDRAGGED; { right mouse-dragged event }
  163. { keyboard events }
  164. kCGEventKeyDown = NX_KEYDOWN; { key-down event }
  165. kCGEventKeyUp = NX_KEYUP; { key-up event }
  166. kCGEventFlagsChanged = NX_FLAGSCHANGED; { flags-changed (modifier keys and status) event }
  167. { Specialized control devices }
  168. kCGEventScrollWheel = NX_SCROLLWHEELMOVED; { Scroll wheel input device }
  169. kCGEventTabletPointer = NX_TABLETPOINTER; { specialized tablet pointer event, in addition to tablet mouse event }
  170. kCGEventTabletProximity = NX_TABLETPROXIMITY; { specialized tablet proximity event, in addition to tablet mouse event }
  171. kCGEventOtherMouseDown = NX_OMOUSEDOWN; { Mouse button 2-31 down }
  172. kCGEventOtherMouseUp = NX_OMOUSEUP; { Mouse button 2-31 up }
  173. kCGEventOtherMouseDragged = NX_OMOUSEDRAGGED; { Drag with mouse button 2-31 down }
  174. *)
  175. {
  176. * Out of band types, delivered for unusual conditions
  177. * These are delivered to the event tap callback to notify of unusual
  178. * conditions that disable the event tap.
  179. }
  180. const
  181. kCGEventTapDisabledByTimeout = $FFFFFFFE;
  182. kCGEventTapDisabledByUserInput = $FFFFFFFF;
  183. type
  184. CGEventType = UInt32;
  185. type
  186. CGEventTimestamp = UInt64; { Event timestamp, roughly, nanoseconds since startup }
  187. {
  188. * Low level functions provide access to specialized fields of the events
  189. * The fields are identified by tokens defined in this enumeration.
  190. }
  191. type
  192. _CGEventField = SInt32;
  193. const
  194. { Additional keys and values found in mouse events, including the OtherMouse events: }
  195. kCGMouseEventNumber = 0;
  196. { Key associated with an integer encoding the mouse button event number as an integer. Matching mouse-down and mouse-up events will have the same event number. }
  197. kCGMouseEventClickState = 1;
  198. { Key associated with an integer encoding the mouse button clickState as an integer. A clickState of 1 represents a single click. A clickState of 2 represents a double-click. A clickState of 3 represents a triple-click. }
  199. kCGMouseEventPressure = 2;
  200. { Key associated with a double encoding the mouse button pressurr. The pressure value may range from 0 to 1.0, with 0 representing the mouse being up. This value is commonly set by tablet pens mimicing a mouse. }
  201. kCGMouseEventButtonNumber = 3;
  202. { Key associated with an integer representing the mouse button number. The left mouse button reports as button 0. A right mouse button reports as button 1. A middle button reports as button 2, and additional buttons report as the appropriate USB button. }
  203. kCGMouseEventDeltaX = 4;
  204. kCGMouseEventDeltaY = 5;
  205. { Key associated with an integer encoding the mouse delta since the last mouse movement event. }
  206. kCGMouseEventInstantMouser = 6;
  207. { Key associated with an integer value, non-zero if the event should be ignored by the Inkwell subsystem. }
  208. kCGMouseEventSubtype = 7;
  209. {
  210. * Key associated with an integer encoding the mouse event subtype as a kCFNumberIntType.
  211. *
  212. * Tablets may generate specially annotated mouse events,
  213. * which will contain additional keys and values.
  214. *
  215. * Mouse events of subtype kCGEventMouseSubtypeTabletPoint may also use the tablet accessor keys.
  216. * Mouse events of subtype kCGEventMouseSubtypeTabletProximity may also use the tablet proximity accessor keys.
  217. }
  218. { Additional keys and values found in keyboard events: }
  219. kCGKeyboardEventAutorepeat = 8;
  220. { Key associated with an integer, non-zero when when this is an autorepeat of a key-down, and zero otherwise. }
  221. kCGKeyboardEventKeycode = 9;
  222. { Key associated with the integer virtual keycode of the key-down or key-up event. }
  223. kCGKeyboardEventKeyboardType = 10;
  224. { Key associated with the integer representing the keyboard type identifier. }
  225. { Additional keys and values found in scroll wheel events: }
  226. kCGScrollWheelEventDeltaAxis1 = 11;
  227. kCGScrollWheelEventDeltaAxis2 = 12;
  228. kCGScrollWheelEventDeltaAxis3 = 13;
  229. { Key associated with an integer value representing a change in scrollwheel position. }
  230. kCGScrollWheelEventInstantMouser = 14;
  231. { Key associated with an integer value, non-zero if the event should be ignored by the Inkwell subsystem. }
  232. {
  233. * Additional keys and values found in tablet pointer events,
  234. * and in mouse events containing embedded tablet event data:
  235. }
  236. kCGTabletEventPointX = 15;
  237. kCGTabletEventPointY = 16;
  238. kCGTabletEventPointZ = 17;
  239. { Key associated with an integer encoding the absolute X, Y, or Z tablet coordinate in tablet space at full tablet resolution. }
  240. kCGTabletEventPointButtons = 18;
  241. { Key associated with an integer encoding the tablet button state. Bit 0 is the first button, and a set bit represents a closed or pressed button. Up to 16 buttons are supported. }
  242. kCGTabletEventPointPressure = 19;
  243. { Key associated with a double encoding the tablet pen pressure. 0 represents no pressure, and 1.0 represents maximum pressure. }
  244. kCGTabletEventTiltX = 20;
  245. kCGTabletEventTiltY = 21;
  246. { Key associated with a double encoding the tablet pen tilt. 0 represents no tilt, and 1.0 represents maximum tilt. }
  247. kCGTabletEventRotation = 22;
  248. { Key associated with a double encoding the tablet pen rotation. }
  249. kCGTabletEventTangentialPressure = 23;
  250. { Key associated with a double encoding the tangential pressure on the device. 0 represents no pressure, and 1.0 represents maximum pressure. }
  251. kCGTabletEventDeviceID = 24;
  252. { Key associated with an integer encoding the system-assigned unique device ID. }
  253. kCGTabletEventVendor1 = 25;
  254. kCGTabletEventVendor2 = 26;
  255. kCGTabletEventVendor3 = 27;
  256. { Key associated with an integer containing vendor-specified values.}
  257. {
  258. * Additional keys and values found in tablet proximity events,
  259. * and in mouse events containing embedded tablet proximity data:
  260. }
  261. kCGTabletProximityEventVendorID = 28;
  262. { Key associated with an integer encoding the vendor-defined ID, typically the USB vendor ID. }
  263. kCGTabletProximityEventTabletID = 29;
  264. { Key associated with an integer encoding the vendor-defined tablet ID, typically the USB product ID. }
  265. kCGTabletProximityEventPointerID = 30;
  266. { Key associated with an integer encoding the vendor-defined ID of the pointing device. }
  267. kCGTabletProximityEventDeviceID = 31;
  268. { Key associated with an integer encoding the system-assigned device ID. }
  269. kCGTabletProximityEventSystemTabletID = 32;
  270. { Key associated with an integer encoding the system-assigned unique tablet ID. }
  271. kCGTabletProximityEventVendorPointerType = 33;
  272. { Key associated with an integer encoding the vendor-assigned pointer type. }
  273. kCGTabletProximityEventVendorPointerSerialNumber = 34;
  274. { Key associated with an integer encoding the vendor-defined pointer serial number. }
  275. kCGTabletProximityEventVendorUniqueID = 35;
  276. { Key associated with an integer encoding the vendor-defined unique ID. }
  277. kCGTabletProximityEventCapabilityMask = 36;
  278. { Key associated with an integer encoding the device capabilities mask. }
  279. kCGTabletProximityEventPointerType = 37;
  280. { Key associated with an integer encoding the pointer type. }
  281. kCGTabletProximityEventEnterProximity = 38;
  282. { Key associated with an integer, non-zero when pen is in proximity to the tablet, and zero when leaving the tablet. }
  283. kCGEventTargetProcessSerialNumber = 39;
  284. { Key for the event target process serial number as a 64 bit longword. }
  285. kCGEventTargetUnixProcessID = 40;
  286. { Key for the event target Unix process ID }
  287. kCGEventSourceUnixProcessID = 41;
  288. { Key for the event source, or poster's Unix process ID }
  289. kCGEventSourceUserData = 42;
  290. { Key for the event source user-supplied data, up to 64 bits }
  291. kCGEventSourceUserID = 43;
  292. { Key for the event source Unix effective UID }
  293. kCGEventSourceGroupID = 44;
  294. { Key for the event source Unix effective GID }
  295. kCGEventSourceStateID = 45;
  296. { Key for the event source state ID used to create this event }
  297. type
  298. CGEventField = UInt32;
  299. { Values used with the kCGMouseEventSubtype }
  300. type
  301. _CGEventMouseSubtype = SInt32;
  302. const
  303. kCGEventMouseSubtypeDefault = 0;
  304. kCGEventMouseSubtypeTabletPoint = 1;
  305. kCGEventMouseSubtypeTabletProximity = 2;
  306. type
  307. CGEventMouseSubtype = UInt32;
  308. {
  309. * Event Taps
  310. *
  311. * Taps may be placed at the point where HIDSystem events enter
  312. * the server, at the point where HIDSystem and remote control
  313. * events enter a session, at the point where events have been
  314. * annotated to flow to a specific application, or at the point
  315. * where events are delivered to the application. Taps may be
  316. * inserted at a specified point at the head of pre-existing filters,
  317. * or appended after any pre-existing filters.
  318. *
  319. * Taps may be passive event listeners, or active filters.
  320. * An active filter may pass an event through unmodified, modify
  321. * an event, or discard an event. When a tap is registered, it
  322. * identifies the set of events to be observed with a mask, and
  323. * indicates if it is a passive or active event filter. Multiple
  324. * event type bitmasks may be ORed together.
  325. *
  326. * Taps may only be placed at kCGHIDEventTap by a process running
  327. * as the root user. NULL is returned for other users.
  328. *
  329. * Taps placed at kCGHIDEventTap, kCGSessionEventTap,
  330. * kCGAnnotatedSessionEventTap, or on a specific process may
  331. * only receive key up and down events if access for assistive
  332. * devices is enabled (Preferences Universal Access panel,
  333. * Keyboard view). If the tap is not permitted to monitor these
  334. * when the tap is being created, then the appropriate bits
  335. * in the mask are cleared. If that results in an empty mask,
  336. * then NULL is returned.
  337. *
  338. * The CGEventTapProxy is an opaque reference to state within
  339. * the client application associated with the tap. The tap
  340. * function may pass this reference to other functions, such as
  341. * the event-posting routines.
  342. *
  343. }
  344. { Possible tapping points for events }
  345. type
  346. _CGEventTapLocation = SInt32;
  347. const
  348. kCGHIDEventTap = 0;
  349. kCGSessionEventTap = 1;
  350. kCGAnnotatedSessionEventTap = 2;
  351. type
  352. CGEventTapLocation = UInt32;
  353. type
  354. _CGEventTapPlacement = SInt32;
  355. const
  356. kCGHeadInsertEventTap = 0;
  357. kCGTailAppendEventTap = 1;
  358. type
  359. CGEventTapPlacement = UInt32;
  360. type
  361. _CGEventTapOptions = SInt32;
  362. const
  363. kCGEventTapOptionListenOnly = $00000001;
  364. type
  365. CGEventTapOptions = UInt32;
  366. type
  367. CGEventMask = UInt64;
  368. {
  369. #define CGEventMaskBit(eventType) ((CGEventMask)1 << (eventType))
  370. }
  371. type
  372. CGEventTapProxy = ^SInt32; { an opaque 32-bit type }
  373. {
  374. * The callback is passed a proxy for the tap, the event type, the incoming event,
  375. * and the refcon the callback was registered with.
  376. * The function should return the (possibly modified) passed in event,
  377. * a newly constructed event, or NULL if the event is to be deleted.
  378. *
  379. * The CGEventRef passed into the callback is retained by the calling code, and is
  380. * released after the callback returns and the data is passed back to the event
  381. * system. If a different event is returned by the callback function, then that
  382. * event will be released by the calling code along with the original event, after
  383. * the event data has been passed back to the event system.
  384. }
  385. type
  386. CGEventTapCallBack = function( proxy: CGEventTapProxy; typ: CGEventType; event: CGEventRef; refcon: UnivPtr ): CGEventRef;
  387. {
  388. * When an event tap is installed or released, a notification
  389. * is posted via the notify_post() API. See notify (3) and
  390. * notify.h for details.
  391. }
  392. const
  393. kCGNotifyEventTapAdded = 'com.apple.coregraphics.eventTapAdded';
  394. const
  395. kCGNotifyEventTapRemoved = 'com.apple.coregraphics.eventTapRemoved';
  396. {
  397. * Structure used to report information on event taps
  398. }
  399. type
  400. CGEventTapInformationPtr = ^CGEventTapInformation;
  401. CGEventTapInformation = record
  402. eventTapID: UInt32;
  403. tapPoint: CGEventTapLocation; { HID, session, annotated session }
  404. options: CGEventTapOptions; { Listener, Filter }
  405. eventsOfInterest: CGEventMask; { Mask of events being tapped }
  406. tappingProcess: pid_t; { Process that is tapping events }
  407. processBeingTapped: pid_t; { Zero if not a per-process tap }
  408. enabled: CBool; { True if tap is enabled }
  409. minUsecLatency: Float32; { Minimum latency in microseconds }
  410. avgUsecLatency: Float32; { Average latency in microseconds }
  411. maxUsecLatency: Float32; { Maximum latency in microseconds }
  412. end;
  413. {
  414. * The CGEventSourceRef is an opaque representation of the source of an event.
  415. *
  416. * API is provided to obtain the CGEventSource from an event, and to create
  417. * a new event with a CGEventSourceRef.
  418. }
  419. type
  420. CGEventSourceRef = ^SInt32; { an opaque 32-bit type }
  421. type
  422. CGEventSourceStateID = UInt32;
  423. const
  424. kCGEventSourceStatePrivate = -1;
  425. kCGEventSourceStateCombinedSessionState = 0;
  426. kCGEventSourceStateHIDSystemState = 1;
  427. type
  428. CGEventSourceKeyboardType = UInt32;
  429. const
  430. kCGAnyInputEventType = $FFFFFFFF;
  431. end.