1<HTML 2><HEAD 3><TITLE 4>Events</TITLE 5><META 6NAME="GENERATOR" 7CONTENT="Modular DocBook HTML Stylesheet Version 1.76b+ 8"><LINK 9REL="HOME" 10TITLE="SDL Library Documentation" 11HREF="index.html"><LINK 12REL="UP" 13TITLE="SDL Reference" 14HREF="reference.html"><LINK 15REL="PREVIOUS" 16TITLE="SDL_WM_GrabInput" 17HREF="sdlwmgrabinput.html"><LINK 18REL="NEXT" 19TITLE="SDL Event Structures." 20HREF="eventstructures.html"><META 21NAME="KEYWORD" 22CONTENT="events"><META 23NAME="KEYWORD" 24CONTENT="function"></HEAD 25><BODY 26CLASS="CHAPTER" 27BGCOLOR="#FFF8DC" 28TEXT="#000000" 29LINK="#0000ee" 30VLINK="#551a8b" 31ALINK="#ff0000" 32><DIV 33CLASS="NAVHEADER" 34><TABLE 35SUMMARY="Header navigation table" 36WIDTH="100%" 37BORDER="0" 38CELLPADDING="0" 39CELLSPACING="0" 40><TR 41><TH 42COLSPAN="3" 43ALIGN="center" 44>SDL Library Documentation</TH 45></TR 46><TR 47><TD 48WIDTH="10%" 49ALIGN="left" 50VALIGN="bottom" 51><A 52HREF="sdlwmgrabinput.html" 53ACCESSKEY="P" 54>Prev</A 55></TD 56><TD 57WIDTH="80%" 58ALIGN="center" 59VALIGN="bottom" 60></TD 61><TD 62WIDTH="10%" 63ALIGN="right" 64VALIGN="bottom" 65><A 66HREF="eventstructures.html" 67ACCESSKEY="N" 68>Next</A 69></TD 70></TR 71></TABLE 72><HR 73ALIGN="LEFT" 74WIDTH="100%"></DIV 75><DIV 76CLASS="CHAPTER" 77><H1 78><A 79NAME="EVENT" 80></A 81>Chapter 8. Events</H1 82><DIV 83CLASS="TOC" 84><DL 85><DT 86><B 87>Table of Contents</B 88></DT 89><DT 90><A 91HREF="event.html#AEN3691" 92>Introduction</A 93></DT 94><DT 95><A 96HREF="eventstructures.html" 97>SDL Event Structures.</A 98></DT 99><DT 100><A 101HREF="eventfunctions.html" 102>Event Functions.</A 103></DT 104></DL 105></DIV 106><DIV 107CLASS="SECT1" 108><H1 109CLASS="SECT1" 110><A 111NAME="AEN3691" 112></A 113>Introduction</H1 114><P 115>Event handling allows your application to receive input from the user. Event handling is initalised (along with video) with a call to: 116<PRE 117CLASS="PROGRAMLISTING" 118>SDL_Init(SDL_INIT_VIDEO);</PRE 119> 120Internally, SDL stores all the events waiting to be handled in an event queue. Using functions like <A 121HREF="sdlpollevent.html" 122><TT 123CLASS="FUNCTION" 124>SDL_PollEvent</TT 125></A 126> and <A 127HREF="sdlpeepevents.html" 128><TT 129CLASS="FUNCTION" 130>SDL_PeepEvents</TT 131></A 132> you can observe and handle waiting input events.</P 133><P 134>The key to event handling in SDL is the <A 135HREF="sdlevent.html" 136><SPAN 137CLASS="STRUCTNAME" 138>SDL_Event</SPAN 139></A 140> union. The event queue itself is composed of a series of <SPAN 141CLASS="STRUCTNAME" 142>SDL_Event</SPAN 143> unions, one for each waiting event. <SPAN 144CLASS="STRUCTNAME" 145>SDL_Event</SPAN 146> unions are read from the queue with the <TT 147CLASS="FUNCTION" 148>SDL_PollEvent</TT 149> function and it is then up to the application to process the information stored with them.</P 150></DIV 151></DIV 152><DIV 153CLASS="NAVFOOTER" 154><HR 155ALIGN="LEFT" 156WIDTH="100%"><TABLE 157SUMMARY="Footer navigation table" 158WIDTH="100%" 159BORDER="0" 160CELLPADDING="0" 161CELLSPACING="0" 162><TR 163><TD 164WIDTH="33%" 165ALIGN="left" 166VALIGN="top" 167><A 168HREF="sdlwmgrabinput.html" 169ACCESSKEY="P" 170>Prev</A 171></TD 172><TD 173WIDTH="34%" 174ALIGN="center" 175VALIGN="top" 176><A 177HREF="index.html" 178ACCESSKEY="H" 179>Home</A 180></TD 181><TD 182WIDTH="33%" 183ALIGN="right" 184VALIGN="top" 185><A 186HREF="eventstructures.html" 187ACCESSKEY="N" 188>Next</A 189></TD 190></TR 191><TR 192><TD 193WIDTH="33%" 194ALIGN="left" 195VALIGN="top" 196>SDL_WM_GrabInput</TD 197><TD 198WIDTH="34%" 199ALIGN="center" 200VALIGN="top" 201><A 202HREF="reference.html" 203ACCESSKEY="U" 204>Up</A 205></TD 206><TD 207WIDTH="33%" 208ALIGN="right" 209VALIGN="top" 210>SDL Event Structures.</TD 211></TR 212></TABLE 213></DIV 214></BODY 215></HTML 216>