3 <h3 id="TOP">Index</h3>
5 <ul><li><a href="#NAME">NAME</a></li>
6 <li><a href="#SYNOPSIS">SYNOPSIS</a></li>
7 <li><a href="#DESCRIPTION">DESCRIPTION</a></li>
8 <li><a href="#METHODS">METHODS</a>
9 <ul><li><a href="#new">new</a></li>
10 <li><a href="#type">type</a></li>
11 <li><a href="#active">active</a>
12 <ul><li><a href="#active_type">active_type</a></li>
13 <li><a href="#active_gain">active_gain</a></li>
14 <li><a href="#active_state">active_state</a></li>
17 <li><a href="#key">key</a>
18 <ul><li><a href="#key_type">key_type</a></li>
19 <li><a href="#key_state">key_state</a></li>
20 <li><a href="#key_keysym">key_keysym</a></li>
21 <li><a href="#key_scancode">key_scancode</a></li>
22 <li><a href="#key_sym">key_sym</a></li>
23 <li><a href="#key_mod">key_mod</a></li>
24 <li><a href="#key_unicode">key_unicode</a></li>
27 <li><a href="#motion">motion</a>
28 <ul><li><a href="#motion_type">motion_type</a></li>
29 <li><a href="#motion_state">motion_state</a></li>
30 <li><a href="#motion_x_motion_y">motion_x, motion_y</a></li>
31 <li><a href="#motion_xrel_motion_yrel">motion_xrel, motion_yrel</a></li>
34 <li><a href="#button">button</a>
35 <ul><li><a href="#button_type">button_type</a></li>
36 <li><a href="#button_which">button_which</a></li>
37 <li><a href="#button_button">button_button</a></li>
38 <li><a href="#button_state">button_state</a></li>
39 <li><a href="#button_x_button_y">button_x, button_y</a></li>
42 <li><a href="#jaxis">jaxis</a>
43 <ul><li><a href="#jaxis_type">jaxis_type</a></li>
44 <li><a href="#jaxis_which">jaxis_which</a></li>
45 <li><a href="#jaxis_axis">jaxis_axis</a></li>
46 <li><a href="#jaxis_value">jaxis_value</a></li>
49 <li><a href="#jbutton">jbutton</a>
50 <ul><li><a href="#jbutton_type">jbutton_type</a></li>
51 <li><a href="#jbutton_which">jbutton_which</a></li>
52 <li><a href="#jbutton_button">jbutton_button</a></li>
53 <li><a href="#jbutton_state">jbutton_state</a></li>
56 <li><a href="#jhat">jhat</a>
57 <ul><li><a href="#jhat_type">jhat_type</a></li>
58 <li><a href="#jhat_which">jhat_which</a></li>
59 <li><a href="#jhat_hat">jhat_hat</a></li>
60 <li><a href="#jhat_value">jhat_value</a></li>
63 <li><a href="#jball">jball</a>
64 <ul><li><a href="#jball_type">jball_type</a></li>
65 <li><a href="#jball_which">jball_which</a></li>
66 <li><a href="#jball_ball">jball_ball</a></li>
67 <li><a href="#jball_xrel_jball_yrel">jball_xrel, jball_yrel</a></li>
70 <li><a href="#resize">resize</a>
71 <ul><li><a href="#resize_type">resize_type</a></li>
72 <li><a href="#resize_x_resize_y">resize_x, resize_y</a></li>
75 <li><a href="#expose">expose</a>
76 <ul><li><a href="#expose_type">expose_type</a></li>
79 <li><a href="#syswm">syswm</a>
80 <ul><li><a href="#syswm_type">syswm_type</a></li>
81 <li><a href="#syswm_msg">syswm_msg</a></li>
84 <li><a href="#user">user</a>
85 <ul><li><a href="#user_type">user_type</a></li>
86 <li><a href="#user_code">user_code</a></li>
87 <li><a href="#user_data1_user_data2">user_data1, user_data2</a></li>
90 <li><a href="#quit">quit</a>
91 <ul><li><a href="#quit_type">quit_type</a></li>
96 <li><a href="#AUTHOR">AUTHOR</a></li>
97 <li><a href="#SEE_ALSO">SEE ALSO</a>
102 <h1 id="NAME">NAME</h1><p><a href="#TOP" class="toplink">Top</a></p>
103 <div id="NAME_CONTENT">
104 <p>SDL::Event - General event structure</p>
107 <h1 id="SYNOPSIS">SYNOPSIS</h1><p><a href="#TOP" class="toplink">Top</a></p>
108 <div id="SYNOPSIS_CONTENT">
109 <pre> use SDL::Event; # for the event object itself
110 use SDL::Events qw(pump_events poll_event); # functions for event queue handling
112 SDL::init(SDL_INIT_VIDEO);
113 my $event = SDL::Event->new();
119 if(poll_event($event))
121 if($event->type == SDL_MOUSEBUTTONDOWN)
123 # now you can handle the details
124 $event->button_which;
125 $event->button_button;
130 last if $event->type == SDL_QUIT;
133 # your screen drawing code will be here
139 <h1 id="DESCRIPTION">DESCRIPTION</h1><p><a href="#TOP" class="toplink">Top</a></p>
140 <div id="DESCRIPTION_CONTENT">
141 <p>Event handling allows your application to receive input from the user.
142 Event handling is initalised (along with video) with a call to:</p>
143 <p><code>SDL::init(SDL_INIT_VIDEO);</code></p>
144 <p>Internally, SDL stores all the events waiting to be handled in an event queue.
145 Using functions like <code>SDL::Events::poll_event()</code>, <code>SDL::Events::peep_events</code>
146 and <code>SDL::Events::wait_event()</code> you can observe and handle waiting input events.</p>
147 <p>The key to event handling in SDL is the <code>SDL::Event</code> union.
148 The event queue itself is composed of a series of <code>SDL::Event</code> unions, one for each waiting event.
149 <code>SDL::Event</code> unions are read from the queue with the <code>SDL::Events::poll_event()</code> function
150 and it is then up to the application to process the information stored with them. </p>
153 <h1 id="METHODS">METHODS</h1><p><a href="#TOP" class="toplink">Top</a></p>
154 <div id="METHODS_CONTENT">
157 <h2 id="new">new</h2>
158 <div id="new_CONTENT">
159 <p><code>new</code> creates an empty event-object, which can be used store information.
160 Either by calling <code>poll_event($event)</code> that transferes one event from the queue into our object
161 or by setting all the needed data manually in order to push the event to the queue.</p>
162 <pre> use SDL::Event;
164 my $event = SDL::Event->new();
169 <h2 id="type">type</h2>
170 <div id="type_CONTENT">
171 <p>SDL::Event is a union of all event structures used in SDL, using it is a simple matter of knowing
172 which union member relates to which event <code>type</code>.</p>
173 <pre> print 'heureka' if $event->type = SDL_MOUSEBUTTONDOWN;
176 <p>Available type constants:</p>
178 <li><a href="#active">SDL_ACTIVEEVENT</a> - Application visibility event structure </li>
179 <li><a href="#active">SDL_KEYDOWN</a> - Keyboard event structure </li>
180 <li><a href="#active">SDL_KEYUP</a> - Keyboard event structure </li>
181 <li><a href="#active">SDL_MOUSEMOTION</a> - Mouse motion event structure </li>
182 <li><a href="#active">SDL_MOUSEBUTTONDOWN</a> - Mouse button event structure </li>
183 <li><a href="#button">SDL_MOUSEBUTTONUP</a> - Mouse button event structure </li>
184 <li><a href="#active">SDL_JOYAXISMOTION</a> - Joystick axis motion event structure </li>
185 <li><a href="#active">SDL_JOYBALLMOTION</a> - Joystick trackball motion event structure </li>
186 <li><a href="#active">SDL_JOYHATMOTION</a> - Joystick hat position change event structure </li>
187 <li><a href="#active">SDL_JOYBUTTONDOWN</a> - Joystick button event structure </li>
188 <li><a href="#active">SDL_JOYBUTTONUP</a> - Joystick button event structure </li>
189 <li><a href="#active">SDL_VIDEORESIZE</a> - Window resize event structure </li>
190 <li><a href="#active">SDL_VIDEOEXPOSE</a> - Window expose event </li>
191 <li><a href="#active">SDL_QUIT</a> - Quit requested event </li>
192 <li><a href="#active">SDL_USEREVENT</a> - A user-defined event type </li>
193 <li><a href="#active">SDL_SYSWMEVENT</a> - Platform-dependent window manager event. </li>
196 <p>TODO: SDL_EVENTMASK()</p>
199 <h2 id="active">active</h2>
200 <div id="active_CONTENT">
201 <p><code>active</code> is a member of the <code>SDL::Event</code> union and is used when an event of type <code>SDL_ACTIVEEVENT</code> is reported.</p>
202 <p>When the mouse leaves or enters the window area a <code>SDL_APPMOUSEFOCUS</code> type activation event occurs,
203 if the mouse entered the window then <strong>gain</strong> will be 1, otherwise <strong>gain</strong> will be 0. </p>
204 <p>A <code>SDL_APPINPUTFOCUS</code> type activation event occurs when the application loses or gains keyboard focus.
205 This usually occurs when another application is made active. </p>
206 <p>Finally, a <code>SDL_APPACTIVE</code> type event occurs when the application is either minimised/iconified (<strong>gain</strong>=0) or restored. </p>
207 <p>A single event can have multiple values set in <strong>state</strong>.</p>
208 <p><strong>Note:</strong> This event does not occur when an application window is first created. </p>
209 <p>A new ActiveEvent (to fake focus loss) will be created like this:</p>
210 <pre> my $event = SDL::Event->new();
211 $event->type(SDL_ACTIVEEVENT);
212 $event->active_gain(0);
213 $event->active_state(SDL_APPMOUSEFOCUS);
215 # I think this is wrong, ->active_type() should get SDL_APPMOUSEFOCUS, but what state gets?
220 <h3 id="active_type">active_type</h3>
221 <div id="active_type_CONTENT">
224 <h3 id="active_gain">active_gain</h3>
225 <div id="active_gain_CONTENT">
228 <h3 id="active_state">active_state</h3>
229 <div id="active_state_CONTENT">
232 <h2 id="key">key</h2>
233 <div id="key_CONTENT">
236 <h3 id="key_type">key_type</h3>
237 <div id="key_type_CONTENT">
240 <h3 id="key_state">key_state</h3>
241 <div id="key_state_CONTENT">
244 <h3 id="key_keysym">key_keysym</h3>
245 <div id="key_keysym_CONTENT">
248 <h3 id="key_scancode">key_scancode</h3>
249 <div id="key_scancode_CONTENT">
252 <h3 id="key_sym">key_sym</h3>
253 <div id="key_sym_CONTENT">
256 <h3 id="key_mod">key_mod</h3>
257 <div id="key_mod_CONTENT">
260 <h3 id="key_unicode">key_unicode</h3>
261 <div id="key_unicode_CONTENT">
264 <h2 id="motion">motion</h2>
265 <div id="motion_CONTENT">
268 <h3 id="motion_type">motion_type</h3>
269 <div id="motion_type_CONTENT">
272 <h3 id="motion_state">motion_state</h3>
273 <div id="motion_state_CONTENT">
276 <h3 id="motion_x_motion_y">motion_x, motion_y</h3>
277 <div id="motion_x_motion_y_CONTENT">
280 <h3 id="motion_xrel_motion_yrel">motion_xrel, motion_yrel</h3>
281 <div id="motion_xrel_motion_yrel_CONTENT">
284 <h2 id="button">button</h2>
285 <div id="button_CONTENT">
288 <h3 id="button_type">button_type</h3>
289 <div id="button_type_CONTENT">
292 <h3 id="button_which">button_which</h3>
293 <div id="button_which_CONTENT">
296 <h3 id="button_button">button_button</h3>
297 <div id="button_button_CONTENT">
300 <h3 id="button_state">button_state</h3>
301 <div id="button_state_CONTENT">
304 <h3 id="button_x_button_y">button_x, button_y</h3>
305 <div id="button_x_button_y_CONTENT">
308 <h2 id="jaxis">jaxis</h2>
309 <div id="jaxis_CONTENT">
312 <h3 id="jaxis_type">jaxis_type</h3>
313 <div id="jaxis_type_CONTENT">
316 <h3 id="jaxis_which">jaxis_which</h3>
317 <div id="jaxis_which_CONTENT">
320 <h3 id="jaxis_axis">jaxis_axis</h3>
321 <div id="jaxis_axis_CONTENT">
324 <h3 id="jaxis_value">jaxis_value</h3>
325 <div id="jaxis_value_CONTENT">
328 <h2 id="jbutton">jbutton</h2>
329 <div id="jbutton_CONTENT">
332 <h3 id="jbutton_type">jbutton_type</h3>
333 <div id="jbutton_type_CONTENT">
336 <h3 id="jbutton_which">jbutton_which</h3>
337 <div id="jbutton_which_CONTENT">
340 <h3 id="jbutton_button">jbutton_button</h3>
341 <div id="jbutton_button_CONTENT">
344 <h3 id="jbutton_state">jbutton_state</h3>
345 <div id="jbutton_state_CONTENT">
348 <h2 id="jhat">jhat</h2>
349 <div id="jhat_CONTENT">
352 <h3 id="jhat_type">jhat_type</h3>
353 <div id="jhat_type_CONTENT">
356 <h3 id="jhat_which">jhat_which</h3>
357 <div id="jhat_which_CONTENT">
360 <h3 id="jhat_hat">jhat_hat</h3>
361 <div id="jhat_hat_CONTENT">
364 <h3 id="jhat_value">jhat_value</h3>
365 <div id="jhat_value_CONTENT">
368 <h2 id="jball">jball</h2>
369 <div id="jball_CONTENT">
372 <h3 id="jball_type">jball_type</h3>
373 <div id="jball_type_CONTENT">
376 <h3 id="jball_which">jball_which</h3>
377 <div id="jball_which_CONTENT">
380 <h3 id="jball_ball">jball_ball</h3>
381 <div id="jball_ball_CONTENT">
384 <h3 id="jball_xrel_jball_yrel">jball_xrel, jball_yrel</h3>
385 <div id="jball_xrel_jball_yrel_CONTENT">
388 <h2 id="resize">resize</h2>
389 <div id="resize_CONTENT">
392 <h3 id="resize_type">resize_type</h3>
393 <div id="resize_type_CONTENT">
396 <h3 id="resize_x_resize_y">resize_x, resize_y</h3>
397 <div id="resize_x_resize_y_CONTENT">
400 <h2 id="expose">expose</h2>
401 <div id="expose_CONTENT">
404 <h3 id="expose_type">expose_type</h3>
405 <div id="expose_type_CONTENT">
408 <h2 id="syswm">syswm</h2>
409 <div id="syswm_CONTENT">
412 <h3 id="syswm_type">syswm_type</h3>
413 <div id="syswm_type_CONTENT">
416 <h3 id="syswm_msg">syswm_msg</h3>
417 <div id="syswm_msg_CONTENT">
420 <h2 id="user">user</h2>
421 <div id="user_CONTENT">
424 <h3 id="user_type">user_type</h3>
425 <div id="user_type_CONTENT">
428 <h3 id="user_code">user_code</h3>
429 <div id="user_code_CONTENT">
432 <h3 id="user_data1_user_data2">user_data1, user_data2</h3>
433 <div id="user_data1_user_data2_CONTENT">
436 <h2 id="quit">quit</h2>
437 <div id="quit_CONTENT">
440 <h3 id="quit_type">quit_type</h3>
441 <div id="quit_type_CONTENT">
442 <p>Create a new SDL::Event object.</p>
445 <h1 id="AUTHOR">AUTHOR</h1><p><a href="#TOP" class="toplink">Top</a></p>
446 <div id="AUTHOR_CONTENT">
449 <h1 id="SEE_ALSO">SEE ALSO</h1><p><a href="#TOP" class="toplink">Top</a></p>
450 <div id="SEE_ALSO_CONTENT">
451 <p><cite>perl</cite></p>