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