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 return SDL::PushEvent($$self);
52 return SDL::WaitEvent($$self);
58 return SDL::EventState($self->type(),$state);
64 return SDL::EnableUnicode($toggle);
71 return SDL::EnableKeyRepeat($delay,$interval);
76 return SDL::ActiveEventGain($$self);
81 return SDL::ActiveEventState($$self);
86 return SDL::KeyEventState($$self);
91 return SDL::KeyEventSym($$self);
96 return SDL::GetKeyName(SDL::KeyEventSym($$self));
101 return SDL::KeyEventMod($$self);
106 return SDL::KeyEventUnicode($$self);
111 return SDL::KeyEventScanCode($$self);
116 return SDL::MouseMotionState($$self);
121 return SDL::MouseMotionX($$self);
126 return SDL::MouseMotionY($$self);
131 return SDL::MouseMotionXrel($$self);
136 return SDL::MouseMotionYrel($$self);
141 return SDL::MouseButtonState($$self);
146 return SDL::MouseButtonX($$self);
151 return SDL::MouseButtonY($$self);
156 return SDL::MouseButton($$self);
161 SDL::ResizeEventW($$self);
166 SDL::ResizeEventH($$self);
177 SDL::Event - a SDL perl extension
182 my $event = new SDL::Event; # create a new event
183 while ($event->wait()) {
184 my $type = $event->type(); # get event type
186 exit if $type == SDL_QUIT;
191 C<SDL::Event> offers an object-oriented approach to SDL events. By creating
192 an instance of SDL::Event via new() you can wait for events, and then determine
193 the type of the event and take an appropriate action.
197 Here is an example of a simple event handler loop routine.
198 See also L<SDL::App::loop>.
201 my ($self,$href) = @_;
202 my $event = new SDL::Event;
203 while ( $event->wait() ) {
204 # ... insert here your event handling like:
205 if ( ref($$href{$event->type()}) eq "CODE" ) {
206 &{$$href{$event->type()}}($event);
216 Create a new event object.
220 Returns the type of the event, see list of exported symbols for which are
225 Pumps the event loop, gathering events from the input devices.
229 Polls for currently pending events
233 Waits for an event end returns then. Always returns true.
235 =head2 set( type, state )
237 Set the state for all events of the given event's type
239 =head2 set_unicode( toggle )
241 Toggle unicode on the event.
243 =head2 set_key_repeat( delay, interval)
245 Sets the delay and intervall of the key repeat rate (e.g. when a user
246 holds down a key on the keyboard).
250 =head2 active_state()
262 =head2 key_scancode()
264 =head2 motion_state()
268 Returns the motion of the mouse in X direction as an absolute value.
272 Returns the motion of the mouse in Y direction as an absolute value.
276 Returns the motion of the mouse in X direction as a relative value.
280 Returns the motion of the mouse in Y direction as a relative value.
282 =head2 button_state()
284 Returns the state of the mouse buttons.
295 Documentation by Tels <http://bloodgate.com/>