Class EventManager
Manages event polling, event queue and input state.
class EventManager
: dlib .core .ownership .Owner;
Constructors
| Name | Description |
|---|---|
this
(app)
|
Constructs an EventManager for the given Application.
|
Fields
| Name | Type | Description |
|---|---|---|
application
|
Application | Application object that owns this EventManager. |
controllerAxisThreshold
|
int | A maximum that controller axis value is clamped to (for normalization in 0..1 range). |
controllerButtonDown
|
bool[255][4] | Controller button went down this frame (valid only if trackUpDownState is true).
|
controllerButtonPressed
|
bool[255][4] | Controller button is currently pressed/released. |
controllerButtonUp
|
bool[255][4] | Controller button went up this frame (valid only if trackUpDownState is true).
|
deltaTime
|
double | Time in seconds since the last updateTimer call.
|
deltaTimeMs
|
ulong | Time in milliseconds since the last updateTimer call.
|
displayHeight
|
uint | Height of the screen. |
displayWidth
|
uint | Width of the screen. |
drawableHeight
|
int | Application's main window drawable height. |
drawableWidth
|
int | Application's main window drawable width. |
enableKeyRepeat
|
bool | Switch key repeat. |
gameInputDevices
|
GameInputDevice[4] | Opened controllers/joysticks. |
graphicsTablet
|
GraphicsTablet | PenMotion events emitter.
|
inboxEventQueue
|
Event[50] | Inbox event queue. All synchronous events from SDL (such as user input) go here. Inbox queue is cleared at the beginning of each event loop iteration, so for emitting custom events, outboxEventQueue should be used. |
inputManager
|
InputManager | Configurable input manager. |
joystickButtonDown
|
bool[255][4] | Joystick button went down this frame (valid only if trackUpDownState is true).
|
joystickButtonPressed
|
bool[255][4] | Joystick button is currently pressed/released. |
joystickButtonUp
|
bool[255][4] | Joystick button went up this frame (valid only if trackUpDownState is true).
|
keyDown
|
bool[512] | Keyboard key went down this frame (valid only if trackUpDownState is true).
|
keyPressed
|
bool[512] | Keyboard key is currently pressed/released. |
keyUp
|
bool[512] | Keyboard key went up this frame (valid only if trackUpDownState is true).
|
messageBroker
|
MessageBroker | Message broker for distributing messages and scheduling tasks. |
mouseButtonDown
|
bool[255] | Mouse button went down this frame (valid only if trackUpDownState is true).
|
mouseButtonPressed
|
bool[255] | Mouse button is currently pressed/released. |
mouseButtonUp
|
bool[255] | Mouse button went up this frame (valid only if trackUpDownState is true).
|
mouseRelX
|
int | Relative change of the X-coordinate of the mouse pointer's position. |
mouseRelY
|
int | Relative change of the Y-coordinate of the mouse pointer's position. |
mouseX
|
int | Mouse pointer's X-coordinate relative to the window. |
mouseY
|
int | Mouse pointer's Y-coordinate relative to the window. |
numGameInputDevices
|
uint | Number of recognized controllers/joysticks. |
numInboxEvents
|
uint | Number of events in the inbox queue. |
numOutboxEvents
|
uint | Number of events in the outbox queue. |
onProcessEvent
|
void delegate(sdl | Event dispatching hook. Provide your delegate to receive SDL events directly. |
outboxEventQueue
|
Event[50] | Outbox event queue. All external events (user events, messages, tasks) should go here. |
running
|
bool | Used by Application to indicate activity. Set to false to stop the main loop. |
tmpHeap
|
dlib | Temporary heap allocator to create short-living objects for custom events. tmpHeap is invalidated each step when there are no more pending outbox events. It is mostly used to create payload data which should be immediately byte-copied when event is dispatched. |
trackUpDownState
|
bool | Whether to update up/down states for keys and buttons. |
window
|
sdl | A pointer to main application window. |
windowFocused
|
bool | Application's main window focus state. |
windowHeight
|
int | Application's main window height. |
windowWidth
|
int | Application's main window width. |
windowX
|
int | Application's main window's X-coordinate. |
windowY
|
int | Application's main window's Y-coordinate. |
wmInfo
|
sdl | Window manager info obtained from SDL. |
Methods
| Name | Description |
|---|---|
addEvent
(e)
|
Adds a new event to the inbox queue. |
addInputDevice
(device)
|
Adds an input device to the event emitters list. |
aspectRatio
()
|
Returns the current window aspect ratio. |
controller
(deviceIndex)
|
Get currently opened SDL controller by device index. |
controllerHasRumble
(deviceIndex)
|
Controller vibration support. |
controllerName
(deviceIndex)
|
Get controller name. |
exit
()
|
Signals the Application to stop running. |
gameControllerAvailable
()
|
Returns true if a game controller is available. |
gameControllerAxis
(deviceIndex, axis)
|
Gets the normalized value of a game controller axis. |
gameControllerRumble
(deviceIndex, lowFreq, hiFreg, duration)
|
Triggers controller rumble (vibration) if supported. |
gameInputDeviceClose
(deviceIndex)
|
Closes the game controller or joystick. |
gameInputDeviceOpen
(deviceIndex)
|
Opens a game controller or joystick at the specified device index. |
joystick
(deviceIndex)
|
Get currently opened SDL joystick by device index. |
joystickAvailable
()
|
Returns true if a joystick is available. |
joystickAxis
(deviceIndex, axis)
|
Gets the normalized value of a joystick axis. |
queueEvent
(e)
|
Adds a new event to the outbox queue. |
queueFileChangeEvent
(filename)
|
Generates a file change event for the given filename. |
queueLogEvent
(level, message)
|
Prints to the logger asynchronically using the event queue. This method is also useful to log from nothrow functions, because the logger itself is not nothrow. |
queueUserEvent
(code, payload)
|
Generates a user event with the given code. |
resetUpDown
()
|
Resets all up and down input event states. |
setMouse
(x, y)
|
Sets the mouse cursor position. |
setMouseToCenter
()
|
Centers the mouse cursor in the window. |
setRelativeMouseMode
(mode)
|
Enables or disables relative mouse mode. |
showCursor
(mode)
|
Shows or hides the mouse cursor. |
update
()
|
Polls and processes all pending events. |
updateTimer
()
|
Updates the internal timer and computes delta time. |
Aliases
| Name | Description |
|---|---|
joystickName
|
Get joystick name. |
Description
EventManager polls SDL events and aggregates them in a queue. It also tracks keyboard, mouse, joystick and controller state. Provides methods for generating custom events.