added constants to SDL::Events docs
[sdlgit/SDL-Site.git] / pages / SDL-Events.html-inc
1 <div class="pod">
2 <!-- INDEX START -->
3 <h3 id="TOP">Index</h3>
4
5 <ul><li><a href="#NAME">NAME</a>
6 <ul><li><a href="#CATEGORY">CATEGORY</a></li>
7 </ul>
8 </li>
9 <li><a href="#SYNOPSIS">SYNOPSIS</a></li>
10 <li><a href="#CONSTANTS">CONSTANTS</a></li>
11 <li><a href="#METHODS">METHODS</a>
12 <ul><li><a href="#pump_events">pump_events</a></li>
13 <li><a href="#peep_events_event_num_events_action_">peep_events (event, num_events, action, mask) </a>
14 <ul><li><a href="#RETURN">RETURN</a></li>
15 </ul>
16 </li>
17 <li><a href="#poll_event_event">poll_event($event)</a>
18 <ul><li><a href="#RETURN-2">RETURN</a></li>
19 </ul>
20 </li>
21 <li><a href="#push_event_event">push_event($event)</a>
22 <ul><li><a href="#RETURN-3">RETURN</a></li>
23 </ul>
24 </li>
25 <li><a href="#wait_event_event">wait_event($event)</a>
26 <ul><li><a href="#RETURN-4">RETURN</a></li>
27 </ul>
28 </li>
29 <li><a href="#set_event_filter">set_event_filter</a>
30 <ul><li><a href="#PARAMETER">PARAMETER</a></li>
31 </ul>
32 </li>
33 <li><a href="#get_key_state">get_key_state</a></li>
34 <li><a href="#get_mod_state">get_mod_state</a>
35 <ul><li><a href="#MOD_VALUES">MOD VALUES</a></li>
36 </ul>
37 </li>
38 <li><a href="#set_mod_state">set_mod_state</a></li>
39 <li><a href="#event_state">event_state </a>
40 <ul><li><a href="#STATES">STATES</a></li>
41 </ul>
42 </li>
43 <li><a href="#get_key_name">get_key_name</a></li>
44 <li><a href="#enable_unicode">enable_unicode </a></li>
45 <li><a href="#enable_key_repeat">enable_key_repeat </a></li>
46 <li><a href="#get_mouse_state">get_mouse_state </a></li>
47 <li><a href="#get_relative_mouse_state">get_relative_mouse_state </a></li>
48 <li><a href="#get_app_state">get_app_state </a></li>
49 <li><a href="#joystick_event_state">joystick_event_state </a></li>
50 </ul>
51 </li>
52 <li><a href="#SEE_ALSO">SEE ALSO</a>
53 </li>
54 </ul><hr />
55 <!-- INDEX END -->
56
57 <h1 id="NAME">NAME</h1><p><a href="#TOP" class="toplink">Top</a></p>
58 <div id="NAME_CONTENT">
59 <p>SDL::Events - Bindings to the Events Category in SDL API</p>
60
61 </div>
62 <h2 id="CATEGORY">CATEGORY</h2>
63 <div id="CATEGORY_CONTENT">
64 <p>Core, Events</p>
65
66 </div>
67 <h1 id="SYNOPSIS">SYNOPSIS</h1><p><a href="#TOP" class="toplink">Top</a></p>
68 <div id="SYNOPSIS_CONTENT">
69 <p>Most likely you just want to know how to get events for you app.</p>
70 <pre>  use SDL ':init';
71   use SDL::Event;
72   use SDL::Events ':all';
73
74   SDL::init(SDL_INIT_VIDEO); # Event can only be grabbed in the same thread as this 
75
76   ...
77
78   my $event = SDL::Event-&gt;new(); # notices 'Event' ne 'Events'
79
80   while( 1 )
81         {
82           SDL::Events::pump_events();    
83          while(  SDL::Events::poll_event($event) )
84          {
85                 #check by event type
86                 on_active() if $event-&gt;type == SDL_ACTIVEEVENT; 
87                 ...
88          }
89         }
90
91 </pre>
92
93 </div>
94 <h1 id="CONSTANTS">CONSTANTS</h1><p><a href="#TOP" class="toplink">Top</a></p>
95 <div id="CONSTANTS_CONTENT">
96 <p>The constants are not exported by default. You can export them into your namespace by doing:</p>
97 <pre> use SDL::Events ':all';
98
99 </pre>
100 <p>or access them directly:</p>
101 <pre> SDL::Events::SDL_ACTIVEEVENT;
102
103 </pre>
104 <p>or by choosing the export tags below:</p>
105 <p>Export tag: ':type'</p>
106 <pre> SDL_ACTIVEEVENT
107  SDL_KEYDOWN
108  SDL_KEYUP
109  SDL_MOUSEMOTION
110  SDL_MOUSEBUTTONDOWN
111  SDL_MOUSEBUTTONUP
112  SDL_JOYAXISMOTION
113  SDL_JOYBALLMOTION
114  SDL_JOYHATMOTION
115  SDL_JOYBUTTONDOWN
116  SDL_JOYBUTTONUP
117  SDL_QUIT
118  SDL_SYSWMEVENT
119  SDL_VIDEORESIZE
120  SDL_VIDEOEXPOSE
121  SDL_USEREVENT
122  SDL_NUMEVENTS
123
124 </pre>
125 <p>Export tag: ':mask'</p>
126 <pre> SDL_EVENTMASK
127  SDL_ACTIVEEVENTMASK
128  SDL_KEYDOWNMASK
129  SDL_KEYUPMASK
130  SDL_KEYEVENTMASK
131  SDL_MOUSEMOTIONMASK
132  SDL_MOUSEBUTTONDOWNMASK
133  SDL_MOUSEBUTTONUPMASK
134  SDL_MOUSEEVENTMASK
135  SDL_JOYAXISMOTIONMASK
136  SDL_JOYBALLMOTIONMASK
137  SDL_JOYHATMOTIONMASK
138  SDL_JOYBUTTONDOWNMASK
139  SDL_JOYBUTTONUPMASK
140  SDL_JOYEVENTMASK
141  SDL_VIDEORESIZEMASK
142  SDL_VIDEOEXPOSEMASK
143  SDL_QUITMASK
144  SDL_SYSWMEVENTMASK
145  SDL_ALLEVENTS
146
147 </pre>
148 <p>Export tag: ':action'</p>
149 <pre> SDL_ADDEVENT
150  SDL_PEEKEVENT
151  SDL_GETEVENT
152
153 </pre>
154 <p>Export tag: ':state'</p>
155 <pre> SDL_QUERY
156  SDL_IGNORE
157  SDL_DISABLE / SDL_ENABLE
158  SDL_RELEASED / SDL_PRESSED
159
160 </pre>
161 <p>Export tag: ':hat'</p>
162 <pre> SDL_HAT_CENTERED
163  SDL_HAT_UP / SDL_HAT_RIGHT / SDL_HAT_DOWN / SDL_HAT_LEFT
164  SDL_HAT_RIGHTUP / SDL_HAT_RIGHTDOWN / SDL_HAT_LEFTUP / SDL_HAT_LEFTDOWN
165
166 </pre>
167 <p>Export tag: ':app'</p>
168 <pre> SDL_APPMOUSEFOCUS
169  SDL_APPINPUTFOCUS
170  SDL_APPACTIVE
171
172 </pre>
173 <p>Export tag: ':button'</p>
174 <pre> SDL_BUTTON
175  SDL_BUTTON_LEFT / SDL_BUTTON_MIDDLE / SDL_BUTTON_RIGHT
176  SDL_BUTTON_WHEELUP / SDL_BUTTON_WHEELDOWN
177  SDL_BUTTON_X1 / SDL_BUTTON_X2
178  SDL_BUTTON_LMASK / SDL_BUTTON_MMASK / SDL_BUTTON_RMASK
179  SDL_BUTTON_X1MASK / SDL_BUTTON_X2MASK
180
181 </pre>
182 <p>Export tag: ':keysym'</p>
183 <pre> SDLK_UNKNOWN
184  SDLK_FIRST
185  SDLK_BACKSPACE
186  SDLK_TAB
187  SDLK_CLEAR
188  SDLK_RETURN
189  SDLK_PAUSE
190  SDLK_ESCAPE
191  SDLK_SPACE
192  SDLK_EXCLAIM
193  SDLK_QUOTEDBL
194  SDLK_HASH
195  SDLK_DOLLAR
196  SDLK_AMPERSAND
197  SDLK_QUOTE
198  SDLK_LEFTPAREN / SDLK_RIGHTPAREN
199  SDLK_ASTERISK
200  SDLK_PLUS / SDLK_MINUS
201  SDLK_COMMA
202  SDLK_PERIOD
203  SDLK_0 .. SDLK_9
204  SDLK_COLON
205  SDLK_SEMICOLON
206  SDLK_LESS / SDLK_GREATER
207  SDLK_EQUALS
208  SDLK_QUESTION
209  SDLK_AT
210  SDLK_LEFTBRACKET / SDLK_RIGHTBRACKET
211  SDLK_SLASH / SDLK_BACKSLASH
212  SDLK_CARET
213  SDLK_UNDERSCORE
214  SDLK_BACKQUOTE
215  SDLK_a .. SDLK_z
216  SDLK_DELETE
217  SDLK_WORLD_0 .. SDLK_WORLD_95
218  SDLK_KP0 .. SDLK_KP9
219  SDLK_KP_PERIOD
220  SDLK_KP_DIVIDE / SDLK_KP_MULTIPLY
221  SDLK_KP_MINUS / SDLK_KP_PLUS
222  SDLK_KP_ENTER
223  SDLK_KP_EQUALS
224  SDLK_UP / SDLK_DOWN / SDLK_RIGHT / SDLK_LEFT
225  SDLK_INSERT
226  SDLK_HOME / SDLK_END
227  SDLK_PAGEUP / SDLK_PAGEDOWN
228  SDLK_F1 .. SDLK_F15
229  SDLK_NUMLOCK / SDLK_CAPSLOCK / SDLK_SCROLLOCK
230  SDLK_RSHIFT / SDLK_LSHIFT
231  SDLK_RCTRL  / SDLK_LCTRL
232  SDLK_RALT   / SDLK_LALT
233  SDLK_RMETA  / SDLK_LMETA
234  SDLK_LSUPER / SDLK_RSUPER
235  SDLK_MODE
236  SDLK_COMPOSE
237  SDLK_HELP
238  SDLK_PRINT
239  SDLK_SYSREQ
240  SDLK_BREAK
241  SDLK_MENU
242  SDLK_POWER
243  SDLK_EURO
244  SDLK_UNDO
245
246 </pre>
247 <p>Export tag ':keymod'</p>
248 <pre> KMOD_NONE
249  KMOD_LSHIFT / KMOD_RSHIFT / KMOD_SHIFT
250  KMOD_LCTRL  / KMOD_RCTRL  / KMOD_CTRL
251  KMOD_LALT   / KMOD_RALT   / KMOD_ALT
252  KMOD_LMETA  / KMOD_RMETA  / KMOD_META
253  KMOD_NUM
254  KMOD_CAPS
255  KMOD_MODE
256  KMOD_RESERVED
257
258 </pre>
259
260 </div>
261 <h1 id="METHODS">METHODS</h1><p><a href="#TOP" class="toplink">Top</a></p>
262 <div id="METHODS_CONTENT">
263
264 </div>
265 <h2 id="pump_events">pump_events</h2>
266 <div id="pump_events_CONTENT">
267 <p>Pumps the event loop, gathering events from the input devices.</p>
268 <pre>   pump_events();
269
270 </pre>
271 <p>pump_events gathers all the pending input information from devices and places it on the event queue. Without calls to pump_events no events would ever be placed on the queue. 
272 Often the need for calls to pump_events is hidden from the user since <a href="http://search.cpan.org/perldoc?poll_event">poll_event</a> and <a href="http://search.cpan.org/perldoc?wait_event">wait_event</a> implicitly call pump_events. 
273 However, if you are not polling or waiting for events (e.g. you are filtering them), then you must call pump_events to force an event queue update.</p>
274
275
276
277
278
279 </div>
280 <h2 id="peep_events_event_num_events_action_">peep_events (event, num_events, action, mask) </h2>
281 <div id="peep_events_event_num_events_action_-2">
282 <p>Checks the event queue for messages and optionally returns them.  </p>
283 <pre>   my $num_peep_events = SDL::Events::peep_events($event, 127, SDL_PEEKEVENT, SDL_ALLEVENTS);
284
285 </pre>
286 <p>If action is SDL_ADDEVENT, up to numevents events will be added to the back of the event queue.</p>
287 <p>If action is SDL_PEEKEVENT, up to numevents events at the front of the event queue, matching mask, will be returned and will not be removed from the queue.</p>
288 <p>If action is SDL_GETEVENT, up to numevents events at the front of the event queue, matching mask, will be returned and will be removed from the queue.</p>
289 <p>The mask parameter is a bitwise OR of SDL::Events::SDL_EVENTMASK(event_type), for all event types you are interested in</p>
290 <p>This function is thread-safe.</p>
291 <p>You may have to call pump_events before calling this function. Otherwise, the events may not be ready to be filtered when you call peep_events.</p>
292 <p>Examples of mask:</p>
293 <dl>
294         <dt>SDL_EVENTMASK (SDL_KEYUP)</dt>
295         <dt>(SDL_EVENTMASK (SDL_MOUSEBUTTONDOWN) | SDL_EVENTMASK (SDL_MOUSEBUTTONUP))</dt>
296         <dt>SDL_ALLEVENTS</dt>
297         <dt>SDL_KEYUPMASK</dt>
298         <dt>SDL_ALLEVENTS ^ SDL_QUITMASK</dt>
299 </dl>
300
301 </div>
302 <h3 id="RETURN">RETURN</h3>
303 <div id="RETURN_CONTENT">
304 <p>Number of Events actually stored or -1 if there was an error</p>
305
306 </div>
307 <h2 id="poll_event_event">poll_event($event)</h2>
308 <div id="poll_event_event_CONTENT">
309 <p>Polls for currently pending events. </p>
310 <p>If $event is not NULL, the next event is removed from the queue and stored in the <a href="SDL-Event.html">SDL::Event</a> structure pointed to by $event.</p>
311 <p>As this function implicitly calls pump_events, you can only call this function in the thread that set the video mode with <a href="/SDL-Video.html#set_video_mode">SDL::Video::set_video_mode</a>. </p>
312
313 </div>
314 <h3 id="RETURN-2">RETURN</h3>
315 <div id="RETURN_CONTENT-2">
316 <p>Returns 1 if there are any pending events, or 0 if there are none available. </p>
317
318 </div>
319 <h2 id="push_event_event">push_event($event)</h2>
320 <div id="push_event_event_CONTENT">
321 <p>Pushes an event onto the event queue </p>
322 <p>The event queue can actually be used as a two way communication channel. Not only can events be read from the queue, but the user can also push their own events onto it. event is a pointer to the event structure you wish to push onto the queue. 
323 The event is copied into the queue, and the caller may dispose of the memory pointed to after push_event returns.</p>
324 <p>Note: Pushing device input events onto the queue doesn't modify the state of the device within SDL. </p>
325 <p>This function is thread safe, and can be called from other threads safely.</p>
326
327 </div>
328 <h3 id="RETURN-3">RETURN</h3>
329 <div id="RETURN_CONTENT-3">
330 <p>Returns 0 on success or -1 if the event couldn't be pushed.</p>
331
332 </div>
333 <h2 id="wait_event_event">wait_event($event)</h2>
334 <div id="wait_event_event_CONTENT">
335 <p>Waits indefinitely for the next available $event, returning 0 if there was an error while waiting for events, 1 otherwise.</p>
336 <p>If $event is not NULL, the next event is removed from the queue and stored in $event.</p>
337 <p>As this function implicitly calls SDL_PumpEvents, you can only call this function in the thread that  <a href="/SDL-Video.html#set_video_mode">SDL::Video::set_video_mode</a>.  </p>
338
339 </div>
340 <h3 id="RETURN-4">RETURN</h3>
341 <div id="RETURN_CONTENT-4">
342 <p>0 if there was an error while waiting for events, 1 otherwise</p>
343
344 </div>
345 <h2 id="set_event_filter">set_event_filter</h2>
346 <div id="set_event_filter_CONTENT">
347 <p>Sets up a filter to process all events </p>
348 <pre>   my $filter = sub { if($_[0]-&gt;type == SDL_ACTIVEEVENT){ return 0} else{ return 1; }};
349
350         SDL::Events::set_event_filter($filter);
351
352 </pre>
353
354 </div>
355 <h3 id="PARAMETER">PARAMETER</h3>
356 <div id="PARAMETER_CONTENT">
357 <p>set_event_filter takes a coderef that it checks all events again. The callback gets a event in the stack</p>
358 <pre>   sub { my $event_to_test = shift; ...}
359
360 </pre>
361 <p>to filter the event return a 0, to pass the filter return a 1. </p>
362 <p>One <strong>Caveat</strong> is if you are filterign SDL_QUITEVENT the event will be filtered if it is non-intterupt call ( Window closes normally ). If it is a interrupt SDL_QUITEVENT it will be process on the next event poll. </p>
363 <p>Events pushed onto to the queue with <a href="/SDL-Events.html#push_events">SDL::Events::push_events</a> or <a href="/SDL-Events.html#peep_events">SDL::Events::peep_events</a> do not get filtered.</p>
364 <p>This callback may run in a different thread. </p>
365
366 </div>
367 <h2 id="get_key_state">get_key_state</h2>
368 <div id="get_key_state_CONTENT">
369 <p>Get a snapshot of the current keyboard state</p>
370 <pre>   my $keys_ref = SDL::Events::get_key_state();
371
372         print $keys_ref-&gt;[SDLK_RETURN]; # 1 if pressed , 0 if not pressed
373
374 </pre>
375 <p>Use <a href="/SDL-Events.html#pump_events">SDL::Events::pump_events</a> to update the state array.</p>
376 <p>This function gives you the current state after all events have been processed, so if a key or button has been pressed and released before you process events, then the pressed state will never show up in the get_key_state call.</p>
377 <p>This function doesn't take into account whether shift has been pressed or not.</p>
378
379 </div>
380 <h2 id="get_mod_state">get_mod_state</h2>
381 <div id="get_mod_state_CONTENT">
382 <p>Get the state of the modifier keys</p>
383 <p>Returns the current state of modifier keys</p>
384 <p>Return value is an OR'd combination of  KMOD_*</p>
385 <pre> SDL::Events::pump_events; #get latest mod_state in buffers
386
387  my $mod_state = SDL::Events::get_mod_state();
388
389  # Check which ones are pressed with 
390
391  # no mod pressed?
392
393  print 'no_mod' if  ( $mod_state &amp; KMOD_NONE );
394
395  # CTRL or ALT 
396
397  print 'ctrl alt' if ($mod_state &amp; KMOD_CTRL || $mod_state &amp; KMOD_ALT );
398
399 </pre>
400
401 </div>
402 <h3 id="MOD_VALUES">MOD VALUES</h3>
403 <div id="MOD_VALUES_CONTENT">
404 <dl>
405         <dt>KMOD_NONE</dt>
406         <dt>KMOD_LSHIFT</dt>
407         <dt>KMOD_RSHIFT</dt>
408         <dt>KMOD_LCTRL</dt>
409         <dt>KMOD_RCTRL</dt>
410         <dt>KMOD_LALT</dt>
411         <dt>KMOD_RALT</dt>
412         <dt>KMOD_LMETA</dt>
413         <dt>KMOD_RMETA</dt>
414         <dt>KMOD_NUM</dt>
415         <dt>KMOD_CAPS</dt>
416         <dt>KMOD_MODE</dt>
417         <dt>KMOD_CTRL </dt>
418         <dd>
419                 <p>same as KMOD_LCTRL|KMOD_RCTRL</p>
420         </dd>
421         <dt>KMOD_SHIFT</dt>
422         <dd>
423                 <p>same as KMOD_LSHIFT|KMOD_RSHIFT</p>
424         </dd>
425         <dt>KMOD_ALT</dt>
426         <dd>
427                 <p>same as KMOD_LALT|KMOD_RALT</p>
428         </dd>
429         <dt>KMOD_META</dt>
430         <dd>
431                 <p>same as KMOD_LMETA|KMOD_RMETA</p>
432         </dd>
433 </dl>
434
435 </div>
436 <h2 id="set_mod_state">set_mod_state</h2>
437 <div id="set_mod_state_CONTENT">
438 <p>Get the state of the modifier keys</p>
439 <p>The inverse of <a href="/SDL-Events.html#get_mod_state">SDL::Events::get_mod_state</a> allows you to impose modifier key states on your application.</p>
440 <p>Simply pass your desired modifier states into $modstate. This value can be a OR'd combination of any KMOD* constant.</p>
441 <pre> my $modstate = KMOD_LMETA | KMOD_LSHIFT;
442
443 </pre>
444 <p>Any KMOD_* constant see <a href="/SDL-Events.html#get_mod_state">SDL::Events::get_mod_state</a> for constants.
445  SDL::Events::set_mod_state( $modstate );</p>
446
447 </div>
448 <h2 id="event_state">event_state </h2>
449 <div id="event_state_CONTENT">
450 <p>Allows you to set the state of processing certain events</p>
451 <pre> SDL::Events::event_state( $type, $state );
452
453 </pre>
454 <p>A list of $type(s) can be found in <a href="SDL-Event.html">SDL::Event</a></p>
455
456 </div>
457 <h3 id="STATES">STATES</h3>
458 <div id="STATES_CONTENT">
459 <dl>
460         <dt>SDL_IGNORE</dt>
461         <dd>
462                 <p>The event of $type will be automatically dropper from the event queue and will not be filtered.</p>
463         </dd>
464         <dt>SDL_ENABLE</dt>
465         <dd>
466                 <p>The event of $type will be processed normally. This is default.</p>
467         </dd>
468         <dt>SDL_QUERY</dt>
469         <dd>
470                 <p>The current processing state of the $type will be returned</p>
471         </dd>
472 </dl>
473
474 </div>
475 <h2 id="get_key_name">get_key_name</h2>
476 <div id="get_key_name_CONTENT">
477 <p>Gets the name of the a SDL virtual keysym</p>
478 <pre> my $event = SDL::Event-&gt;new();
479
480  while( SDL::Events::poll_event($event) )
481  {
482    my $key = $event-&gt;key_sym;
483    $key_str = SDL::Events::get_key_name($key);
484  }
485
486 </pre>
487 <p>Returns a string with the name of the key sym.</p>
488
489 </div>
490 <h2 id="enable_unicode">enable_unicode </h2>
491 <div id="enable_unicode_CONTENT">
492 <p>Enable/Disable UNICODE translation</p>
493 <pre>  my $previous_translation_mode = SDL::Events::enable_unicode( 1 ); #enable
494      $previous_translation_mode = SDL::Events::enable_unicode( 0 ); #disables
495
496 </pre>
497 <p>To obtain the character codes corresponding to received keyboard events, Unicode translation must first be turned on using this function. The translation incurs a slight overhead for each keyboard event and is therefore disabled by default. For each subsequently recieved key down event, the unicode member of the <a href="/SDL-Event.html#key_sym">SDL::Event::key_sym</a> provided structure will be then contain the corresponding character code, or otherwise zero.</p>
498 <p>A value of 1 for enabling, 0 for disabling and -1 for unchanged. -1 is usefull for querying the current translation mode.</p>
499 <p>Only key press events will be translated not release events.</p>
500 <p>Returns the previous translation mode as (1,0).</p>
501
502 </div>
503 <h2 id="enable_key_repeat">enable_key_repeat </h2>
504 <div id="enable_key_repeat_CONTENT">
505 <p>Sets keyboard repeat rate</p>
506 <pre> my $success = SDL::Events::enable_key_repeat( $delay, $interval );
507
508 </pre>
509 <p>Enables or disables the keyboard repeat rate. $delay specifies how long the key must be pressed before it begins repeating, it then repleats at the speed specified by $interval. Both $delay and $interval are expressed in milliseconds.</p>
510 <p>Setting $delay to 0 disables key repeating completely. Good default values are SDL_DEFAULT_REPEAT_DELAY and SDL_DEFAULT_REPEAT_INTERVAL.</p>
511 <p>Return 0 on success and -1 on fail.</p>
512
513 </div>
514 <h2 id="get_mouse_state">get_mouse_state </h2>
515 <div id="get_mouse_state_CONTENT">
516 <p>Retrives the current state of the mouse</p>
517 <pre>   my ($mask,$x,$y) = @{ SDL::Events::get_mouse_state( ) };
518
519         print 'Button Left pressed' if ($mask &amp; SDL_BUTTON_LMASK);    
520
521         print 'Button Right pressed' if ($mask &amp; SDL_BUTTON_RMASK);   
522
523         print 'Button Middle pressed' if ($mask &amp; SDL_BUTTON_MMASK);  
524
525         print $x.','.$y;
526
527 </pre>
528 <p>The current button state is returned as a button $bitmask, which can be tested using the the above constants </p>
529
530 </div>
531 <h2 id="get_relative_mouse_state">get_relative_mouse_state </h2>
532 <div id="get_relative_mouse_state_CONTENT">
533 <p>Retrives the current relative state of the mouse</p>
534 <pre>   my ($mask,$x,$y) = @{ SDL::Events::get_mouse_state( ) };
535
536         print 'Button Left pressed' if ($mask &amp; SDL_BUTTON_LMASK);    
537
538         print 'Button Right pressed' if ($mask &amp; SDL_BUTTON_RMASK);   
539
540         print 'Button Middle pressed' if ($mask &amp; SDL_BUTTON_MMASK);  
541
542         print $x.','.$y; # this is relative to the last postion of the mouse
543
544 </pre>
545 <p>The current button state is returned as a button $bitmask, which can be tested using the the above constants </p>
546
547
548
549
550
551 </div>
552 <h2 id="get_app_state">get_app_state </h2>
553 <div id="get_app_state_CONTENT">
554 <p>Gets the state of the application</p>
555 <pre>   my $app_state = SDL::Events::get_app_state();
556
557 </pre>
558 <p>The $app_state is a bitwise combination of:</p>
559 <dl>
560         <dt>SDL_APPMOUSEFOCUS</dt>
561         <dd>
562                 <p>Application has mouse focus</p>
563 <pre>   warn 'mouse focus' if $app_state &amp; SDL_APPMOUSEFOCUS
564
565 </pre>
566         </dd>
567         <dt>SDL_APPINPUTFOCUS</dt>
568         <dd>
569                 <p>Application has keyboard focus</p>
570 <pre>   warn 'keyboard focus' if $app_state &amp; SDL_APPINPUTFOCUS
571
572
573
574
575 </pre>
576         </dd>
577         <dt>SDL_APPACTIVE</dt>
578         <dd>
579                 <p>Application is visible</p>
580 <pre>   warn 'Application Visible' if $app_state &amp; SDL_APPACTIVE
581
582 </pre>
583         </dd>
584 </dl>
585
586 </div>
587 <h2 id="joystick_event_state">joystick_event_state </h2>
588 <div id="joystick_event_state_CONTENT">
589 <p>Enable/disable joystick event polling</p>
590 <pre>   my $status = SDL::Events::joystick_event_state( $state );
591
592 </pre>
593 <p>This function is used to enable or disable joystick event processing. With joystick event processing disabled you will have to update joystick states with SDL_JoystickUpdate and read the joystick information manually. $state can be:</p>
594 <dl>
595         <dt>SDL_QUERY</dt>
596         <dt>SDL_ENABLE </dt>
597         <dt>SDL_IGNORE</dt>
598         <dd>
599                 <p>Joystick event handling is default. Even if joystick event processing is enabled, individual joysticks must be opened before they generate events</p>
600         </dd>
601 </dl>
602 <p><strong>Warning:</strong> Calling this function may delete all events currently in SDL's event queue.</p>
603 <p>If $state is SDL_QUERY then the current state is returned, otherwise the new processing state is returned.</p>
604
605 </div>
606 <h1 id="SEE_ALSO">SEE ALSO</h1><p><a href="#TOP" class="toplink">Top</a></p>
607 <div id="SEE_ALSO_CONTENT">
608 <p><a href="SDL-Event.html">SDL::Event</a>, <a href="SDL-Video.html">SDL::Video</a>
609 </p>
610
611 </div>
612 </div>