Commit | Line | Data |
9b6fa14c |
1 | <div class="pod"> |
2 | <!-- INDEX START --> |
3 | <h3 id="TOP">Index</h3> |
4 | |
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="#pump_events">pump_events</a></li> |
10 | <li><a href="#peep_events_event_num_events_action_">peep_events (event, num_events, action, mask) </a> |
11 | <ul><li><a href="#RETURN">RETURN</a></li> |
12 | </ul> |
13 | </li> |
14 | <li><a href="#poll_event_event">poll_event($event)</a> |
15 | <ul><li><a href="#RETURN-2">RETURN</a></li> |
16 | </ul> |
17 | </li> |
18 | <li><a href="#push_event_event">push_event($event)</a> |
19 | <ul><li><a href="#RETURN-3">RETURN</a></li> |
20 | </ul> |
21 | </li> |
22 | <li><a href="#wait_event_event">wait_event($event)</a> |
23 | <ul><li><a href="#RETURN-4">RETURN</a></li> |
24 | </ul> |
25 | </li> |
26 | </ul> |
27 | </li> |
28 | <li><a href="#SEE_ALSO">SEE ALSO</a> |
29 | </li> |
30 | </ul><hr /> |
31 | <!-- INDEX END --> |
32 | |
33 | <h1 id="NAME">NAME</h1><p><a href="#TOP" class="toplink">Top</a></p> |
34 | <div id="NAME_CONTENT"> |
35 | <p>SDL::Events - Bindings to the Events Category in SDL API</p> |
36 | |
37 | </div> |
38 | <h1 id="SYNOPSIS">SYNOPSIS</h1><p><a href="#TOP" class="toplink">Top</a></p> |
39 | <div id="SYNOPSIS_CONTENT"> |
40 | <p>Most likely you just want to know how to get events for you app. |
41 | use SDL; |
42 | use SDL::Event; |
43 | use SDL::Events;</p> |
44 | <pre> SDL::init(SDL_INIT_VIDEO); # Event can only be grabbed in the same thread as this |
45 | |
46 | ... |
47 | |
48 | my $event = SDL::Event->new(); # notices 'Event' ne 'Events' |
49 | |
50 | while( 1 ) |
51 | { |
52 | SDL::Events::pump_events(); |
53 | while( SDL::Events::poll_event($event) ) |
54 | { |
55 | #check by event type |
56 | on_active() if $event->type == SDL_ACTIVEEVENT; |
57 | ... |
58 | } |
59 | } |
60 | |
61 | </pre> |
62 | |
63 | </div> |
64 | <h1 id="DESCRIPTION">DESCRIPTION</h1><p><a href="#TOP" class="toplink">Top</a></p> |
65 | <div id="DESCRIPTION_CONTENT"> |
66 | |
67 | |
68 | |
69 | |
70 | |
71 | </div> |
72 | <h1 id="METHODS">METHODS</h1><p><a href="#TOP" class="toplink">Top</a></p> |
73 | <div id="METHODS_CONTENT"> |
74 | |
75 | </div> |
76 | <h2 id="pump_events">pump_events</h2> |
77 | <div id="pump_events_CONTENT"> |
78 | <p>Pumps the event loop, gathering events from the input devices.</p> |
79 | <pre> pump_events(); |
80 | |
81 | </pre> |
82 | <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. |
83 | Often the need for calls to pump_events is hidden from the user since <cite>poll_event</cite> and <cite>wait_event</cite> implicitly call pump_events. |
84 | 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> |
85 | |
86 | |
87 | |
88 | |
89 | |
90 | </div> |
91 | <h2 id="peep_events_event_num_events_action_">peep_events (event, num_events, action, mask) </h2> |
92 | <div id="peep_events_event_num_events_action_-2"> |
93 | <p>Checks the event queue for messages and optionally returns them. </p> |
94 | <pre> my $num_peep_events = SDL::Events::peep_events($event, 127, SDL_PEEKEVENT, SDL_ALLEVENTS); |
95 | |
96 | </pre> |
97 | <p>If action is SDL_ADDEVENT, up to numevents events will be added to the back of the event queue.</p> |
98 | <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> |
99 | <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> |
100 | <p>The mask parameter is a bitwise OR of SDL::Events::SDL_EVENTMASK(event_type), for all event types you are interested in</p> |
101 | <p>This function is thread-safe.</p> |
102 | <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> |
103 | <p>Examples of mask:</p> |
104 | <dl> |
105 | <dt>SDL_EVENTMASK (SDL_KEYUP)</dt> |
106 | <dt>(SDL_EVENTMASK (SDL_MOUSEBUTTONDOWN) | SDL_EVENTMASK (SDL_MOUSEBUTTONUP))</dt> |
107 | <dt>SDL_ALLEVENTS</dt> |
108 | <dt>SDL_KEYUPMASK</dt> |
109 | <dt>SDL_ALLEVENTS ^ SDL_QUITMASK</dt> |
110 | </dl> |
111 | |
112 | </div> |
113 | <h3 id="RETURN">RETURN</h3> |
114 | <div id="RETURN_CONTENT"> |
115 | <p>Number of Events actually stored or -1 if there was an error</p> |
116 | |
117 | </div> |
118 | <h2 id="poll_event_event">poll_event($event)</h2> |
119 | <div id="poll_event_event_CONTENT"> |
120 | <p>Polls for currently pending events. </p> |
121 | <p>If $event is not NULL, the next event is removed from the queue and stored in the <cite>SDL::Event</cite> structure pointed to by $event.</p> |
122 | <p>As this function implicitly calls pump_events, you can only call this function in the thread that set the video mode with <cite>SDL::Video::set_video_mode</cite>. </p> |
123 | |
124 | </div> |
125 | <h3 id="RETURN-2">RETURN</h3> |
126 | <div id="RETURN_CONTENT-2"> |
127 | <p>Returns 1 if there are any pending events, or 0 if there are none available. </p> |
128 | |
129 | </div> |
130 | <h2 id="push_event_event">push_event($event)</h2> |
131 | <div id="push_event_event_CONTENT"> |
132 | <p>Pushes an event onto the event queue </p> |
133 | <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. |
134 | The event is copied into the queue, and the caller may dispose of the memory pointed to after push_event returns.</p> |
135 | <p>Note: Pushing device input events onto the queue doesn't modify the state of the device within SDL. </p> |
136 | <p>This function is thread safe, and can be called from other threads safely.</p> |
137 | |
138 | </div> |
139 | <h3 id="RETURN-3">RETURN</h3> |
140 | <div id="RETURN_CONTENT-3"> |
141 | <p>Returns 0 on success or -1 if the event couldn't be pushed.</p> |
142 | |
143 | </div> |
144 | <h2 id="wait_event_event">wait_event($event)</h2> |
145 | <div id="wait_event_event_CONTENT"> |
146 | <p>Waits indefinitely for the next available $event, returning 0 if there was an error while waiting for events, 1 otherwise.</p> |
147 | <p>If $event is not NULL, the next event is removed from the queue and stored in $event.</p> |
148 | <p>As this function implicitly calls SDL_PumpEvents, you can only call this function in the thread that <cite>SDL::Video::set_video_mode</cite>. </p> |
149 | |
150 | </div> |
151 | <h3 id="RETURN-4">RETURN</h3> |
152 | <div id="RETURN_CONTENT-4"> |
153 | <p>0 if there was an error while waiting for events, 1 otherwise</p> |
154 | |
155 | </div> |
156 | <h1 id="SEE_ALSO">SEE ALSO</h1><p><a href="#TOP" class="toplink">Top</a></p> |
157 | <div id="SEE_ALSO_CONTENT"> |
158 | <p><cite>SDL::Event</cite>, <cite>SDL::Video</cite></p> |
159 | |
160 | </div> |
161 | </div> |