0
|
1 <HTML
|
|
2 ><HEAD
|
|
3 ><TITLE
|
|
4 >SDL_PollEvent</TITLE
|
|
5 ><META
|
|
6 NAME="GENERATOR"
|
|
7 CONTENT="Modular DocBook HTML Stylesheet Version 1.61
|
|
8 "><LINK
|
|
9 REL="HOME"
|
|
10 TITLE="SDL Library Documentation"
|
|
11 HREF="index.html"><LINK
|
|
12 REL="UP"
|
|
13 TITLE="Event Functions."
|
|
14 HREF="eventfunctions.html"><LINK
|
|
15 REL="PREVIOUS"
|
|
16 TITLE="SDL_PeepEvents"
|
|
17 HREF="sdlpeepevents.html"><LINK
|
|
18 REL="NEXT"
|
|
19 TITLE="SDL_WaitEvent"
|
|
20 HREF="sdlwaitevent.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="sdlpeepevents.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="sdlwaitevent.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="SDLPOLLEVENT"
|
|
71 >SDL_PollEvent</A
|
|
72 ></H1
|
|
73 ><DIV
|
|
74 CLASS="REFNAMEDIV"
|
|
75 ><A
|
|
76 NAME="AEN4854"
|
|
77 ></A
|
|
78 ><H2
|
|
79 >Name</H2
|
|
80 >SDL_PollEvent -- Polls for currently pending events.</DIV
|
|
81 ><DIV
|
|
82 CLASS="REFSYNOPSISDIV"
|
|
83 ><A
|
|
84 NAME="AEN4857"
|
|
85 ></A
|
|
86 ><H2
|
|
87 >Synopsis</H2
|
|
88 ><DIV
|
|
89 CLASS="FUNCSYNOPSIS"
|
|
90 ><A
|
|
91 NAME="AEN4858"
|
|
92 ></A
|
|
93 ><P
|
|
94 ></P
|
|
95 ><PRE
|
|
96 CLASS="FUNCSYNOPSISINFO"
|
|
97 >#include "SDL.h"</PRE
|
|
98 ><P
|
|
99 ><CODE
|
|
100 ><CODE
|
|
101 CLASS="FUNCDEF"
|
|
102 >int <B
|
|
103 CLASS="FSFUNC"
|
|
104 >SDL_PollEvent</B
|
|
105 ></CODE
|
|
106 >(SDL_Event *event);</CODE
|
|
107 ></P
|
|
108 ><P
|
|
109 ></P
|
|
110 ></DIV
|
|
111 ></DIV
|
|
112 ><DIV
|
|
113 CLASS="REFSECT1"
|
|
114 ><A
|
|
115 NAME="AEN4864"
|
|
116 ></A
|
|
117 ><H2
|
|
118 >Description</H2
|
|
119 ><P
|
|
120 >Polls for currently pending events, and returns <SPAN
|
|
121 CLASS="RETURNVALUE"
|
|
122 >1</SPAN
|
|
123 >
|
|
124 if there are any pending events, or <SPAN
|
|
125 CLASS="RETURNVALUE"
|
|
126 >0</SPAN
|
|
127 > if there
|
|
128 are none available. </P
|
|
129 ><P
|
|
130 >If <TT
|
|
131 CLASS="PARAMETER"
|
|
132 ><I
|
|
133 >event</I
|
|
134 ></TT
|
|
135 > is not <TT
|
|
136 CLASS="LITERAL"
|
|
137 >NULL</TT
|
|
138 >, the next
|
|
139 event is removed from the queue and stored in that area.</P
|
|
140 ></DIV
|
|
141 ><DIV
|
|
142 CLASS="REFSECT1"
|
|
143 ><A
|
|
144 NAME="AEN4872"
|
|
145 ></A
|
|
146 ><H2
|
|
147 >Examples</H2
|
|
148 ><P
|
|
149 ><PRE
|
|
150 CLASS="PROGRAMLISTING"
|
|
151 >SDL_Event event; /* Event structure */
|
|
152
|
|
153 .
|
|
154 .
|
|
155 .
|
|
156 /* Check for events */
|
|
157 while(SDL_PollEvent(&event)){ /* Loop until there are no events left on the queue */
|
|
158 switch(event.type){ /* Process the appropiate event type */
|
|
159 case SDL_KEYDOWN: /* Handle a KEYDOWN event */
|
|
160 printf("Oh! Key press\n");
|
|
161 break;
|
|
162 case SDL_MOUSEMOTION:
|
|
163 .
|
|
164 .
|
|
165 .
|
|
166 default: /* Report an unhandled event */
|
|
167 printf("I don't know what this event is!\n");
|
|
168 }
|
|
169 }</PRE
|
|
170 ></P
|
|
171 ></DIV
|
|
172 ><DIV
|
|
173 CLASS="REFSECT1"
|
|
174 ><A
|
|
175 NAME="AEN4876"
|
|
176 ></A
|
|
177 ><H2
|
|
178 >See Also</H2
|
|
179 ><P
|
|
180 ><A
|
|
181 HREF="sdlevent.html"
|
|
182 ><SPAN
|
|
183 CLASS="STRUCTNAME"
|
|
184 >SDL_Event</SPAN
|
|
185 ></A
|
|
186 >,
|
|
187 <A
|
|
188 HREF="sdlwaitevent.html"
|
|
189 ><TT
|
|
190 CLASS="FUNCTION"
|
|
191 >SDL_WaitEvent</TT
|
|
192 ></A
|
|
193 >,
|
|
194 <A
|
|
195 HREF="sdlpeepevents.html"
|
|
196 ><TT
|
|
197 CLASS="FUNCTION"
|
|
198 >SDL_PeepEvents</TT
|
|
199 ></A
|
|
200 ></P
|
|
201 ></DIV
|
|
202 ><DIV
|
|
203 CLASS="NAVFOOTER"
|
|
204 ><HR
|
|
205 ALIGN="LEFT"
|
|
206 WIDTH="100%"><TABLE
|
|
207 WIDTH="100%"
|
|
208 BORDER="0"
|
|
209 CELLPADDING="0"
|
|
210 CELLSPACING="0"
|
|
211 ><TR
|
|
212 ><TD
|
|
213 WIDTH="33%"
|
|
214 ALIGN="left"
|
|
215 VALIGN="top"
|
|
216 ><A
|
|
217 HREF="sdlpeepevents.html"
|
|
218 >Prev</A
|
|
219 ></TD
|
|
220 ><TD
|
|
221 WIDTH="34%"
|
|
222 ALIGN="center"
|
|
223 VALIGN="top"
|
|
224 ><A
|
|
225 HREF="index.html"
|
|
226 >Home</A
|
|
227 ></TD
|
|
228 ><TD
|
|
229 WIDTH="33%"
|
|
230 ALIGN="right"
|
|
231 VALIGN="top"
|
|
232 ><A
|
|
233 HREF="sdlwaitevent.html"
|
|
234 >Next</A
|
|
235 ></TD
|
|
236 ></TR
|
|
237 ><TR
|
|
238 ><TD
|
|
239 WIDTH="33%"
|
|
240 ALIGN="left"
|
|
241 VALIGN="top"
|
|
242 >SDL_PeepEvents</TD
|
|
243 ><TD
|
|
244 WIDTH="34%"
|
|
245 ALIGN="center"
|
|
246 VALIGN="top"
|
|
247 ><A
|
|
248 HREF="eventfunctions.html"
|
|
249 >Up</A
|
|
250 ></TD
|
|
251 ><TD
|
|
252 WIDTH="33%"
|
|
253 ALIGN="right"
|
|
254 VALIGN="top"
|
|
255 >SDL_WaitEvent</TD
|
|
256 ></TR
|
|
257 ></TABLE
|
|
258 ></DIV
|
|
259 ></BODY
|
|
260 ></HTML
|
|
261 > |