NAME

SYNOPSIS

DESCRIPTION

SDL::Event->new(); creates a SDL_Event structure, into
which events may be stored.

$event->type()

This function returns the event type which will be one of
the values: SDL_ACTIVEEVENT, SDL_KEYDOWN, SDL_KEYUP, SDL_MOUSEMOTION,
SDL_MOUSEBUTTONDOWN, SDL_MOUSEBUTTONUP, SDL_QUIT,SDL_SYSWMEVENT.

Gathering Events

$event->poll();
$event->pump();
$event->wait();

These three methods can be used to gather new events. Poll and pump should be used together. Pump will collect events, and poll will read events from the stack, returning 0 if no events were found. Similarly wait will wait for an event to occur, and then return.

Active Events

These events indicate a change in the state of the application. The methods which access the event's properties are:

$event->gain();
$event->state();

The possible states that an event may return are: SDL_APPMOUSEFOCUS, SDL_APPINPUTFOCUS, and SDL_APPACTIVE.

Key Events

Everytime a key is pressed or release, while the app has input focus, a key event will be generated. The following methods provide access to the event's fileds:

Key_state will return either SDL_PRESSED or SDL_RELEASED. Key_name will return a string giving the name of the key. Sym will return the SDL key symbol code, which can be checked against the SDLK_* entries as specified in the SDL documentation. (ie sym 27 is SDLK_ESCAPE). Likewise, key_mod will return the current modifier state of the key and can be or'ed against the KMOD_* masks as per the SDL documentation.

To enable unicode support, one must first call

$event->set_unicode(1);

there after each event will fill out the unicode field. The key_unicode function returns the integer of the unicode key. Similarly, key_scancode will return the raw scancode from the key event.

Mouse Events

There are two types of mouse related events, motion and button. The exact type is important as there are separate methodss for reading from each. For motion events one should use: