Safe Haskell | None |
---|---|
Language | Haskell2010 |
SDL.Event
Contents
Description
SDL.Event exports an interface for working with the SDL event model. Event handling allows your application to receive input from the user. Internally, SDL stores all the events waiting to be handled in an event queue. Using functions like pollEvent
and waitEvent
you can observe and handle waiting input events.
The event queue itself is composed of a series of Event
values, one for each waiting event. Event
values are read from the queue with the pollEvent
function and it is then up to the application to process the information stored with them.
- pollEvent :: MonadIO m => m (Maybe Event)
- pollEvents :: (Functor m, MonadIO m) => m [Event]
- mapEvents :: MonadIO m => (Event -> m ()) -> m ()
- pumpEvents :: MonadIO m => m ()
- waitEvent :: MonadIO m => m Event
- waitEventTimeout :: MonadIO m => CInt -> m (Maybe Event)
- data Event = Event {}
- data EventPayload
- = WindowShownEvent WindowShownEventData
- | WindowHiddenEvent WindowHiddenEventData
- | WindowExposedEvent WindowExposedEventData
- | WindowMovedEvent WindowMovedEventData
- | WindowResizedEvent WindowResizedEventData
- | WindowSizeChangedEvent WindowSizeChangedEventData
- | WindowMinimizedEvent WindowMinimizedEventData
- | WindowMaximizedEvent WindowMaximizedEventData
- | WindowRestoredEvent WindowRestoredEventData
- | WindowGainedMouseFocusEvent WindowGainedMouseFocusEventData
- | WindowLostMouseFocusEvent WindowLostMouseFocusEventData
- | WindowGainedKeyboardFocusEvent WindowGainedKeyboardFocusEventData
- | WindowLostKeyboardFocusEvent WindowLostKeyboardFocusEventData
- | WindowClosedEvent WindowClosedEventData
- | KeyboardEvent KeyboardEventData
- | TextEditingEvent TextEditingEventData
- | TextInputEvent TextInputEventData
- | MouseMotionEvent MouseMotionEventData
- | MouseButtonEvent MouseButtonEventData
- | MouseWheelEvent MouseWheelEventData
- | JoyAxisEvent JoyAxisEventData
- | JoyBallEvent JoyBallEventData
- | JoyHatEvent JoyHatEventData
- | JoyButtonEvent JoyButtonEventData
- | JoyDeviceEvent JoyDeviceEventData
- | ControllerAxisEvent ControllerAxisEventData
- | ControllerButtonEvent ControllerButtonEventData
- | ControllerDeviceEvent ControllerDeviceEventData
- | QuitEvent
- | UserEvent UserEventData
- | SysWMEvent SysWMEventData
- | TouchFingerEvent TouchFingerEventData
- | MultiGestureEvent MultiGestureEventData
- | DollarGestureEvent DollarGestureEventData
- | DropEvent DropEventData
- | ClipboardUpdateEvent ClipboardUpdateEventData
- | UnknownEvent UnknownEventData
- data WindowShownEventData = WindowShownEventData {}
- data WindowHiddenEventData = WindowHiddenEventData {}
- data WindowExposedEventData = WindowExposedEventData {}
- data WindowMovedEventData = WindowMovedEventData {}
- data WindowResizedEventData = WindowResizedEventData {}
- data WindowSizeChangedEventData = WindowSizeChangedEventData {}
- data WindowMinimizedEventData = WindowMinimizedEventData {}
- data WindowMaximizedEventData = WindowMaximizedEventData {}
- data WindowRestoredEventData = WindowRestoredEventData {}
- data WindowGainedMouseFocusEventData = WindowGainedMouseFocusEventData {}
- data WindowLostMouseFocusEventData = WindowLostMouseFocusEventData {}
- data WindowGainedKeyboardFocusEventData = WindowGainedKeyboardFocusEventData {}
- data WindowLostKeyboardFocusEventData = WindowLostKeyboardFocusEventData {}
- data WindowClosedEventData = WindowClosedEventData {}
- data SysWMEventData = SysWMEventData {}
- data KeyboardEventData = KeyboardEventData {}
- data TextEditingEventData = TextEditingEventData {}
- data TextInputEventData = TextInputEventData {}
- data MouseMotionEventData = MouseMotionEventData {}
- data MouseButtonEventData = MouseButtonEventData {}
- data MouseWheelEventData = MouseWheelEventData {}
- data JoyAxisEventData = JoyAxisEventData {}
- data JoyBallEventData = JoyBallEventData {}
- data JoyHatEventData = JoyHatEventData {}
- data JoyButtonEventData = JoyButtonEventData {}
- data JoyDeviceEventData = JoyDeviceEventData {}
- data ControllerAxisEventData = ControllerAxisEventData {}
- data ControllerButtonEventData = ControllerButtonEventData {}
- data ControllerDeviceEventData = ControllerDeviceEventData {}
- data UserEventData = UserEventData {
- userEventWindow :: Window
- userEventCode :: Int32
- userEventData1 :: Ptr ()
- userEventData2 :: Ptr ()
- data TouchFingerEventData = TouchFingerEventData {}
- data MultiGestureEventData = MultiGestureEventData {}
- data DollarGestureEventData = DollarGestureEventData {}
- data DropEventData = DropEventData {}
- data ClipboardUpdateEventData = ClipboardUpdateEventData
- data UnknownEventData = UnknownEventData {}
- data InputMotion
- data MouseButton
Polling events
pollEvent :: MonadIO m => m (Maybe Event) Source
Poll for currently pending events. You can only call this function in the thread that set the video mode.
pollEvents :: (Functor m, MonadIO m) => m [Event] Source
Clear the event queue by polling for all pending events.
mapEvents :: MonadIO m => (Event -> m ()) -> m () Source
Run a monadic computation, accumulating over all known Event
s.
This can be useful when used with a state monad, allowing you to fold all events together.
pumpEvents :: MonadIO m => m () Source
Pump the event loop, gathering events from the input devices.
This function updates the event queue and internal input device state.
This should only be run in the thread that initialized the video subsystem, and for extra safety, you should consider only doing those things on the main thread in any case.
pumpEvents
gathers all the pending input information from devices and places it in the event queue. Without calls to pumpEvents
no events would ever be placed on the queue. Often the need for calls to pumpEvents
is hidden from the user since pollEvent
and waitEvent
implicitly call pumpEvents
. However, if you are not polling or waiting for events (e.g. you are filtering them), then you must call pumpEvents
to force an event queue update.
See SDL_PumpEvents
for C documentation.
Wait until the specified timeout for the next available amount.
Event data
A single SDL event. This event occured at eventTimestamp
and carries data under eventPayload
.
Constructors
Event | |
Fields
|
data EventPayload Source
An enumeration of all possible SDL event types. This data type pairs up event types with their payload, where possible.
Constructors
Instances
Window events
data WindowShownEventData Source
A window has been shown.
Constructors
WindowShownEventData | |
Fields
|
data WindowHiddenEventData Source
A window has been hidden.
Constructors
WindowHiddenEventData | |
Fields
|
data WindowExposedEventData Source
A part of a window has been exposed - where exposure means to become visible (for example, an overlapping window no longer overlaps with the window).
Constructors
WindowExposedEventData | |
Fields
|
data WindowMovedEventData Source
A Window
has been moved.
Constructors
WindowMovedEventData | |
Fields
|
data WindowResizedEventData Source
Window has been resized. This is event is always preceded by WindowSizeChangedEvent
.
Constructors
WindowResizedEventData | |
Fields
|
data WindowSizeChangedEventData Source
The window size has changed, either as a result of an API call or through the system or user changing the window size; this event is followed by WindowResizedEvent
if the size was changed by an external event, i.e. the user or the window manager.
Constructors
WindowSizeChangedEventData | |
Fields
|
data WindowMinimizedEventData Source
The window has been minimized.
Constructors
WindowMinimizedEventData | |
Fields
|
data WindowMaximizedEventData Source
The window has been maximized.
Constructors
WindowMaximizedEventData | |
Fields
|
data WindowRestoredEventData Source
The window has been restored to normal size and position.
Constructors
WindowRestoredEventData | |
Fields
|
data WindowGainedMouseFocusEventData Source
The window has gained mouse focus.
Constructors
WindowGainedMouseFocusEventData | |
Fields
|
data WindowLostMouseFocusEventData Source
The window has lost mouse focus.
Constructors
WindowLostMouseFocusEventData | |
Fields
|
data WindowGainedKeyboardFocusEventData Source
The window has gained keyboard focus.
Constructors
WindowGainedKeyboardFocusEventData | |
Fields
|
data WindowLostKeyboardFocusEventData Source
The window has lost keyboard focus.
Constructors
WindowLostKeyboardFocusEventData | |
Fields
|
data WindowClosedEventData Source
The window manager requests that the window be closed.
Constructors
WindowClosedEventData | |
Fields
|
Keyboard events
data KeyboardEventData Source
A keyboard key has been pressed or released.
Constructors
KeyboardEventData | |
Fields
|
data TextEditingEventData Source
Keyboard text editing event information.
Constructors
TextEditingEventData | |
Fields
|
data TextInputEventData Source
Keyboard text input event information.
Constructors
TextInputEventData | |
Fields
|
Mouse events
data MouseMotionEventData Source
A mouse or pointer device was moved.
Constructors
MouseMotionEventData | |
Fields
|
data MouseButtonEventData Source
A mouse or pointer device button was pressed or released.
Constructors
MouseButtonEventData | |
Fields
|
data MouseWheelEventData Source
Mouse wheel event information.
Constructors
MouseWheelEventData | |
Fields
|
Joystick events
data JoyAxisEventData Source
Joystick axis motion event information
Constructors
JoyAxisEventData | |
Fields
|
data JoyBallEventData Source
Joystick trackball motion event information.
Constructors
JoyBallEventData | |
Fields
|
data JoyHatEventData Source
Joystick hat position change event information
Constructors
JoyHatEventData | |
Fields
|
data JoyButtonEventData Source
Joystick button event information.
Constructors
JoyButtonEventData | |
Fields
|
data JoyDeviceEventData Source
Joystick device event information.
Constructors
JoyDeviceEventData | |
Fields
|
Controller events
data ControllerAxisEventData Source
Game controller axis motion event information.
Constructors
ControllerAxisEventData | |
Fields
|
data ControllerButtonEventData Source
Game controller button event information
Constructors
ControllerButtonEventData | |
Fields
|
data ControllerDeviceEventData Source
Controller device event information
Constructors
ControllerDeviceEventData | |
Fields
|
User events
data UserEventData Source
Event data for application-defined events.
Constructors
UserEventData | |
Fields
|
Touch events
data TouchFingerEventData Source
Finger touch event information.
Constructors
TouchFingerEventData | |
Fields
|
Gesture events
data MultiGestureEventData Source
Multiple finger gesture event information
Constructors
MultiGestureEventData | |
Fields
|
data DollarGestureEventData Source
Complex gesture event information.
Constructors
DollarGestureEventData | |
Fields
|
Drag and drop events
data DropEventData Source
An event used to request a file open by the system
Constructors
DropEventData | |
Fields
|
Clipboard events
Unknown events
data UnknownEventData Source
SDL reported an unknown event type.
Constructors
UnknownEventData | |
Fields
|
Auxiliary event data
data InputMotion Source
data MouseButton Source
Constructors
ButtonLeft | |
ButtonMiddle | |
ButtonRight | |
ButtonX1 | |
ButtonX2 | |
ButtonExtra !Int | An unknown mouse button. |