5
* Copyright (c) 2004 Apple Computer, Inc. All rights reserved.
8
{ Pascal Translation: Peter N Lewis, <peter@stairways.com.au>, August 2005 }
10
Modified for use with Free Pascal
12
Please report any bugs to <gpc@microbizz.nl>
23
{$setc UNIVERSAL_INTERFACES_VERSION := $0342}
24
{$setc GAP_INTERFACES_VERSION := $0200}
26
{$ifc not defined USE_CFSTR_CONSTANT_MACROS}
27
{$setc USE_CFSTR_CONSTANT_MACROS := TRUE}
30
{$ifc defined CPUPOWERPC and defined CPUI386}
31
{$error Conflicting initial definitions for CPUPOWERPC and CPUI386}
33
{$ifc defined FPC_BIG_ENDIAN and defined FPC_LITTLE_ENDIAN}
34
{$error Conflicting initial definitions for FPC_BIG_ENDIAN and FPC_LITTLE_ENDIAN}
37
{$ifc not defined __ppc__ and defined CPUPOWERPC}
42
{$ifc not defined __i386__ and defined CPUI386}
48
{$ifc defined __ppc__ and __ppc__ and defined __i386__ and __i386__}
49
{$error Conflicting definitions for __ppc__ and __i386__}
52
{$ifc defined __ppc__ and __ppc__}
53
{$setc TARGET_CPU_PPC := TRUE}
54
{$setc TARGET_CPU_X86 := FALSE}
55
{$elifc defined __i386__ and __i386__}
56
{$setc TARGET_CPU_PPC := FALSE}
57
{$setc TARGET_CPU_X86 := TRUE}
59
{$error Neither __ppc__ nor __i386__ is defined.}
61
{$setc TARGET_CPU_PPC_64 := FALSE}
63
{$ifc defined FPC_BIG_ENDIAN}
64
{$setc TARGET_RT_BIG_ENDIAN := TRUE}
65
{$setc TARGET_RT_LITTLE_ENDIAN := FALSE}
66
{$elifc defined FPC_LITTLE_ENDIAN}
67
{$setc TARGET_RT_BIG_ENDIAN := FALSE}
68
{$setc TARGET_RT_LITTLE_ENDIAN := TRUE}
70
{$error Neither FPC_BIG_ENDIAN nor FPC_LITTLE_ENDIAN are defined.}
72
{$setc ACCESSOR_CALLS_ARE_FUNCTIONS := TRUE}
73
{$setc CALL_NOT_IN_CARBON := FALSE}
74
{$setc OLDROUTINENAMES := FALSE}
75
{$setc OPAQUE_TOOLBOX_STRUCTS := TRUE}
76
{$setc OPAQUE_UPP_TYPES := TRUE}
77
{$setc OTCARBONAPPLICATION := TRUE}
78
{$setc OTKERNEL := FALSE}
79
{$setc PM_USE_SESSION_APIS := TRUE}
80
{$setc TARGET_API_MAC_CARBON := TRUE}
81
{$setc TARGET_API_MAC_OS8 := FALSE}
82
{$setc TARGET_API_MAC_OSX := TRUE}
83
{$setc TARGET_CARBON := TRUE}
84
{$setc TARGET_CPU_68K := FALSE}
85
{$setc TARGET_CPU_MIPS := FALSE}
86
{$setc TARGET_CPU_SPARC := FALSE}
87
{$setc TARGET_OS_MAC := TRUE}
88
{$setc TARGET_OS_UNIX := FALSE}
89
{$setc TARGET_OS_WIN32 := FALSE}
90
{$setc TARGET_RT_MAC_68881 := FALSE}
91
{$setc TARGET_RT_MAC_CFM := FALSE}
92
{$setc TARGET_RT_MAC_MACHO := TRUE}
93
{$setc TYPED_FUNCTION_POINTERS := TRUE}
94
{$setc TYPE_BOOL := FALSE}
95
{$setc TYPE_EXTENDED := FALSE}
96
{$setc TYPE_LONGLONG := TRUE}
97
uses MacTypes,MacOSXPosix,CGRemoteOperation,CGBase;
102
* The CGEventRef object may be created or copied, retained, released, and
103
* modified. The object provides an opaque representation of one low level
107
CGEventRef = ^SInt32; { an opaque 32-bit type }
110
* Types common to both CGEvent.h and CGEventSource.h
113
_CGMouseButton = SInt32;
115
kCGMouseButtonLeft = 0;
116
kCGMouseButtonRight = 1;
117
kCGMouseButtonCenter = 2;
119
CGMouseButton = UInt32;
122
* The flags field includes both modifier key state at the time the event was created,
123
* as well as other event related state.
125
* Note that any bits not specified are reserved.
128
_CGEventFlags = SInt32;
130
Uncomment when IOKit is translated
132
const { Masks for the bits in event flags }
133
{ device-independent modifier key bits }
134
kCGEventFlagMaskAlphaShift = NX_ALPHASHIFTMASK;
135
kCGEventFlagMaskShift = NX_SHIFTMASK;
136
kCGEventFlagMaskControl = NX_CONTROLMASK;
137
kCGEventFlagMaskAlternate = NX_ALTERNATEMASK;
138
kCGEventFlagMaskCommand = NX_COMMANDMASK;
140
{ Special key identifiers }
141
kCGEventFlagMaskHelp = NX_HELPMASK;
142
kCGEventFlagMaskSecondaryFn = NX_SECONDARYFNMASK;
144
{ Identifies key events from numeric keypad area on extended keyboards }
145
kCGEventFlagMaskNumericPad = NX_NUMERICPADMASK;
147
{ Indicates if mouse/pen movement events are not being coalesced }
148
kCGEventFlagMaskNonCoalesced = NX_NONCOALSESCEDMASK;
151
CGEventFlags = UInt64; { Flags for events }
156
* The following enumeration describes all event types currently presented
157
* in this API. Apple reserves the right to extend or create new event
161
* Tablet devices may generate mice events with embedded tablet
162
* data, or tablet pointer and proximity events. The tablet
163
* events as mouse events allow tablets to be used with programs
164
* which are not tablet-aware.
169
_CGEventType = SInt32;
171
Uncomment when IOKit is translated
174
kCGEventNull = NX_NULLEVENT; { Placeholder; the Null Event }
176
kCGEventLeftMouseDown = NX_LMOUSEDOWN; { left mouse-down event }
177
kCGEventLeftMouseUp = NX_LMOUSEUP; { left mouse-up event }
178
kCGEventRightMouseDown = NX_RMOUSEDOWN; { right mouse-down event }
179
kCGEventRightMouseUp = NX_RMOUSEUP; { right mouse-up event }
180
kCGEventMouseMoved = NX_MOUSEMOVED; { mouse-moved event }
181
kCGEventLeftMouseDragged = NX_LMOUSEDRAGGED; { left mouse-dragged event }
182
kCGEventRightMouseDragged = NX_RMOUSEDRAGGED; { right mouse-dragged event }
185
kCGEventKeyDown = NX_KEYDOWN; { key-down event }
186
kCGEventKeyUp = NX_KEYUP; { key-up event }
187
kCGEventFlagsChanged = NX_FLAGSCHANGED; { flags-changed (modifier keys and status) event }
189
{ Specialized control devices }
190
kCGEventScrollWheel = NX_SCROLLWHEELMOVED; { Scroll wheel input device }
191
kCGEventTabletPointer = NX_TABLETPOINTER; { specialized tablet pointer event, in addition to tablet mouse event }
192
kCGEventTabletProximity = NX_TABLETPROXIMITY; { specialized tablet proximity event, in addition to tablet mouse event }
193
kCGEventOtherMouseDown = NX_OMOUSEDOWN; { Mouse button 2-31 down }
194
kCGEventOtherMouseUp = NX_OMOUSEUP; { Mouse button 2-31 up }
195
kCGEventOtherMouseDragged = NX_OMOUSEDRAGGED; { Drag with mouse button 2-31 down }
199
* Out of band types, delivered for unusual conditions
200
* These are delivered to the event tap callback to notify of unusual
201
* conditions that disable the event tap.
204
kCGEventTapDisabledByTimeout = $FFFFFFFE;
205
kCGEventTapDisabledByUserInput = $FFFFFFFF;
207
CGEventType = UInt32;
211
CGEventTimestamp = UInt64; { Event timestamp, roughly, nanoseconds since startup }
214
* Low level functions provide access to specialized fields of the events
215
* The fields are identified by tokens defined in this enumeration.
218
_CGEventField = SInt32;
220
{ Additional keys and values found in mouse events, including the OtherMouse events: }
222
kCGMouseEventNumber = 0;
223
{ 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. }
225
kCGMouseEventClickState = 1;
226
{ 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. }
228
kCGMouseEventPressure = 2;
229
{ 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. }
231
kCGMouseEventButtonNumber = 3;
232
{ 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. }
234
kCGMouseEventDeltaX = 4;
235
kCGMouseEventDeltaY = 5;
236
{ Key associated with an integer encoding the mouse delta since the last mouse movement event. }
238
kCGMouseEventInstantMouser = 6;
239
{ Key associated with an integer value, non-zero if the event should be ignored by the Inkwell subsystem. }
241
kCGMouseEventSubtype = 7;
243
* Key associated with an integer encoding the mouse event subtype as a kCFNumberIntType.
245
* Tablets may generate specially annotated mouse events,
246
* which will contain additional keys and values.
248
* Mouse events of subtype kCGEventMouseSubtypeTabletPoint may also use the tablet accessor keys.
249
* Mouse events of subtype kCGEventMouseSubtypeTabletProximity may also use the tablet proximity accessor keys.
252
{ Additional keys and values found in keyboard events: }
254
kCGKeyboardEventAutorepeat = 8;
255
{ Key associated with an integer, non-zero when when this is an autorepeat of a key-down, and zero otherwise. }
257
kCGKeyboardEventKeycode = 9;
258
{ Key associated with the integer virtual keycode of the key-down or key-up event. }
260
kCGKeyboardEventKeyboardType = 10;
261
{ Key associated with the integer representing the keyboard type identifier. }
264
{ Additional keys and values found in scroll wheel events: }
266
kCGScrollWheelEventDeltaAxis1 = 11;
267
kCGScrollWheelEventDeltaAxis2 = 12;
268
kCGScrollWheelEventDeltaAxis3 = 13;
269
{ Key associated with an integer value representing a change in scrollwheel position. }
271
kCGScrollWheelEventInstantMouser = 14;
272
{ Key associated with an integer value, non-zero if the event should be ignored by the Inkwell subsystem. }
276
* Additional keys and values found in tablet pointer events,
277
* and in mouse events containing embedded tablet event data:
280
kCGTabletEventPointX = 15;
281
kCGTabletEventPointY = 16;
282
kCGTabletEventPointZ = 17;
283
{ Key associated with an integer encoding the absolute X, Y, or Z tablet coordinate in tablet space at full tablet resolution. }
285
kCGTabletEventPointButtons = 18;
286
{ 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. }
288
kCGTabletEventPointPressure = 19;
289
{ Key associated with a double encoding the tablet pen pressure. 0 represents no pressure, and 1.0 represents maximum pressure. }
291
kCGTabletEventTiltX = 20;
292
kCGTabletEventTiltY = 21;
293
{ Key associated with a double encoding the tablet pen tilt. 0 represents no tilt, and 1.0 represents maximum tilt. }
295
kCGTabletEventRotation = 22;
296
{ Key associated with a double encoding the tablet pen rotation. }
298
kCGTabletEventTangentialPressure = 23;
299
{ Key associated with a double encoding the tangential pressure on the device. 0 represents no pressure, and 1.0 represents maximum pressure. }
301
kCGTabletEventDeviceID = 24;
302
{ Key associated with an integer encoding the system-assigned unique device ID. }
304
kCGTabletEventVendor1 = 25;
305
kCGTabletEventVendor2 = 26;
306
kCGTabletEventVendor3 = 27;
307
{ Key associated with an integer containing vendor-specified values.}
311
* Additional keys and values found in tablet proximity events,
312
* and in mouse events containing embedded tablet proximity data:
315
kCGTabletProximityEventVendorID = 28;
316
{ Key associated with an integer encoding the vendor-defined ID, typically the USB vendor ID. }
318
kCGTabletProximityEventTabletID = 29;
319
{ Key associated with an integer encoding the vendor-defined tablet ID, typically the USB product ID. }
321
kCGTabletProximityEventPointerID = 30;
322
{ Key associated with an integer encoding the vendor-defined ID of the pointing device. }
324
kCGTabletProximityEventDeviceID = 31;
325
{ Key associated with an integer encoding the system-assigned device ID. }
327
kCGTabletProximityEventSystemTabletID = 32;
328
{ Key associated with an integer encoding the system-assigned unique tablet ID. }
330
kCGTabletProximityEventVendorPointerType = 33;
331
{ Key associated with an integer encoding the vendor-assigned pointer type. }
333
kCGTabletProximityEventVendorPointerSerialNumber = 34;
334
{ Key associated with an integer encoding the vendor-defined pointer serial number. }
336
kCGTabletProximityEventVendorUniqueID = 35;
337
{ Key associated with an integer encoding the vendor-defined unique ID. }
339
kCGTabletProximityEventCapabilityMask = 36;
340
{ Key associated with an integer encoding the device capabilities mask. }
342
kCGTabletProximityEventPointerType = 37;
343
{ Key associated with an integer encoding the pointer type. }
345
kCGTabletProximityEventEnterProximity = 38;
346
{ Key associated with an integer, non-zero when pen is in proximity to the tablet, and zero when leaving the tablet. }
348
kCGEventTargetProcessSerialNumber = 39;
349
{ Key for the event target process serial number as a 64 bit longword. }
351
kCGEventTargetUnixProcessID = 40;
352
{ Key for the event target Unix process ID }
354
kCGEventSourceUnixProcessID = 41;
355
{ Key for the event source, or poster's Unix process ID }
357
kCGEventSourceUserData = 42;
358
{ Key for the event source user-supplied data, up to 64 bits }
360
kCGEventSourceUserID = 43;
361
{ Key for the event source Unix effective UID }
363
kCGEventSourceGroupID = 44;
364
{ Key for the event source Unix effective GID }
366
kCGEventSourceStateID = 45;
367
{ Key for the event source state ID used to create this event }
369
CGEventField = UInt32;
371
{ Values used with the kCGMouseEventSubtype }
373
_CGEventMouseSubtype = SInt32;
375
kCGEventMouseSubtypeDefault = 0;
376
kCGEventMouseSubtypeTabletPoint = 1;
377
kCGEventMouseSubtypeTabletProximity = 2;
379
CGEventMouseSubtype = UInt32;
384
* Taps may be placed at the point where HIDSystem events enter
385
* the server, at the point where HIDSystem and remote control
386
* events enter a session, at the point where events have been
387
* annotated to flow to a specific application, or at the point
388
* where events are delivered to the application. Taps may be
389
* inserted at a specified point at the head of pre-existing filters,
390
* or appended after any pre-existing filters.
392
* Taps may be passive event listeners, or active filters.
393
* An active filter may pass an event through unmodified, modify
394
* an event, or discard an event. When a tap is registered, it
395
* identifies the set of events to be observed with a mask, and
396
* indicates if it is a passive or active event filter. Multiple
397
* event type bitmasks may be ORed together.
399
* Taps may only be placed at kCGHIDEventTap by a process running
400
* as the root user. NULL is returned for other users.
402
* Taps placed at kCGHIDEventTap, kCGSessionEventTap,
403
* kCGAnnotatedSessionEventTap, or on a specific process may
404
* only receive key up and down events if access for assistive
405
* devices is enabled (Preferences Universal Access panel,
406
* Keyboard view). If the tap is not permitted to monitor these
407
* when the tap is being created, then the appropriate bits
408
* in the mask are cleared. If that results in an empty mask,
409
* then NULL is returned.
411
* The CGEventTapProxy is an opaque reference to state within
412
* the client application associated with the tap. The tap
413
* function may pass this reference to other functions, such as
414
* the event-posting routines.
417
{ Possible tapping points for events }
419
_CGEventTapLocation = SInt32;
422
kCGSessionEventTap = 1;
423
kCGAnnotatedSessionEventTap = 2;
425
CGEventTapLocation = UInt32;
428
_CGEventTapPlacement = SInt32;
430
kCGHeadInsertEventTap = 0;
431
kCGTailAppendEventTap = 1;
433
CGEventTapPlacement = UInt32;
436
_CGEventTapOptions = SInt32;
438
kCGEventTapOptionListenOnly = $00000001;
440
CGEventTapOptions = UInt32;
444
CGEventMask = UInt64;
446
#define CGEventMaskBit(eventType) ((CGEventMask)1 << (eventType))
450
CGEventTapProxy = ^SInt32; { an opaque 32-bit type }
453
* The callback is passed a proxy for the tap, the event type, the incoming event,
454
* and the refcon the callback was registered with.
455
* The function should return the (possibly modified) passed in event,
456
* a newly constructed event, or NULL if the event is to be deleted.
458
* The CGEventRef passed into the callback is retained by the calling code, and is
459
* released after the callback returns and the data is passed back to the event
460
* system. If a different event is returned by the callback function, then that
461
* event will be released by the calling code along with the original event, after
462
* the event data has been passed back to the event system.
465
CGEventTapCallBack = function( proxy: CGEventTapProxy; typ: CGEventType; event: CGEventRef; refcon: UnivPtr ): CGEventRef;
469
* When an event tap is installed or released, a notification
470
* is posted via the notify_post() API. See notify (3) and
471
* notify.h for details.
474
kCGNotifyEventTapAdded = 'com.apple.coregraphics.eventTapAdded';
476
kCGNotifyEventTapRemoved = 'com.apple.coregraphics.eventTapRemoved';
479
* Structure used to report information on event taps
482
CGEventTapInformationPtr = ^CGEventTapInformation;
483
CGEventTapInformation = record
485
tapPoint: CGEventTapLocation; { HID, session, annotated session }
486
options: CGEventTapOptions; { Listener, Filter }
487
eventsOfInterest: CGEventMask; { Mask of events being tapped }
488
tappingProcess: pid_t; { Process that is tapping events }
489
processBeingTapped: pid_t; { Zero if not a per-process tap }
490
enabled: CBool; { True if tap is enabled }
491
minUsecLatency: Float32; { Minimum latency in microseconds }
492
avgUsecLatency: Float32; { Average latency in microseconds }
493
maxUsecLatency: Float32; { Maximum latency in microseconds }
498
* The CGEventSourceRef is an opaque representation of the source of an event.
500
* API is provided to obtain the CGEventSource from an event, and to create
501
* a new event with a CGEventSourceRef.
504
CGEventSourceRef = ^SInt32; { an opaque 32-bit type }
507
CGEventSourceStateID = UInt32;
509
kCGEventSourceStatePrivate = -1;
510
kCGEventSourceStateCombinedSessionState = 0;
511
kCGEventSourceStateHIDSystemState = 1;
514
CGEventSourceKeyboardType = UInt32;
517
kCGAnyInputEventType = $FFFFFFFF;