2 * Copyright (c) 1998-2000 Apple Computer, Inc. All rights reserved.
4 * @APPLE_LICENSE_HEADER_START@
6 * The contents of this file constitute Original Code as defined in and
7 * are subject to the Apple Public Source License Version 1.1 (the
8 * "License"). You may not use this file except in compliance with the
9 * License. Please obtain a copy of the License at
10 * http://www.apple.com/publicsource and read it before using this file.
12 * This Original Code and all software distributed under the License are
13 * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
14 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
15 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
16 * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the
17 * License for the specific language governing rights and limitations
20 * @APPLE_LICENSE_HEADER_END@
22 /******************************************************************************
23 event.h (PostScript side version)
26 Copyright (c) 1988 NeXT, Inc. as an unpublished work.
32 04May88 Leo Final event types and record
33 22Aug88 Leo Change short -> int for window, add reserved
34 26May90 Ted Added NX_UNDIMMASK to correct triggering of UndoAutoDim
35 12Dec91 Mike Brought into sync with dpsclient/event.h, and fixed
36 the #ifndef interlock with dpsclient/event.h that was
37 broken during the Great Header Revision.
39 The PostScript version of this file differs from the
40 Window Kit version in that the coordinates here are
41 ints instead of floats.
42 ******************************************************************************/
47 #include <libkern/OSTypes.h>
48 #include <IOKit/hidsystem/IOHIDTypes.h>
50 #ifdef EVENT_H /* Interlock with dpsclient/event.h */
51 #if !defined(_NXSIZE_) /* Work around patch for old event.h in Phase 3 projs*/
52 #define _NXSIZE_ 1 /* NXCoord, NXPoint, NXSize decl seen */
53 #define _NXSize_ NXSize
55 #else /* EVENT_H */ /* Haven't seen dpsclient/event.h, so define away */
61 #if !defined(_NXSIZE_) /* Work around patch for old event.h in Phase 3 projs*/
62 #define _NXSIZE_ 1 /* NXCoord, NXPoint, NXSize decl seen */
63 typedef float NXCoord
;
65 typedef struct _NXPoint
{ /* point */
69 typedef struct _NXSize
{ /* size */
70 NXCoord width
, height
;
72 #define _NXSize_ NXSize /* Correct usage in event_status_driver.h */
79 #define NX_NULLEVENT 0 /* internal use */
83 #define NX_LMOUSEDOWN 1 /* left mouse-down event */
84 #define NX_LMOUSEUP 2 /* left mouse-up event */
85 #define NX_RMOUSEDOWN 3 /* right mouse-down event */
86 #define NX_RMOUSEUP 4 /* right mouse-up event */
87 #define NX_MOUSEMOVED 5 /* mouse-moved event */
88 #define NX_LMOUSEDRAGGED 6 /* left mouse-dragged event */
89 #define NX_RMOUSEDRAGGED 7 /* right mouse-dragged event */
90 #define NX_MOUSEENTERED 8 /* mouse-entered event */
91 #define NX_MOUSEEXITED 9 /* mouse-exited event */
95 #define NX_KEYDOWN 10 /* key-down event */
96 #define NX_KEYUP 11 /* key-up event */
97 #define NX_FLAGSCHANGED 12 /* flags-changed event */
99 /* composite events */
101 #define NX_KITDEFINED 13 /* application-kit-defined event */
102 #define NX_SYSDEFINED 14 /* system-defined event */
103 #define NX_APPDEFINED 15 /* application-defined event */
104 /* There are additional DPS client defined events past this point. */
106 /* Scroll wheel events */
108 #define NX_SCROLLWHEELMOVED 22
112 #define NX_TABLETPOINTER 23
113 #define NX_TABLETPROXIMITY 24
115 #define NX_FIRSTEVENT 0
116 #define NX_LASTEVENT 24
117 #define NX_NUMPROCS (NX_LASTEVENT-NX_FIRSTEVENT+1)
121 #define NX_LMOUSEDOWNMASK (1 << NX_LMOUSEDOWN) /* left mouse-down */
122 #define NX_LMOUSEUPMASK (1 << NX_LMOUSEUP) /* left mouse-up */
123 #define NX_RMOUSEDOWNMASK (1 << NX_RMOUSEDOWN) /* right mouse-down */
124 #define NX_RMOUSEUPMASK (1 << NX_RMOUSEUP) /* right mouse-up */
125 #define NX_MOUSEMOVEDMASK (1 << NX_MOUSEMOVED) /* mouse-moved */
126 #define NX_LMOUSEDRAGGEDMASK (1 << NX_LMOUSEDRAGGED) /* left-dragged */
127 #define NX_RMOUSEDRAGGEDMASK (1 << NX_RMOUSEDRAGGED) /* right-dragged */
128 #define NX_MOUSEENTEREDMASK (1 << NX_MOUSEENTERED) /* mouse-entered */
129 #define NX_MOUSEEXITEDMASK (1 << NX_MOUSEEXITED) /* mouse-exited */
130 #define NX_KEYDOWNMASK (1 << NX_KEYDOWN) /* key-down */
131 #define NX_KEYUPMASK (1 << NX_KEYUP) /* key-up */
132 #define NX_FLAGSCHANGEDMASK (1 << NX_FLAGSCHANGED) /* flags-changed */
133 #define NX_KITDEFINEDMASK (1 << NX_WINCHANGED) /* kit-defined */
134 #define NX_SYSDEFINEDMASK (1 << NX_SYSDEFINED) /* system-defined */
135 #define NX_APPDEFINEDMASK (1 << NX_APPDEFINED) /* app-defined */
136 #define NX_SCROLLWHEELMOVEDMASK (1 << NX_SCROLLWHEELMOVED) /* scroll wheel moved */
137 #define NX_TABLETPOINTERMASK (1 << NX_TABLETPOINTER) /* tablet pointer moved */
138 #define NX_TABLETPROXIMITYMASK (1 << NX_TABLETPROXIMITY) /* tablet pointer proximity */
140 #define EventCodeMask(type) (1 << (type))
141 #define NX_ALLEVENTS -1 /* Check for all events */
143 /* sub types for system defined events */
145 #define NX_SUBTYPE_POWER_KEY 1
146 #define NX_SUBTYPE_AUX_MOUSE_BUTTONS 7
147 #define NX_SUBTYPE_AUX_CONTROL_BUTTONS 8
149 #define NX_SUBTYPE_EJECT_KEY 10
150 #define NX_SUBTYPE_SLEEP_EVENT 11
151 #define NX_SUBTYPE_RESTART_EVENT 12
152 #define NX_SUBTYPE_SHUTDOWN_EVENT 13
154 /* Masks for the bits in event.flags */
156 /* device-independent */
158 #define NX_ALPHASHIFTMASK 0x00010000
159 #define NX_SHIFTMASK 0x00020000
160 #define NX_CONTROLMASK 0x00040000
161 #define NX_ALTERNATEMASK 0x00080000
162 #define NX_COMMANDMASK 0x00100000
163 #define NX_NUMERICPADMASK 0x00200000
164 #define NX_HELPMASK 0x00400000
165 #define NX_SECONDARYFNMASK 0x00800000
167 /* device-dependent (really?) */
169 //#define NX_NEXTCTLKEYMASK 0x00000001
170 //#define NX_NEXTLSHIFTKEYMASK 0x00000002
171 //#define NX_NEXTRSHIFTKEYMASK 0x00000004
172 //#define NX_NEXTLCMDKEYMASK 0x00000008
173 //#define NX_NEXTRCMDKEYMASK 0x00000010
174 //#define NX_NEXTLALTKEYMASK 0x00000020
175 //#define NX_NEXTRALTKEYMASK 0x00000040
178 * Additional reserved bits in event.flags
181 #define NX_STYLUSPROXIMITYMASK 0x00000080
182 #define NX_NONCOALSESCEDMASK 0x00000100
184 /* click state values
185 * If you have the following events in close succession, the click
186 * field has the indicated value:
188 * Event Click Value Comments
189 * mouse-down 1 Not part of any click yet
190 * mouse-up 1 Aha! A click!
191 * mouse-down 2 Doing a double-click
192 * mouse-up 2 It's finished
193 * mouse-down 3 A triple
197 /* Values for the character set in event.data.key.charSet */
199 #define NX_ASCIISET 0
200 #define NX_SYMBOLSET 1
201 #define NX_DINGBATSSET 2
203 /* EventData type: defines the data field of an event */
206 struct { /* For mouse-down and mouse-up events */
207 unsigned char subx
; /* sub-pixel position for x */
208 unsigned char suby
; /* sub-pixel position for y */
209 short eventNum
; /* unique identifier for this button */
210 int click
; /* click state of this event */
211 unsigned char pressure
; /* pressure value: 0=none, 255=full */
230 struct { /* For key-down and key-up events */
231 unsigned short origCharSet
; /* unmodified character set code */
232 short repeat
; /* for key-down: nonzero if really a repeat */
233 unsigned short charSet
; /* character set code */
234 unsigned short charCode
; /* character code in that set */
235 unsigned short keyCode
; /* device-dependent key number */
236 unsigned short origCharCode
; /* unmodified character code */
238 unsigned int keyboardType
;
243 struct { /* For mouse-entered and mouse-exited events */
245 short eventNum
; /* unique identifier from mouse down event */
246 int trackingNum
; /* unique identifier from settrackingrect */
247 int userData
; /* uninterpreted integer from settrackingrect */
266 struct { /* For window-changed, sys-defined, and app-defined events */
268 short subType
; /* event subtype for compound events */
270 float F
[7]; /* for use in compound events */
271 long L
[7]; /* for use in compound events */
272 short S
[14]; /* for use in compound events */
273 char C
[28]; /* for use in compound events */
277 SInt32 x
; /* absolute x coordinate in tablet space at full tablet resolution */
278 SInt32 y
; /* absolute y coordinate in tablet space at full tablet resolution */
279 SInt32 z
; /* absolute z coordinate in tablet space at full tablet resolution */
280 UInt16 buttons
; /* one bit per button - bit 0 is first button - 1 = closed */
281 UInt16 pressure
; /* scaled pressure value; MAXPRESSURE=(2^16)-1, MINPRESSURE=0 */
283 SInt16 x
; /* scaled tilt x value; range is -((2^15)-1) to (2^15)-1 (-32767 to 32767) */
284 SInt16 y
; /* scaled tilt y value; range is -((2^15)-1) to (2^15)-1 (-32767 to 32767) */
286 UInt16 rotation
; /* Fixed-point representation of device rotation in a 10.6 format */
287 SInt16 tangentialPressure
; /* tangential pressure on the device; range same as tilt */
288 UInt16 deviceID
; /* system-assigned unique device ID - matches to deviceID field in proximity event */
289 SInt16 vendor1
; /* vendor-defined signed 16-bit integer */
290 SInt16 vendor2
; /* vendor-defined signed 16-bit integer */
291 SInt16 vendor3
; /* vendor-defined signed 16-bit integer */
294 UInt16 vendorID
; /* vendor-defined ID - typically will be USB vendor ID */
295 UInt16 tabletID
; /* vendor-defined tablet ID - typically will be USB product ID for the tablet */
296 UInt16 pointerID
; /* vendor-defined ID of the specific pointing device */
297 UInt16 deviceID
; /* system-assigned unique device ID - matches to deviceID field in tablet event */
298 UInt16 systemTabletID
; /* system-assigned unique tablet ID */
299 UInt16 vendorPointerType
; /* vendor-defined pointer type */
300 UInt32 pointerSerialNumber
; /* vendor-defined serial number of the specific pointing device */
301 UInt64 uniqueID
; /* vendor-defined unique ID for this pointer */
302 UInt32 capabilityMask
; /* mask representing the capabilities of the device */
303 UInt8 pointerType
; /* type of pointing device - enum to be defined */
304 UInt8 enterProximity
; /* non-zero = entering; zero = leaving */
309 /* Finally! The event record! */
310 typedef struct _NXEvent
{
311 int type
; /* An event type from above */
313 int x
, y
; /* Base coordinates in window, */
314 } location
; /* from bottom left */
315 unsigned long long time
; /* time since launch */
316 int flags
; /* key state flags */
317 unsigned int window
; /* window number of assigned window */
318 NXEventData data
; /* type-dependent data */
319 } NXEvent
, *NXEventPtr
;
322 /* How to pick window(s) for event (for PostEvent) */
323 #define NX_NOWINDOW -1
325 #define NX_BROADCAST 1
326 #define NX_TOPWINDOW 2
327 #define NX_FIRSTWINDOW 3
328 #define NX_MOUSEWINDOW 4
329 #define NX_NEXTWINDOW 5
330 #define NX_LASTLEFT 6
331 #define NX_LASTRIGHT 7
333 #define NX_EXPLICIT 9
334 #define NX_TRANSMIT 10
335 #define NX_BYPSCONTEXT 11
337 #endif /* EVENT_H */ /* End of defs common with dpsclient/event.h */
339 /* Mask of events that cause screen to undim */
341 #define NX_UNDIMMASK (NX_KEYDOWNMASK | NX_KEYUPMASK | \
342 NX_LMOUSEDOWNMASK | NX_LMOUSEUPMASK | \
343 NX_RMOUSEDOWNMASK | NX_RMOUSEUPMASK | \
344 NX_MOUSEMOVEDMASK | NX_FLAGSCHANGEDMASK | \
345 NX_MOUSEENTEREDMASK | NX_MOUSEEXITEDMASK | \
346 NX_LMOUSEDRAGGEDMASK | NX_RMOUSEDRAGGEDMASK | \
347 NX_SCROLLWHEELMOVEDMASK | NX_TABLETPOINTERMASK | \
348 NX_TABLETPROXIMITYMASK)
350 #endif /* !_DEV_EVENT_H */