Mercurial > sdl-ios-xcode
annotate docs/html/sdlevent.html @ 340:b9f1ce709960
Fixed a minor memory leak in the SDL thread subsystem
author | Sam Lantinga <slouken@libsdl.org> |
---|---|
date | Thu, 11 Apr 2002 21:08:44 +0000 |
parents | e5bc29de3f0a |
children | 355632dca928 |
rev | line source |
---|---|
0 | 1 <HTML |
2 ><HEAD | |
3 ><TITLE | |
4 >SDL_Event</TITLE | |
5 ><META | |
6 NAME="GENERATOR" | |
55
55f1f1b3e27d
Added new docs for SDL 1.2.1
Sam Lantinga <slouken@lokigames.com>
parents:
0
diff
changeset
|
7 CONTENT="Modular DocBook HTML Stylesheet Version 1.64 |
0 | 8 "><LINK |
9 REL="HOME" | |
10 TITLE="SDL Library Documentation" | |
11 HREF="index.html"><LINK | |
12 REL="UP" | |
13 TITLE="SDL Event Structures." | |
14 HREF="eventstructures.html"><LINK | |
15 REL="PREVIOUS" | |
16 TITLE="SDL Event Structures." | |
17 HREF="eventstructures.html"><LINK | |
18 REL="NEXT" | |
19 TITLE="SDL_ActiveEvent" | |
20 HREF="sdlactiveevent.html"></HEAD | |
21 ><BODY | |
22 CLASS="REFENTRY" | |
23 BGCOLOR="#FFF8DC" | |
24 TEXT="#000000" | |
25 LINK="#0000ee" | |
26 VLINK="#551a8b" | |
27 ALINK="#ff0000" | |
28 ><DIV | |
29 CLASS="NAVHEADER" | |
30 ><TABLE | |
31 WIDTH="100%" | |
32 BORDER="0" | |
33 CELLPADDING="0" | |
34 CELLSPACING="0" | |
35 ><TR | |
36 ><TH | |
37 COLSPAN="3" | |
38 ALIGN="center" | |
39 >SDL Library Documentation</TH | |
40 ></TR | |
41 ><TR | |
42 ><TD | |
43 WIDTH="10%" | |
44 ALIGN="left" | |
45 VALIGN="bottom" | |
46 ><A | |
47 HREF="eventstructures.html" | |
48 >Prev</A | |
49 ></TD | |
50 ><TD | |
51 WIDTH="80%" | |
52 ALIGN="center" | |
53 VALIGN="bottom" | |
54 ></TD | |
55 ><TD | |
56 WIDTH="10%" | |
57 ALIGN="right" | |
58 VALIGN="bottom" | |
59 ><A | |
60 HREF="sdlactiveevent.html" | |
61 >Next</A | |
62 ></TD | |
63 ></TR | |
64 ></TABLE | |
65 ><HR | |
66 ALIGN="LEFT" | |
67 WIDTH="100%"></DIV | |
68 ><H1 | |
69 ><A | |
70 NAME="SDLEVENT" | |
71 >SDL_Event</A | |
72 ></H1 | |
73 ><DIV | |
74 CLASS="REFNAMEDIV" | |
75 ><A | |
181
e5bc29de3f0a
Updated from the SDL Documentation Project
Sam Lantinga <slouken@libsdl.org>
parents:
55
diff
changeset
|
76 NAME="AEN3327" |
0 | 77 ></A |
78 ><H2 | |
79 >Name</H2 | |
80 >SDL_Event -- General event structure</DIV | |
81 ><DIV | |
82 CLASS="REFSECT1" | |
83 ><A | |
181
e5bc29de3f0a
Updated from the SDL Documentation Project
Sam Lantinga <slouken@libsdl.org>
parents:
55
diff
changeset
|
84 NAME="AEN3330" |
0 | 85 ></A |
86 ><H2 | |
87 >Structure Definition</H2 | |
88 ><PRE | |
89 CLASS="PROGRAMLISTING" | |
90 >typedef union{ | |
91 Uint8 type; | |
92 SDL_ActiveEvent active; | |
93 SDL_KeyboardEvent key; | |
94 SDL_MouseMotionEvent motion; | |
95 SDL_MouseButtonEvent button; | |
96 SDL_JoyAxisEvent jaxis; | |
97 SDL_JoyBallEvent jball; | |
98 SDL_JoyHatEvent jhat; | |
99 SDL_JoyButtonEvent jbutton; | |
100 SDL_ResizeEvent resize; | |
181
e5bc29de3f0a
Updated from the SDL Documentation Project
Sam Lantinga <slouken@libsdl.org>
parents:
55
diff
changeset
|
101 SDL_ExposeEvent expose; |
0 | 102 SDL_QuitEvent quit; |
103 SDL_UserEvent user; | |
104 SDL_SywWMEvent syswm; | |
105 } SDL_Event;</PRE | |
106 ></DIV | |
107 ><DIV | |
108 CLASS="REFSECT1" | |
109 ><A | |
181
e5bc29de3f0a
Updated from the SDL Documentation Project
Sam Lantinga <slouken@libsdl.org>
parents:
55
diff
changeset
|
110 NAME="AEN3333" |
0 | 111 ></A |
112 ><H2 | |
113 >Structure Data</H2 | |
114 ><DIV | |
115 CLASS="INFORMALTABLE" | |
116 ><A | |
181
e5bc29de3f0a
Updated from the SDL Documentation Project
Sam Lantinga <slouken@libsdl.org>
parents:
55
diff
changeset
|
117 NAME="AEN3335" |
0 | 118 ></A |
119 ><P | |
120 ></P | |
121 ><TABLE | |
122 BORDER="0" | |
123 CLASS="CALSTABLE" | |
124 ><TBODY | |
125 ><TR | |
126 ><TD | |
127 ALIGN="LEFT" | |
128 VALIGN="TOP" | |
129 ><TT | |
130 CLASS="STRUCTFIELD" | |
131 ><I | |
132 >type</I | |
133 ></TT | |
134 ></TD | |
135 ><TD | |
136 ALIGN="LEFT" | |
137 VALIGN="TOP" | |
138 >The type of event</TD | |
139 ></TR | |
140 ><TR | |
141 ><TD | |
142 ALIGN="LEFT" | |
143 VALIGN="TOP" | |
144 ><TT | |
145 CLASS="STRUCTFIELD" | |
146 ><I | |
147 >active</I | |
148 ></TT | |
149 ></TD | |
150 ><TD | |
151 ALIGN="LEFT" | |
152 VALIGN="TOP" | |
153 ><A | |
154 HREF="sdlactiveevent.html" | |
155 >Activation event</A | |
156 ></TD | |
157 ></TR | |
158 ><TR | |
159 ><TD | |
160 ALIGN="LEFT" | |
161 VALIGN="TOP" | |
162 ><TT | |
163 CLASS="STRUCTFIELD" | |
164 ><I | |
165 >key</I | |
166 ></TT | |
167 ></TD | |
168 ><TD | |
169 ALIGN="LEFT" | |
170 VALIGN="TOP" | |
171 ><A | |
172 HREF="sdlkeyboardevent.html" | |
173 >Keyboard event</A | |
174 ></TD | |
175 ></TR | |
176 ><TR | |
177 ><TD | |
178 ALIGN="LEFT" | |
179 VALIGN="TOP" | |
180 ><TT | |
181 CLASS="STRUCTFIELD" | |
182 ><I | |
183 >motion</I | |
184 ></TT | |
185 ></TD | |
186 ><TD | |
187 ALIGN="LEFT" | |
188 VALIGN="TOP" | |
189 ><A | |
190 HREF="sdlmousemotionevent.html" | |
191 >Mouse motion event</A | |
192 ></TD | |
193 ></TR | |
194 ><TR | |
195 ><TD | |
196 ALIGN="LEFT" | |
197 VALIGN="TOP" | |
198 ><TT | |
199 CLASS="STRUCTFIELD" | |
200 ><I | |
201 >button</I | |
202 ></TT | |
203 ></TD | |
204 ><TD | |
205 ALIGN="LEFT" | |
206 VALIGN="TOP" | |
207 ><A | |
208 HREF="sdlmousebuttonevent.html" | |
209 >Mouse button event</A | |
210 ></TD | |
211 ></TR | |
212 ><TR | |
213 ><TD | |
214 ALIGN="LEFT" | |
215 VALIGN="TOP" | |
216 ><TT | |
217 CLASS="STRUCTFIELD" | |
218 ><I | |
219 >jaxis</I | |
220 ></TT | |
221 ></TD | |
222 ><TD | |
223 ALIGN="LEFT" | |
224 VALIGN="TOP" | |
225 ><A | |
226 HREF="sdljoyaxisevent.html" | |
227 >Joystick axis motion event</A | |
228 ></TD | |
229 ></TR | |
230 ><TR | |
231 ><TD | |
232 ALIGN="LEFT" | |
233 VALIGN="TOP" | |
234 ><TT | |
235 CLASS="STRUCTFIELD" | |
236 ><I | |
237 >jball</I | |
238 ></TT | |
239 ></TD | |
240 ><TD | |
241 ALIGN="LEFT" | |
242 VALIGN="TOP" | |
243 ><A | |
244 HREF="sdljoyballevent.html" | |
245 >Joystick trackball motion event</A | |
246 ></TD | |
247 ></TR | |
248 ><TR | |
249 ><TD | |
250 ALIGN="LEFT" | |
251 VALIGN="TOP" | |
252 ><TT | |
253 CLASS="STRUCTFIELD" | |
254 ><I | |
255 >jhat</I | |
256 ></TT | |
257 ></TD | |
258 ><TD | |
259 ALIGN="LEFT" | |
260 VALIGN="TOP" | |
261 ><A | |
262 HREF="sdljoyhatevent.html" | |
263 >Joystick hat motion event</A | |
264 ></TD | |
265 ></TR | |
266 ><TR | |
267 ><TD | |
268 ALIGN="LEFT" | |
269 VALIGN="TOP" | |
270 ><TT | |
271 CLASS="STRUCTFIELD" | |
272 ><I | |
273 >jbutton</I | |
274 ></TT | |
275 ></TD | |
276 ><TD | |
277 ALIGN="LEFT" | |
278 VALIGN="TOP" | |
279 ><A | |
280 HREF="sdljoybuttonevent.html" | |
281 >Joystick button event</A | |
282 ></TD | |
283 ></TR | |
284 ><TR | |
285 ><TD | |
286 ALIGN="LEFT" | |
287 VALIGN="TOP" | |
288 ><TT | |
289 CLASS="STRUCTFIELD" | |
290 ><I | |
291 >resize</I | |
292 ></TT | |
293 ></TD | |
294 ><TD | |
295 ALIGN="LEFT" | |
296 VALIGN="TOP" | |
297 ><A | |
298 HREF="sdlresizeevent.html" | |
299 >Application window resize event</A | |
300 ></TD | |
301 ></TR | |
302 ><TR | |
303 ><TD | |
304 ALIGN="LEFT" | |
305 VALIGN="TOP" | |
306 ><TT | |
307 CLASS="STRUCTFIELD" | |
308 ><I | |
181
e5bc29de3f0a
Updated from the SDL Documentation Project
Sam Lantinga <slouken@libsdl.org>
parents:
55
diff
changeset
|
309 >expose</I |
e5bc29de3f0a
Updated from the SDL Documentation Project
Sam Lantinga <slouken@libsdl.org>
parents:
55
diff
changeset
|
310 ></TT |
e5bc29de3f0a
Updated from the SDL Documentation Project
Sam Lantinga <slouken@libsdl.org>
parents:
55
diff
changeset
|
311 ></TD |
e5bc29de3f0a
Updated from the SDL Documentation Project
Sam Lantinga <slouken@libsdl.org>
parents:
55
diff
changeset
|
312 ><TD |
e5bc29de3f0a
Updated from the SDL Documentation Project
Sam Lantinga <slouken@libsdl.org>
parents:
55
diff
changeset
|
313 ALIGN="LEFT" |
e5bc29de3f0a
Updated from the SDL Documentation Project
Sam Lantinga <slouken@libsdl.org>
parents:
55
diff
changeset
|
314 VALIGN="TOP" |
e5bc29de3f0a
Updated from the SDL Documentation Project
Sam Lantinga <slouken@libsdl.org>
parents:
55
diff
changeset
|
315 ><A |
e5bc29de3f0a
Updated from the SDL Documentation Project
Sam Lantinga <slouken@libsdl.org>
parents:
55
diff
changeset
|
316 HREF="sdlexposeevent.html" |
e5bc29de3f0a
Updated from the SDL Documentation Project
Sam Lantinga <slouken@libsdl.org>
parents:
55
diff
changeset
|
317 >Application window expose event</A |
e5bc29de3f0a
Updated from the SDL Documentation Project
Sam Lantinga <slouken@libsdl.org>
parents:
55
diff
changeset
|
318 ></TD |
e5bc29de3f0a
Updated from the SDL Documentation Project
Sam Lantinga <slouken@libsdl.org>
parents:
55
diff
changeset
|
319 ></TR |
e5bc29de3f0a
Updated from the SDL Documentation Project
Sam Lantinga <slouken@libsdl.org>
parents:
55
diff
changeset
|
320 ><TR |
e5bc29de3f0a
Updated from the SDL Documentation Project
Sam Lantinga <slouken@libsdl.org>
parents:
55
diff
changeset
|
321 ><TD |
e5bc29de3f0a
Updated from the SDL Documentation Project
Sam Lantinga <slouken@libsdl.org>
parents:
55
diff
changeset
|
322 ALIGN="LEFT" |
e5bc29de3f0a
Updated from the SDL Documentation Project
Sam Lantinga <slouken@libsdl.org>
parents:
55
diff
changeset
|
323 VALIGN="TOP" |
e5bc29de3f0a
Updated from the SDL Documentation Project
Sam Lantinga <slouken@libsdl.org>
parents:
55
diff
changeset
|
324 ><TT |
e5bc29de3f0a
Updated from the SDL Documentation Project
Sam Lantinga <slouken@libsdl.org>
parents:
55
diff
changeset
|
325 CLASS="STRUCTFIELD" |
e5bc29de3f0a
Updated from the SDL Documentation Project
Sam Lantinga <slouken@libsdl.org>
parents:
55
diff
changeset
|
326 ><I |
0 | 327 >quit</I |
328 ></TT | |
329 ></TD | |
330 ><TD | |
331 ALIGN="LEFT" | |
332 VALIGN="TOP" | |
333 ><A | |
334 HREF="sdlquitevent.html" | |
335 >Application quit request event</A | |
336 ></TD | |
337 ></TR | |
338 ><TR | |
339 ><TD | |
340 ALIGN="LEFT" | |
341 VALIGN="TOP" | |
342 ><TT | |
343 CLASS="STRUCTFIELD" | |
344 ><I | |
345 >user</I | |
346 ></TT | |
347 ></TD | |
348 ><TD | |
349 ALIGN="LEFT" | |
350 VALIGN="TOP" | |
351 ><A | |
352 HREF="sdluserevent.html" | |
353 >User defined event</A | |
354 ></TD | |
355 ></TR | |
356 ><TR | |
357 ><TD | |
358 ALIGN="LEFT" | |
359 VALIGN="TOP" | |
360 ><TT | |
361 CLASS="STRUCTFIELD" | |
362 ><I | |
363 >syswm</I | |
364 ></TT | |
365 ></TD | |
366 ><TD | |
367 ALIGN="LEFT" | |
368 VALIGN="TOP" | |
369 ><A | |
370 HREF="sdlsyswmevent.html" | |
371 >Undefined window manager event</A | |
372 ></TD | |
373 ></TR | |
374 ></TBODY | |
375 ></TABLE | |
376 ><P | |
377 ></P | |
378 ></DIV | |
379 ></DIV | |
380 ><DIV | |
381 CLASS="REFSECT1" | |
382 ><A | |
181
e5bc29de3f0a
Updated from the SDL Documentation Project
Sam Lantinga <slouken@libsdl.org>
parents:
55
diff
changeset
|
383 NAME="AEN3407" |
0 | 384 ></A |
385 ><H2 | |
386 >Description</H2 | |
387 ><P | |
388 >The <SPAN | |
389 CLASS="STRUCTNAME" | |
390 >SDL_Event</SPAN | |
391 > union is the core to all event handling is SDL, its probably the most important structure after <SPAN | |
392 CLASS="STRUCTNAME" | |
393 >SDL_Surface</SPAN | |
394 >. <SPAN | |
395 CLASS="STRUCTNAME" | |
396 >SDL_Event</SPAN | |
397 > is a union of all event structures used in SDL, using it is a simple matter of knowing which union member relates to which event <TT | |
398 CLASS="STRUCTFIELD" | |
399 ><I | |
400 >type</I | |
401 ></TT | |
402 >.</P | |
403 ><P | |
404 ><DIV | |
405 CLASS="INFORMALTABLE" | |
406 ><A | |
181
e5bc29de3f0a
Updated from the SDL Documentation Project
Sam Lantinga <slouken@libsdl.org>
parents:
55
diff
changeset
|
407 NAME="AEN3415" |
0 | 408 ></A |
409 ><P | |
410 ></P | |
411 ><TABLE | |
412 BORDER="1" | |
413 CLASS="CALSTABLE" | |
414 ><THEAD | |
415 ><TR | |
416 ><TH | |
417 ALIGN="LEFT" | |
418 VALIGN="TOP" | |
419 >Event <TT | |
420 CLASS="STRUCTFIELD" | |
421 ><I | |
422 >type</I | |
423 ></TT | |
424 ></TH | |
425 ><TH | |
426 ALIGN="LEFT" | |
427 VALIGN="TOP" | |
428 >Event Structure</TH | |
429 ></TR | |
430 ></THEAD | |
431 ><TBODY | |
432 ><TR | |
433 ><TD | |
434 ALIGN="LEFT" | |
435 VALIGN="MIDDLE" | |
436 ><TT | |
437 CLASS="LITERAL" | |
438 >SDL_ACTIVEEVENT</TT | |
439 ></TD | |
440 ><TD | |
441 ALIGN="LEFT" | |
442 VALIGN="MIDDLE" | |
443 ><A | |
444 HREF="sdlactiveevent.html" | |
445 ><SPAN | |
446 CLASS="STRUCTNAME" | |
447 >SDL_ActiveEvent</SPAN | |
448 ></A | |
449 ></TD | |
450 ></TR | |
451 ><TR | |
452 ><TD | |
453 ALIGN="LEFT" | |
454 VALIGN="TOP" | |
455 ><TT | |
456 CLASS="LITERAL" | |
457 >SDL_KEYDOWN/UP</TT | |
458 ></TD | |
459 ><TD | |
460 ALIGN="LEFT" | |
461 VALIGN="TOP" | |
462 ><A | |
463 HREF="sdlkeyboardevent.html" | |
464 ><SPAN | |
465 CLASS="STRUCTNAME" | |
466 >SDL_KeyboardEvent</SPAN | |
467 ></A | |
468 ></TD | |
469 ></TR | |
470 ><TR | |
471 ><TD | |
472 ALIGN="LEFT" | |
473 VALIGN="TOP" | |
474 ><TT | |
475 CLASS="LITERAL" | |
476 >SDL_MOUSEMOTION</TT | |
477 ></TD | |
478 ><TD | |
479 ALIGN="LEFT" | |
480 VALIGN="TOP" | |
481 ><A | |
482 HREF="sdlmousemotionevent.html" | |
483 ><SPAN | |
484 CLASS="STRUCTNAME" | |
485 >SDL_MouseMotionEvent</SPAN | |
486 ></A | |
487 ></TD | |
488 ></TR | |
489 ><TR | |
490 ><TD | |
491 ALIGN="LEFT" | |
492 VALIGN="TOP" | |
493 ><TT | |
494 CLASS="LITERAL" | |
495 >SDL_MOUSEBUTTONDOWN/UP</TT | |
496 ></TD | |
497 ><TD | |
498 ALIGN="LEFT" | |
499 VALIGN="TOP" | |
500 ><A | |
501 HREF="sdlmousebuttonevent.html" | |
502 ><SPAN | |
503 CLASS="STRUCTNAME" | |
504 >SDL_MouseButtonEvent</SPAN | |
505 ></A | |
506 ></TD | |
507 ></TR | |
508 ><TR | |
509 ><TD | |
510 ALIGN="LEFT" | |
511 VALIGN="TOP" | |
512 ><TT | |
513 CLASS="LITERAL" | |
514 >SDL_JOYAXISMOTION</TT | |
515 ></TD | |
516 ><TD | |
517 ALIGN="LEFT" | |
518 VALIGN="TOP" | |
519 ><A | |
520 HREF="sdljoyaxisevent.html" | |
521 ><SPAN | |
522 CLASS="STRUCTNAME" | |
523 >SDL_JoyAxisEvent</SPAN | |
524 ></A | |
525 ></TD | |
526 ></TR | |
527 ><TR | |
528 ><TD | |
529 ALIGN="LEFT" | |
530 VALIGN="TOP" | |
531 ><TT | |
532 CLASS="LITERAL" | |
533 >SDL_JOYBALLMOTION</TT | |
534 ></TD | |
535 ><TD | |
536 ALIGN="LEFT" | |
537 VALIGN="TOP" | |
538 ><A | |
539 HREF="sdljoyballevent.html" | |
540 ><SPAN | |
541 CLASS="STRUCTNAME" | |
542 >SDL_JoyBallEvent</SPAN | |
543 ></A | |
544 ></TD | |
545 ></TR | |
546 ><TR | |
547 ><TD | |
548 ALIGN="LEFT" | |
549 VALIGN="TOP" | |
550 ><TT | |
551 CLASS="LITERAL" | |
552 >SDL_JOYHATMOTION</TT | |
553 ></TD | |
554 ><TD | |
555 ALIGN="LEFT" | |
556 VALIGN="TOP" | |
557 ><A | |
558 HREF="sdljoyhatevent.html" | |
559 ><SPAN | |
560 CLASS="STRUCTNAME" | |
561 >SDL_JoyHatEvent</SPAN | |
562 ></A | |
563 ></TD | |
564 ></TR | |
565 ><TR | |
566 ><TD | |
567 ALIGN="LEFT" | |
568 VALIGN="TOP" | |
569 ><TT | |
570 CLASS="LITERAL" | |
571 >SDL_JOYBUTTONDOWN/UP</TT | |
572 ></TD | |
573 ><TD | |
574 ALIGN="LEFT" | |
575 VALIGN="TOP" | |
576 ><A | |
577 HREF="sdljoybuttonevent.html" | |
578 ><SPAN | |
579 CLASS="STRUCTNAME" | |
580 >SDL_JoyButtonEvent</SPAN | |
581 ></A | |
582 ></TD | |
583 ></TR | |
584 ><TR | |
585 ><TD | |
586 ALIGN="LEFT" | |
587 VALIGN="TOP" | |
588 ><TT | |
589 CLASS="LITERAL" | |
590 >SDL_QUIT</TT | |
591 ></TD | |
592 ><TD | |
593 ALIGN="LEFT" | |
594 VALIGN="TOP" | |
595 ><A | |
596 HREF="sdlquitevent.html" | |
597 ><SPAN | |
598 CLASS="STRUCTNAME" | |
599 >SDL_QuitEvent</SPAN | |
600 ></A | |
601 ></TD | |
602 ></TR | |
603 ><TR | |
604 ><TD | |
605 ALIGN="LEFT" | |
606 VALIGN="TOP" | |
607 ><TT | |
608 CLASS="LITERAL" | |
609 >SDL_SYSWMEVENT</TT | |
610 ></TD | |
611 ><TD | |
612 ALIGN="LEFT" | |
613 VALIGN="TOP" | |
614 ><A | |
615 HREF="sdlsyswmevent.html" | |
616 ><SPAN | |
617 CLASS="STRUCTNAME" | |
618 >SDL_SysWMEvent</SPAN | |
619 ></A | |
620 ></TD | |
621 ></TR | |
622 ><TR | |
623 ><TD | |
624 ALIGN="LEFT" | |
625 VALIGN="TOP" | |
626 ><TT | |
627 CLASS="LITERAL" | |
628 >SDL_VIDEORESIZE</TT | |
629 ></TD | |
630 ><TD | |
631 ALIGN="LEFT" | |
632 VALIGN="TOP" | |
633 ><A | |
634 HREF="sdlresizeevent.html" | |
635 ><SPAN | |
636 CLASS="STRUCTNAME" | |
637 >SDL_ResizeEvent</SPAN | |
638 ></A | |
639 ></TD | |
640 ></TR | |
641 ><TR | |
642 ><TD | |
643 ALIGN="LEFT" | |
644 VALIGN="TOP" | |
645 ><TT | |
646 CLASS="LITERAL" | |
181
e5bc29de3f0a
Updated from the SDL Documentation Project
Sam Lantinga <slouken@libsdl.org>
parents:
55
diff
changeset
|
647 >SDL_VIDEOEXPOSE</TT |
e5bc29de3f0a
Updated from the SDL Documentation Project
Sam Lantinga <slouken@libsdl.org>
parents:
55
diff
changeset
|
648 ></TD |
e5bc29de3f0a
Updated from the SDL Documentation Project
Sam Lantinga <slouken@libsdl.org>
parents:
55
diff
changeset
|
649 ><TD |
e5bc29de3f0a
Updated from the SDL Documentation Project
Sam Lantinga <slouken@libsdl.org>
parents:
55
diff
changeset
|
650 ALIGN="LEFT" |
e5bc29de3f0a
Updated from the SDL Documentation Project
Sam Lantinga <slouken@libsdl.org>
parents:
55
diff
changeset
|
651 VALIGN="TOP" |
e5bc29de3f0a
Updated from the SDL Documentation Project
Sam Lantinga <slouken@libsdl.org>
parents:
55
diff
changeset
|
652 ><A |
e5bc29de3f0a
Updated from the SDL Documentation Project
Sam Lantinga <slouken@libsdl.org>
parents:
55
diff
changeset
|
653 HREF="sdlexposeevent.html" |
e5bc29de3f0a
Updated from the SDL Documentation Project
Sam Lantinga <slouken@libsdl.org>
parents:
55
diff
changeset
|
654 ><SPAN |
e5bc29de3f0a
Updated from the SDL Documentation Project
Sam Lantinga <slouken@libsdl.org>
parents:
55
diff
changeset
|
655 CLASS="STRUCTNAME" |
e5bc29de3f0a
Updated from the SDL Documentation Project
Sam Lantinga <slouken@libsdl.org>
parents:
55
diff
changeset
|
656 >SDL_ExposeEvent</SPAN |
e5bc29de3f0a
Updated from the SDL Documentation Project
Sam Lantinga <slouken@libsdl.org>
parents:
55
diff
changeset
|
657 ></A |
e5bc29de3f0a
Updated from the SDL Documentation Project
Sam Lantinga <slouken@libsdl.org>
parents:
55
diff
changeset
|
658 ></TD |
e5bc29de3f0a
Updated from the SDL Documentation Project
Sam Lantinga <slouken@libsdl.org>
parents:
55
diff
changeset
|
659 ></TR |
e5bc29de3f0a
Updated from the SDL Documentation Project
Sam Lantinga <slouken@libsdl.org>
parents:
55
diff
changeset
|
660 ><TR |
e5bc29de3f0a
Updated from the SDL Documentation Project
Sam Lantinga <slouken@libsdl.org>
parents:
55
diff
changeset
|
661 ><TD |
e5bc29de3f0a
Updated from the SDL Documentation Project
Sam Lantinga <slouken@libsdl.org>
parents:
55
diff
changeset
|
662 ALIGN="LEFT" |
e5bc29de3f0a
Updated from the SDL Documentation Project
Sam Lantinga <slouken@libsdl.org>
parents:
55
diff
changeset
|
663 VALIGN="TOP" |
e5bc29de3f0a
Updated from the SDL Documentation Project
Sam Lantinga <slouken@libsdl.org>
parents:
55
diff
changeset
|
664 ><TT |
e5bc29de3f0a
Updated from the SDL Documentation Project
Sam Lantinga <slouken@libsdl.org>
parents:
55
diff
changeset
|
665 CLASS="LITERAL" |
0 | 666 >SDL_USEREVENT</TT |
667 ></TD | |
668 ><TD | |
669 ALIGN="LEFT" | |
670 VALIGN="TOP" | |
671 ><A | |
672 HREF="sdluserevent.html" | |
673 ><SPAN | |
674 CLASS="STRUCTNAME" | |
675 >SDL_UserEvent</SPAN | |
676 ></A | |
677 ></TD | |
678 ></TR | |
679 ></TBODY | |
680 ></TABLE | |
681 ><P | |
682 ></P | |
683 ></DIV | |
684 ></P | |
685 ></DIV | |
686 ><DIV | |
687 CLASS="REFSECT1" | |
688 ><A | |
181
e5bc29de3f0a
Updated from the SDL Documentation Project
Sam Lantinga <slouken@libsdl.org>
parents:
55
diff
changeset
|
689 NAME="AEN3501" |
0 | 690 ></A |
691 ><H2 | |
692 >Use</H2 | |
693 ><P | |
694 >The <SPAN | |
695 CLASS="STRUCTNAME" | |
696 >SDL_Event</SPAN | |
697 > structure has two uses</P | |
698 ><P | |
699 ></P | |
700 ><UL | |
701 COMPACT="COMPACT" | |
702 ><LI | |
703 ><P | |
704 >Reading events on the event queue</P | |
705 ></LI | |
706 ><LI | |
707 ><P | |
708 >Placing events on the event queue</P | |
709 ></LI | |
710 ></UL | |
711 ><P | |
712 >Reading events from the event queue is done with either <A | |
713 HREF="sdlpollevent.html" | |
714 ><TT | |
715 CLASS="FUNCTION" | |
716 >SDL_PollEvent</TT | |
717 ></A | |
718 > or <A | |
719 HREF="sdlpeepevents.html" | |
720 ><TT | |
721 CLASS="FUNCTION" | |
722 >SDL_PeepEvents</TT | |
723 ></A | |
724 >. We'll use <TT | |
725 CLASS="FUNCTION" | |
726 >SDL_PollEvent</TT | |
727 > and step through an example.</P | |
728 ><P | |
729 >First off, we create an empty <SPAN | |
730 CLASS="STRUCTNAME" | |
731 >SDL_Event</SPAN | |
732 > structure. | |
733 <PRE | |
734 CLASS="PROGRAMLISTING" | |
735 >SDL_Event test_event;</PRE | |
736 > | |
737 <TT | |
738 CLASS="FUNCTION" | |
739 >SDL_PollEvent</TT | |
740 > removes the next event from the event queue, if there are no events on the queue it returns <SPAN | |
741 CLASS="RETURNVALUE" | |
742 >0</SPAN | |
743 > otherwise it returns <SPAN | |
744 CLASS="RETURNVALUE" | |
745 >1</SPAN | |
746 >. We use a <TT | |
747 CLASS="FUNCTION" | |
748 >while</TT | |
749 > loop to process each event in turn. | |
750 <PRE | |
751 CLASS="PROGRAMLISTING" | |
752 >while(SDL_PollEvent(&test_event)) {</PRE | |
753 > | |
754 The <TT | |
755 CLASS="FUNCTION" | |
756 >SDL_PollEvent</TT | |
757 > function take a pointer to an <SPAN | |
758 CLASS="STRUCTNAME" | |
759 >SDL_Event</SPAN | |
760 > structure that is to be filled with event information. We know that if <TT | |
761 CLASS="FUNCTION" | |
762 >SDL_PollEvent</TT | |
763 > removes an event from the queue then the event information will be placed in our <SPAN | |
764 CLASS="STRUCTNAME" | |
765 >test_event</SPAN | |
766 > structure, but we also know that the <I | |
767 CLASS="EMPHASIS" | |
768 >type</I | |
769 > of event will be placed in the <TT | |
770 CLASS="STRUCTFIELD" | |
771 ><I | |
772 >type</I | |
773 ></TT | |
774 > member of <SPAN | |
775 CLASS="STRUCTNAME" | |
776 >test_event</SPAN | |
777 >. So to handle each event <TT | |
778 CLASS="STRUCTFIELD" | |
779 ><I | |
780 >type</I | |
781 ></TT | |
782 > seperately we use a <TT | |
783 CLASS="FUNCTION" | |
784 >switch</TT | |
785 > statement. | |
786 <PRE | |
787 CLASS="PROGRAMLISTING" | |
788 > switch(test_event.type) {</PRE | |
789 > | |
790 We need to know what kind of events we're looking for <I | |
791 CLASS="EMPHASIS" | |
792 >and</I | |
793 > the event <TT | |
794 CLASS="STRUCTFIELD" | |
795 ><I | |
796 >type</I | |
797 ></TT | |
798 >'s of those events. So lets assume we want to detect where the user is moving the mouse pointer within our application. We look through our event types and notice that <TT | |
799 CLASS="LITERAL" | |
800 >SDL_MOUSEMOTION</TT | |
801 > is, more than likely, the event we're looking for. A little <A | |
802 HREF="sdlmousemotionevent.html" | |
803 >more</A | |
804 > research tells use that <TT | |
805 CLASS="LITERAL" | |
806 >SDL_MOUSEMOTION</TT | |
807 > events are handled within the <A | |
808 HREF="sdlmousemotionevent.html" | |
809 ><SPAN | |
810 CLASS="STRUCTNAME" | |
811 >SDL_MouseMotionEvent</SPAN | |
812 ></A | |
813 > structure which is the <TT | |
814 CLASS="STRUCTFIELD" | |
815 ><I | |
816 >motion</I | |
817 ></TT | |
818 > member of <SPAN | |
819 CLASS="STRUCTNAME" | |
820 >SDL_Event</SPAN | |
821 >. We can check for the <TT | |
822 CLASS="LITERAL" | |
823 >SDL_MOUSEMOTION</TT | |
824 > event <TT | |
825 CLASS="STRUCTFIELD" | |
826 ><I | |
827 >type</I | |
828 ></TT | |
829 > within our <TT | |
830 CLASS="FUNCTION" | |
831 >switch</TT | |
832 > statement like so: | |
833 <PRE | |
834 CLASS="PROGRAMLISTING" | |
835 > case SDL_MOUSEMOTION:</PRE | |
836 > | |
837 All we need do now is read the information out of the <TT | |
838 CLASS="STRUCTFIELD" | |
839 ><I | |
840 >motion</I | |
841 ></TT | |
842 > member of <SPAN | |
843 CLASS="STRUCTNAME" | |
844 >test_event</SPAN | |
845 >. | |
846 <PRE | |
847 CLASS="PROGRAMLISTING" | |
848 > printf("We got a motion event.\n"); | |
849 printf("Current mouse position is: (%d, %d)\n", test_event.motion.x, test_event.motion.y); | |
850 break; | |
851 default: | |
852 printf("Unhandled Event!\n"); | |
853 break; | |
854 } | |
855 } | |
856 printf("Event queue empty.\n");</PRE | |
857 ></P | |
858 ><P | |
859 >It is also possible to push events onto the event queue and so use it as a two-way communication path. Both <A | |
860 HREF="sdlpushevent.html" | |
861 ><TT | |
862 CLASS="FUNCTION" | |
863 >SDL_PushEvent</TT | |
864 ></A | |
865 > and <A | |
866 HREF="sdlpeepevents.html" | |
867 ><TT | |
868 CLASS="FUNCTION" | |
869 >SDL_PeepEvents</TT | |
870 ></A | |
871 > allow you to place events onto the event queue. This is usually used to place a <TT | |
872 CLASS="LITERAL" | |
873 >SDL_USEREVENT</TT | |
874 > on the event queue, however you could use it to post fake input events if you wished. Creating your own events is a simple matter of choosing the event type you want, setting the <TT | |
875 CLASS="STRUCTFIELD" | |
876 ><I | |
877 >type</I | |
878 ></TT | |
879 > member and filling the appropriate member structure with information. | |
880 <PRE | |
881 CLASS="PROGRAMLISTING" | |
882 >SDL_Event user_event; | |
883 | |
884 user_event.type=SDL_USEREVENT; | |
885 user_event.user.code=2; | |
886 user_event.user.data1=NULL; | |
887 user_event.user.data2=NULL; | |
888 SDL_PushEvent(&user_event);</PRE | |
889 ></P | |
890 ></DIV | |
891 ><DIV | |
892 CLASS="REFSECT1" | |
893 ><A | |
181
e5bc29de3f0a
Updated from the SDL Documentation Project
Sam Lantinga <slouken@libsdl.org>
parents:
55
diff
changeset
|
894 NAME="AEN3558" |
0 | 895 ></A |
896 ><H2 | |
897 >See Also</H2 | |
898 ><P | |
899 ><A | |
900 HREF="sdlpollevent.html" | |
901 ><TT | |
902 CLASS="FUNCTION" | |
903 >SDL_PollEvent</TT | |
904 ></A | |
905 >, | |
906 <A | |
907 HREF="sdlpushevent.html" | |
908 ><TT | |
909 CLASS="FUNCTION" | |
910 >SDL_PushEvent</TT | |
911 ></A | |
912 >, | |
913 <A | |
914 HREF="sdlpeepevents.html" | |
915 ><TT | |
916 CLASS="FUNCTION" | |
917 >SDL_PeepEvents</TT | |
918 ></A | |
919 ></P | |
920 ></DIV | |
921 ><DIV | |
922 CLASS="NAVFOOTER" | |
923 ><HR | |
924 ALIGN="LEFT" | |
925 WIDTH="100%"><TABLE | |
926 WIDTH="100%" | |
927 BORDER="0" | |
928 CELLPADDING="0" | |
929 CELLSPACING="0" | |
930 ><TR | |
931 ><TD | |
932 WIDTH="33%" | |
933 ALIGN="left" | |
934 VALIGN="top" | |
935 ><A | |
936 HREF="eventstructures.html" | |
937 >Prev</A | |
938 ></TD | |
939 ><TD | |
940 WIDTH="34%" | |
941 ALIGN="center" | |
942 VALIGN="top" | |
943 ><A | |
944 HREF="index.html" | |
945 >Home</A | |
946 ></TD | |
947 ><TD | |
948 WIDTH="33%" | |
949 ALIGN="right" | |
950 VALIGN="top" | |
951 ><A | |
952 HREF="sdlactiveevent.html" | |
953 >Next</A | |
954 ></TD | |
955 ></TR | |
956 ><TR | |
957 ><TD | |
958 WIDTH="33%" | |
959 ALIGN="left" | |
960 VALIGN="top" | |
961 >SDL Event Structures.</TD | |
962 ><TD | |
963 WIDTH="34%" | |
964 ALIGN="center" | |
965 VALIGN="top" | |
966 ><A | |
967 HREF="eventstructures.html" | |
968 >Up</A | |
969 ></TD | |
970 ><TD | |
971 WIDTH="33%" | |
972 ALIGN="right" | |
973 VALIGN="top" | |
974 >SDL_ActiveEvent</TD | |
975 ></TR | |
976 ></TABLE | |
977 ></DIV | |
978 ></BODY | |
979 ></HTML | |
980 > |