3 # A package for handling SDL_Event *
5 # Copyright (C) 2000,2001,2002 David J. Goehrig
6 # Copyright (C) 2009 Kartik Thakore
7 # see the file COPYING for terms of use
16 my $class = ref($proto) || $proto;
18 $self = \SDL::NewEvent();
25 SDL::FreeEvent($$self);
31 SDL::SetEventType($$self,$_[0]);
33 return SDL::EventType($$self);
42 return SDL::PollEvent($$self);
47 my ($event, $numEvents, $action, $mask) = @_;
48 return SDL::PeepEvents($$event, $numEvents, $action, $mask);
53 return SDL::PushEvent($$self);
58 return SDL::WaitEvent($$self);
64 return SDL::EventState($self->type(),$state);
70 return SDL::EnableUnicode($toggle);
77 return SDL::EnableKeyRepeat($delay,$interval);
82 return SDL::ActiveEventGain($$self);
87 return SDL::ActiveEventState($$self);
92 return SDL::KeyEventState($$self);
97 return SDL::KeyEventSym($$self);
102 return SDL::GetKeyName(SDL::KeyEventSym($$self));
107 return SDL::KeyEventMod($$self);
112 return SDL::KeyEventUnicode($$self);
117 return SDL::KeyEventScanCode($$self);
122 return SDL::MouseMotionState($$self);
127 return SDL::MouseMotionX($$self);
132 return SDL::MouseMotionY($$self);
137 return SDL::MouseMotionXrel($$self);
142 return SDL::MouseMotionYrel($$self);
147 return SDL::MouseButtonState($$self);
152 return SDL::MouseButtonX($$self);
157 return SDL::MouseButtonY($$self);
162 return SDL::MouseButton($$self);
167 SDL::ResizeEventW($$self);
172 SDL::ResizeEventH($$self);
183 SDL::Event - a SDL perl extension
188 my $event = new SDL::Event; # create a new event
189 while ($event->wait()) {
190 my $type = $event->type(); # get event type
192 exit if $type == SDL_QUIT;
197 C<SDL::Event> offers an object-oriented approach to SDL events. By creating
198 an instance of SDL::Event via new() you can wait for events, and then determine
199 the type of the event and take an appropriate action.
203 Here is an example of a simple event handler loop routine.
204 See also L<SDL::App::loop>.
207 my ($self,$href) = @_;
208 my $event = new SDL::Event;
209 while ( $event->wait() ) {
210 # ... insert here your event handling like:
211 if ( ref($$href{$event->type()}) eq "CODE" ) {
212 &{$$href{$event->type()}}($event);
222 Create a new event object.
226 Returns the type of the event, see list of exported symbols for which are
231 Pumps the event loop, gathering events from the input devices.
235 Polls for currently pending events
239 Checks the event queue for messages and optionally returns them.
241 If action is SDL_ADDEVENT, up to numevents events will be added to the back of the event queue.
243 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.
245 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.
247 The mask parameter is a bitwise OR of SDL_EVENTMASK(event_type), for all event types you are interested in
252 Waits for an event end returns then. Always returns true.
254 =head2 set( type, state )
256 Set the state for all events of the given event's type
258 =head2 set_unicode( toggle )
260 Toggle unicode on the event.
262 =head2 set_key_repeat( delay, interval)
264 Sets the delay and intervall of the key repeat rate (e.g. when a user
265 holds down a key on the keyboard).
269 =head2 active_state()
281 =head2 key_scancode()
283 =head2 motion_state()
287 Returns the motion of the mouse in X direction as an absolute value.
291 Returns the motion of the mouse in Y direction as an absolute value.
295 Returns the motion of the mouse in X direction as a relative value.
299 Returns the motion of the mouse in Y direction as a relative value.
301 =head2 button_state()
303 Returns the state of the mouse buttons.
314 Documentation by Tels <http://bloodgate.com/>