SDL::Event - a SDL perl extension
use SDL::Event; my $event = new SDL::Event; # create a new event while ($event->wait()) { my $type = $event->type(); # get event type # ... handle event exit if $type == SDL_QUIT; }
SDL::Event offers an object-oriented approach to SDL events. By creating an instance of SDL::Event via new() you can wait for events, and then determine the type of the event and take an appropriate action.
SDL::Event
Here is an example of a simple event handler loop routine. See also SDL::App::loop.
sub loop { my ($self,$href) = @_; my $event = new SDL::Event; while ( $event->wait() ) { # ... insert here your event handling like: if ( ref($$href{$event->type()}) eq "CODE" ) { &{$$href{$event->type()}}($event); $self->sync(); } } }
Create a new event object.
Returns the type of the event, see list of exported symbols for which are available.
Waits for an event end returns then. Always returns true.
Set the state for all events of the given event's type
Toggle unicode on the event.
Sets the delay and intervall of the key repeat rate (e.g. when a user holds down a key on the keyboard).
Returns the motion of the mouse in X direction as an absolute value.
Returns the motion of the mouse in Y direction as an absolute value.
Returns the motion of the mouse in X direction as a relative value.
Returns the motion of the mouse in Y direction as a relative value.
Returns the state of the mouse buttons.
David J. Goehrig Documentation by Tels <http://bloodgate.com/>
perl SDL::App
To install SDL, copy and paste the appropriate command in to your terminal.
cpanm
cpanm SDL
CPAN shell
perl -MCPAN -e shell install SDL
For more information on module installation, please visit the detailed CPAN module installation guide.