]> git.saurik.com Git - apple/xnu.git/blob - iokit/IOKit/hidsystem/IOLLEvent.h
xnu-124.13.tar.gz
[apple/xnu.git] / iokit / IOKit / hidsystem / IOLLEvent.h
1 /*
2 * Copyright (c) 1998-2000 Apple Computer, Inc. All rights reserved.
3 *
4 * @APPLE_LICENSE_HEADER_START@
5 *
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.
11 *
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
18 * under the License.
19 *
20 * @APPLE_LICENSE_HEADER_END@
21 */
22 /******************************************************************************
23 event.h (PostScript side version)
24
25 CONFIDENTIAL
26 Copyright (c) 1988 NeXT, Inc. as an unpublished work.
27 All Rights Reserved.
28
29 Created Leo 01Mar88
30
31 Modified:
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.
38
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 ******************************************************************************/
43
44 #ifndef _DEV_EVENT_H
45 #define _DEV_EVENT_H
46
47 #include <libkern/OSTypes.h>
48 #include <IOKit/hidsystem/IOHIDTypes.h>
49
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
54 #endif /* _NXSIZE_ */
55 #else /* EVENT_H */ /* Haven't seen dpsclient/event.h, so define away */
56 #define EVENT_H
57
58 #ifdef KERNEL
59 #else /* KERNEL */
60
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;
64
65 typedef struct _NXPoint { /* point */
66 NXCoord x, y;
67 } NXPoint;
68
69 typedef struct _NXSize { /* size */
70 NXCoord width, height;
71 } NXSize;
72 #define _NXSize_ NXSize /* Correct usage in event_status_driver.h */
73 #endif /* _NXSIZE_ */
74
75 #endif /* KERNEL */
76
77 /* Event types */
78
79 #define NX_NULLEVENT 0 /* internal use */
80
81 /* mouse events */
82
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 */
92
93 /* keyboard events */
94
95 #define NX_KEYDOWN 10 /* key-down event */
96 #define NX_KEYUP 11 /* key-up event */
97 #define NX_FLAGSCHANGED 12 /* flags-changed event */
98
99 /* composite events */
100
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. */
105
106 /* Scroll wheel events */
107
108 #define NX_SCROLLWHEELMOVED 22
109
110 /* tablet events */
111
112 #define NX_TABLETPOINTER 23
113 #define NX_TABLETPROXIMITY 24
114
115 #define NX_FIRSTEVENT 0
116 #define NX_LASTEVENT 24
117 #define NX_NUMPROCS (NX_LASTEVENT-NX_FIRSTEVENT+1)
118
119 /* Event masks */
120
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 */
139
140 #define EventCodeMask(type) (1 << (type))
141 #define NX_ALLEVENTS -1 /* Check for all events */
142
143 /* sub types for system defined events */
144
145 #define NX_SUBTYPE_POWER_KEY 1
146 #define NX_SUBTYPE_AUX_MOUSE_BUTTONS 7
147 #define NX_SUBTYPE_AUX_CONTROL_BUTTONS 8
148
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
153
154 /* Masks for the bits in event.flags */
155
156 /* device-independent */
157
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
166
167 /* device-dependent (really?) */
168
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
176
177 /*
178 * Additional reserved bits in event.flags
179 */
180
181 #define NX_STYLUSPROXIMITYMASK 0x00000080
182 #define NX_NONCOALSESCEDMASK 0x00000100
183
184 /* click state values
185 * If you have the following events in close succession, the click
186 * field has the indicated value:
187 *
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
194 * mouse-up 3
195 */
196
197 /* Values for the character set in event.data.key.charSet */
198
199 #define NX_ASCIISET 0
200 #define NX_SYMBOLSET 1
201 #define NX_DINGBATSSET 2
202
203 /* EventData type: defines the data field of an event */
204
205 typedef union {
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 */
212 char reserved1;
213 short reserved2;
214 int reserved3;
215 int reserved4;
216 int reserved5;
217 int reserved6;
218 int reserved7;
219 } mouse;
220 struct {
221 int dx;
222 int dy;
223 int reserved1;
224 int reserved2;
225 int reserved3;
226 int reserved4;
227 int reserved5;
228 int reserved6;
229 } mouseMove;
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 */
237 int reserved1;
238 unsigned int keyboardType;
239 int reserved2;
240 int reserved3;
241 int reserved4;
242 } key;
243 struct { /* For mouse-entered and mouse-exited events */
244 short reserved;
245 short eventNum; /* unique identifier from mouse down event */
246 int trackingNum; /* unique identifier from settrackingrect */
247 int userData; /* uninterpreted integer from settrackingrect */
248 int reserved1;
249 int reserved2;
250 int reserved3;
251 int reserved4;
252 int reserved5;
253 } tracking;
254 struct {
255 short deltaAxis1;
256 short deltaAxis2;
257 short deltaAxis3;
258 short reserved1;
259 int reserved2;
260 int reserved3;
261 int reserved4;
262 int reserved5;
263 int reserved6;
264 int reserved7;
265 } scrollWheel;
266 struct { /* For window-changed, sys-defined, and app-defined events */
267 short reserved;
268 short subType; /* event subtype for compound events */
269 union {
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 */
274 } misc;
275 } compound;
276 struct {
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 */
282 struct {
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) */
285 } tilt;
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 */
292 } tablet;
293 struct {
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 */
305 SInt16 reserved1;
306 } proximity;
307 } NXEventData;
308
309 /* Finally! The event record! */
310 typedef struct _NXEvent {
311 int type; /* An event type from above */
312 struct {
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;
320
321
322 /* How to pick window(s) for event (for PostEvent) */
323 #define NX_NOWINDOW -1
324 #define NX_BYTYPE 0
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
332 #define NX_LASTKEY 8
333 #define NX_EXPLICIT 9
334 #define NX_TRANSMIT 10
335 #define NX_BYPSCONTEXT 11
336
337 #endif /* EVENT_H */ /* End of defs common with dpsclient/event.h */
338
339 /* Mask of events that cause screen to undim */
340
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)
349
350 #endif /* !_DEV_EVENT_H */
351