SDL2 multimedia library for 2D graphics, input handling, audio playback, and window management. Core types: Window, Renderer, Texture, Surface, Event, and Mixer. Compile with -lib sdl2.
Event
SDL event
Operations
- New
- Flush
- Free
- GetControllerAxis
- GetControllerButton
- GetControllerDevice
- GetDrop
- GetJAxis
- GetJButton
- GetJHat
- GetKey
- GetMButton
- GetMouseButton
- GetMouseMotion
- GetMouseWheel
- GetTextEditing
- GetTextInput
- GetTouchFinger
- GetType
- GetUser
- GetWindow
- Has
- IsNull
- Peeps
- Poll
- Pump
- Push
- Registers
- SetUser
- State
- Wait
- WaitTimeout
Flush # function
Clear events from the event queue
function : Flush(type:Int) ~ NilParameters
| Name | Type | Description |
|---|---|---|
| type | Int | the type of event to be cleared |
GetControllerAxis #
Get game controller axis event
method : public : GetControllerAxis() ~ ControllerAxisEventReturn
| Type | Description |
|---|---|
| ControllerAxisEvent | controller axis event, or Nil if this is not an EventType->SDL_CONTROLLERAXISMOTION |
GetControllerButton #
Get game controller button event
method : public : GetControllerButton() ~ ControllerButtonEventReturn
| Type | Description |
|---|---|
| ControllerButtonEvent | controller button event, or Nil if this is not an EventType->SDL_CONTROLLERBUTTONDOWN or SDL_CONTROLLERBUTTONUP |
GetControllerDevice #
Get game controller device event
method : public : GetControllerDevice() ~ ControllerDeviceEventReturn
| Type | Description |
|---|---|
| ControllerDeviceEvent | controller device event, or Nil if this is not a controller added, removed or remapped event |
GetDrop #
Get drop event. The dropped path is released by SDL on the first read; reading the same event again returns the same value.
method : public : GetDrop() ~ DropEventReturn
| Type | Description |
|---|---|
| DropEvent | drop event, or Nil if this is not a drop event |
GetJAxis #
Get joystick axis event
method : public : GetJAxis() ~ JoyAxisEventReturn
| Type | Description |
|---|---|
| JoyAxisEvent | joystick axis event |
GetJButton #
Get joystick button event
method : public : GetJButton() ~ JoyButtonEventReturn
| Type | Description |
|---|---|
| JoyButtonEvent | joystick button event |
GetJHat #
Get joystick hat event
method : public : GetJHat() ~ JoyHatEventReturn
| Type | Description |
|---|---|
| JoyHatEvent | joystick hat event |
GetKey #
Get keyboard event
method : public : GetKey() ~ KeyboardEventReturn
| Type | Description |
|---|---|
| KeyboardEvent | keyboard event |
GetMButton #
Get mouse button event
method : public : GetMButton() ~ MouseButtonEventReturn
| Type | Description |
|---|---|
| MouseButtonEvent | mouse button event |
GetMouseButton #
Get mouse button event.
MouseButtonEvent existed but nothing returned one, so a click could not be read anywhere in the tree.
method : public : GetMouseButton() ~ MouseButtonEventReturn
| Type | Description |
|---|---|
| MouseButtonEvent | the button event, or Nil if this is not a button event |
GetMouseMotion #
Get mouse motion event
method : public : GetMouseMotion() ~ MouseMotionEventReturn
| Type | Description |
|---|---|
| MouseMotionEvent | mouse motion event |
GetMouseWheel #
Get mouse wheel event
method : public : GetMouseWheel() ~ MouseWheelEventReturn
| Type | Description |
|---|---|
| MouseWheelEvent | mouse wheel event |
GetTextEditing #
Get text editing (IME composition) event
method : public : GetTextEditing() ~ TextEditingEventReturn
| Type | Description |
|---|---|
| TextEditingEvent | text editing event, or Nil if this is not an EventType->SDL_TEXTEDITING |
GetTextInput #
Get text input event
method : public : GetTextInput() ~ TextInputEventReturn
| Type | Description |
|---|---|
| TextInputEvent | text input event |
GetTouchFinger #
Get touch finger event
method : public : GetTouchFinger() ~ TouchFingerEventReturn
| Type | Description |
|---|---|
| TouchFingerEvent | touch finger event, or Nil if this is not an EventType->SDL_FINGERDOWN, SDL_FINGERUP or SDL_FINGERMOTION |
GetUser #
Get user event
method : public : GetUser() ~ UserEventReturn
| Type | Description |
|---|---|
| UserEvent | user event, or Nil if the type is below EventType->SDL_USEREVENT |
GetWindow #
Get window event
method : public : GetWindow() ~ WindowEventReturn
| Type | Description |
|---|---|
| WindowEvent | window event, or Nil if this is not an EventType->SDL_WINDOWEVENT |
Has # function
Check for the existence of certain event types in the event queue
function : Has(type:Int) ~ BoolParameters
| Name | Type | Description |
|---|---|---|
| type | Int | the type of event to be queried |
Return
| Type | Description |
|---|---|
| Bool | true if events matching type are present, false otherwise |
IsNull #
Determines if the underlying SDL C-struct is NULL
method : public : IsNull() ~ BoolReturn
| Type | Description |
|---|---|
| Bool | true if NULL, false otherwise |
Peeps #
Check the event queue for messages and optionally return them
method : public : Peeps(numevents:Int, action:EventAction, minType:Int, maxType:Int) ~ IntParameters
| Name | Type | Description |
|---|---|---|
| numevents | Int | if action is SDL_ADDEVENT, the number of events to add back to the event queue; if action is SDL_PEEKEVENT or SDL_GETEVENT, the maximum number of events to retrieve |
| action | EventAction | action to take; see Remarks for details |
| minType | Int | minimum value of the event type to be considered; SDL_FIRSTEVENT is a safe choice |
| maxType | Int | maximum value of the event type to be considered; SDL_LASTEVENT is a safe choice |
Return
| Type | Description |
|---|---|
| Int | number of events actually stored or a negative error code on failure |
Push #
Add an event to the event queue
method : public : Push() ~ IntReturn
| Type | Description |
|---|---|
| Int | 1 on success, 0 if the event was filtered, or -1 if the event queue was full or there was some other error. |
Registers # function
Allocate a set of user-defined events, and return the beginning event number for that set of events
function : Registers(numevents:Int) ~ IntParameters
| Name | Type | Description |
|---|---|---|
| numevents | Int | the number of events to be allocated |
SetUser #
Fill this event in as a user event, ready to Push
method : public : SetUser(type:Int, code:Int, window_id:Int) ~ BoolParameters
| Name | Type | Description |
|---|---|---|
| type | Int | event type from Event->Registers |
| code | Int | application defined code |
| window_id | Int | associated window ID, or 0 |
Return
| Type | Description |
|---|---|
| Bool | true on success, false if type is not a user event type |
Example
type := Event->Registers(1);
event := Event->New();
if(event->SetUser(type, 42, 0)) {
event->Push();
};State # function
Allows you to set the state of processing certain events.
function : State(type:Int, state:Int) ~ IntParameters
| Name | Type | Description |
|---|---|---|
| type | Int | the type of event; see SDL_EventType for details |
| state | Int | how to process the event; see Remarks for details |
Return
| Type | Description |
|---|---|
| Int | SDL_DISABLE or SDL_ENABLE, representing the processing state of the event before this function makes any changes to it |
Wait #
Waits indefinitely for the next available event.
method : public : Wait() ~ IntReturn
| Type | Description |
|---|---|
| Int | 1, or 0 if there was an error while waiting for events |
WaitTimeout #
Waits until the specified timeout (in milliseconds) for the next available event
method : public : WaitTimeout(timeout:Int) ~ IntParameters
| Name | Type | Description |
|---|---|---|
| timeout | Int | The timeout (in milliseconds) to wait for next event |
Return
| Type | Description |
|---|---|
| Int | 1, or 0 if there was an error while waiting for events |