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