Next: , Previous: Video, Up: Top   [Contents][Index]


4 Events

Procedure: make-event [type]

Return a new SDL event. Optional arg type is a symbol (see event-type enums). If omitted, the default is SDL_NOEVENT.

Procedure: event:type event

Return the symbolic type from event.

Procedure: event:set-type! event value

Set type in event to value, a symbol or integer.

4.1 Activity

The value for event:active:gain and event:active:set-gain! is a symbol, one of: gained or lost.

The value for event:active:state and event:active:set-state! is a (possibly empty) list of symbols from the same set used by get-app-state.

Procedure: event:active:gain event

Return the symbolic active.gain from event.

Procedure: event:active:state event

Return active.state from event as a (possibly empty) list of symbols.

Procedure: event:active:set-gain! event value

Set active.gain in event to value, a symbol or integer.

Procedure: event:active:set-state! event value

Set active.state in event to value, a (possibly empty) list of symbols.

4.2 Keys

The value for event:key:state and event:key:set-state! is a symbol, one of: released or pressed.

Procedure: event:key:keysym:sym event

Return the symbolic key.keysym.sym from event.

Procedure: event:key:keysym:set-sym! event value

Set key.keysym.sym in event to value, a symbol or integer.

Procedure: event:key:keysym:mod event

Return key.keysym.mod from event as a (possibly empty) list of symbols.

Procedure: event:key:keysym:set-mod! event value

Set key.keysym.mod in event to value, a (possibly empty) list of symbols.

Procedure: event:key:state event

Return the symbolic key.state from event.

Procedure: event:key:keysym:scancode event

Get key.keysym.scancode from event.

Procedure: event:key:keysym:unicode event

Get key.keysym.unicode from event.

Procedure: event:key:set-state! event value

Set key.state in event to value, a symbol or integer.

Procedure: event:key:keysym:set-scancode! event value

Set key.keysym.scancode in event to value.

Procedure: event:key:keysym:set-unicode! event value

Set key.keysym.unicode in event to value.

4.3 Motions

Procedure: event:motion:state event

Return motion.state from event as a (possibly empty) list of symbols.

Procedure: event:motion:x event

Get motion.x from event.

Procedure: event:motion:y event

Get motion.y from event.

Procedure: event:motion:xrel event

Get motion.xrel from event.

Procedure: event:motion:yrel event

Get motion.yrel from event.

Procedure: event:motion:set-state! event value

Set motion.state in event to value, a (possibly empty) list of symbols.

Procedure: event:motion:set-x! event value

Set motion.x in event to value.

Procedure: event:motion:set-y! event value

Set motion.y in event to value.

Procedure: event:motion:set-xrel! event value

Set motion.xrel in event to value.

Procedure: event:motion:set-yrel! event value

Set motion.yrel in event to value.

4.4 Buttons

The value for event:button:button and event:button:set-button! is a (possibly empty) list of symbols from the set:

left middle right
wheel-up wheel-down
x1 x2

The value for event:button:state and event:button:set-state! is a symbol, one of: released or pressed.

Procedure: event:button:button event

Return the symbolic button.button from event.

Procedure: event:button:state event

Return the symbolic button.state from event.

Procedure: event:button:x event

Get button.x from event.

Procedure: event:button:y event

Get button.y from event.

Procedure: event:button:set-button! event value

Set button.button in event to value, a symbol or integer.

Procedure: event:button:set-state! event value

Set button.state in event to value, a symbol or integer.

Procedure: event:button:set-x! event value

Set button.x in event to value.

Procedure: event:button:set-y! event value

Set button.y in event to value.

4.5 Joysticks

The value for event:jbutton:state and event:jbutton:set-state! is a symbol, one of: released or pressed.

The value for event:jhat:value and event:jhat:set-value! is a list of or more symbols from the set:

centered
up    down
left  right

Specifying the empty list for event:jhat:set-value! is effectively the same as specifying centered.

Procedure: event:jaxis:which event

Get jaxis.which from event.

Procedure: event:jaxis:axis event

Get jaxis.axis from event.

Procedure: event:jaxis:value event

Get jaxis.value from event.

Procedure: event:jaxis:set-which! event value

Set jaxis.which in event to value.

Procedure: event:jaxis:set-axis! event value

Set jaxis.axis in event to value.

Procedure: event:jaxis:set-value! event value

Set jaxis.value in event to value.

Procedure: event:jbutton:which event

Get jbutton.which from event.

Procedure: event:jbutton:button event

Get jbutton.button from event.

Procedure: event:jbutton:state event

Return the symbolic jbutton.state from event.

Procedure: event:jbutton:set-which! event value

Set jbutton.which in event to value.

Procedure: event:jbutton:set-button! event value

Set jbutton.button in event to value.

Procedure: event:jbutton:set-state! event value

Set jbutton.state in event to value, a symbol or integer.

Procedure: event:jball:which event

Get jball.which from event.

Procedure: event:jball:ball event

Get jball.ball from event.

Procedure: event:jball:xrel event

Get jball.xrel from event.

Procedure: event:jball:yrel event

Get jball.yrel from event.

Procedure: event:jball:set-which! event value

Set jball.which in event to value.

Procedure: event:jball:set-ball! event value

Set jball.ball in event to value.

Procedure: event:jball:set-xrel! event value

Set jball.xrel in event to value.

Procedure: event:jball:set-yrel! event value

Set jball.yrel in event to value.

Procedure: event:jhat:which event

Get jhat.which from event.

Procedure: event:jhat:hat event

Get jhat.hat from event.

Procedure: event:jhat:value event

Return jhat.value from event as a (possibly empty) list of symbols.

Procedure: event:jhat:set-which! event value

Set jhat.which in event to value.

Procedure: event:jhat:set-hat! event value

Set jhat.hat in event to value.

Procedure: event:jhat:set-value! event value

Set jhat.value in event to value, a (possibly empty) list of symbols.

4.6 Resizes

Procedure: event:resize:w event

Get resize.w from event.

Procedure: event:resize:h event

Get resize.h from event.

Procedure: event:resize:set-w! event value

Set resize.w in event to value.

Procedure: event:resize:set-h! event value

Set resize.h in event to value.

4.7 Misc

Procedure: pump-events

Gather events from input devices and update the event queue.

Procedure: evqueue-add [events…]

Add events to the back of the event queue. Return the count of succesfully added events.

Procedure: evqueue-peek n mask [accumulate]

Return a count (less than or equal to n) of events at the front of the event queue that match mask, without changing the queue. Optional arg accumulate if non-#f means to return the list of matched events, instead. If there are errors, return #f.

See event-mask flags.

Procedure: evqueue-get n mask

Return a list (of length at most n) of events at the front of the event queue that match mask, removing them from the queue. If there are errors, return #f.

See event-mask flags.

Procedure: peep-events events numevents action mask

NB: This procedure is obsoleted by evqueue-add, evqueue-peek and evqueue-get; it will be removed after 2013-12-31.

Manage the event queue, depending on action (see event-action enums):

SDL_ADDEVENT

Add up to numevents (an integer) events from events (a list) to the back of the event queue.

SDL_PEEKEVENT

Return a count (number less than or equal to numevents) of events at the front of the event queue that match mask (see event-mask flags), without changing the queue.

SDL_GETEVENT

Act like for SDL_PEEKEVENT except return a list of matching events instead of a count, removing them from the queue.

Procedure: poll-event [event]

Poll for events and return #t if there are any pending. Optional arg event specifies an event object (from make-event) to be filled in with the next event from the queue (if available).

Procedure: wait-event [event]

Wait indefinitely for and return #f only if there were errors. Optional arg event specifies an event object (from make-event) to be filled in with the next event from the queue.

Procedure: push-event event

Push event onto the queue. Return #t on success.

Procedure: set-event-filter filter full?

Set the event filter to filter, or clear it if filter is #f. This is a procedure called with one arg, and whose return value, if non-#f, means to keep the event, otherwise discard it. If full? is #f, the arg the event type (a symbol), otherwise it is an event object.

Procedure: get-event-filter

Return information on the current event filter, or #f if none is set. If there is a filter, the value is a pair with car the filter proc, and cdr #f if the proc takes an event type, or #t if the proc takes an event object.

Procedure: event-type-handling type [setting]

Return #t if event type (see event-type enums) is recognized and queued, or #f if it is ignored. If setting is specified, set the handling of type to the truth value of setting first.

Procedure: event-state type state

NB: This procedure is obsoleted by event-type-handling and will be removed after 2013-12-31.

Set or query the state of event type (see event-type enums) processing, based on state (see event-state enums). If state is SDL_QUERY, return the current state. If it is SDL_IGNORE or SDL_ENABLE, disable or enable, respectively, internal event type processing and return state.

Procedure: enable-unicode [enable-p]

Return #t iff UNICODE keyboard translation is enabled. Optional arg enable? if non-#f, enables UNICODE keyboard translation, or disables it if #f.

Procedure: enable-key-repeat delay interval

Enable or disable keyboard repeat. delay is the initial delay in ms between the time when a key is pressed, and keyboard repeat begins. interval is the time in ms between keyboard repeat events. If delay is 0, keyboard repeat is disabled. Return #t on success.

Procedure: get-key-state

Return a list of pressed keys (see keysym enums).

Procedure: get-mod-state

Return the current key modifier state as a list of symbols.

Procedure: set-mod-state modstate

Set the current key modifier state to modstate, a list of symbols. This does not change the keyboard state, only the key modifier flags.

Procedure: get-mouse-state [symbolic]

NB: This procedure is obsoleted by mouse-bxy and will be removed after 2013-12-31.

Return the current state of the mouse as an alist with symbolic keys: state, x and y. Normally, all values are integers. However, if optional arg symbolic is non-#f, the state value is instead a (possibly empty) list of symbols of the set:

left middle right
wheel-up wheel-down
x1 x2
Procedure: get-mouse-relative-state [symbolic]

NB: This procedure is obsoleted by mouse-bxy and will be removed after 2013-12-31.

Return the current relative state of the mouse as an alist with symbolic keys: state, x and y. Optional arg symbolic has the same effect as for get-mouse-state.

Procedure: button? mask

Return #t if buttons specified in mask are pressed, otherwise #f. mask is a symbol or a list of symbols from the set returned by get-mouse-state.

For backward compatability, mask can also be the (integer) logior of the buttons, using mapping:

 1  left
 2  middle
 4  right
 8  wheel-up
16  wheel-down
32  x1
64  x2

For example, a value of 5 specifies both left and right buttons, equivalent to (left right).

Procedure: mouse-bxy [relative]

Return three values: a (possibly empty) list of symbols representing pressed mouse buttons (like event:button:button), and two integer coordinates x and y.

Optional arg relative non-#f means the coordinates are relative to the last time the underlying SDL_GetRelativeMouseState was called.


Next: , Previous: Video, Up: Top   [Contents][Index]