module Sdlevent: sig
.. end
SDL event handling
exception Event_exn of string
The exception used for reporting events-related errors.
Application focus
type
active_state =
| |
MOUSEFOCUS |
| |
INPUTFOCUS |
| |
APPACTIVE |
The available application states
val get_app_state : unit -> active_state list
This function returns the current state of the application. If
ACTIVE is set, then the user is able to see your application,
otherwise it has been iconified or disabled.
Events datatypes
type
active_event = {
}
Application visibility event record
type
switch_state =
type
keyboard_event = {
}
Keyboard event record
type
mousemotion_event = {
|
mme_which : int ; |
|
mme_state : Sdlmouse.button list ; |
|
mme_x : int ; |
|
mme_y : int ; |
|
mme_xrel : int ; |
|
mme_yrel : int ; |
}
Mouse motion event record
type
mousebutton_event = {
}
Mouse button event record
type
joyaxis_event = {
|
jae_which : int ; |
|
jae_axis : int ; |
|
jae_value : int ; |
}
Joystick axis motion event record
type
joyball_event = {
|
jle_which : int ; |
|
jle_ball : int ; |
|
jle_xrel : int ; |
|
jle_yrel : int ; |
}
Joystick axis motion event record
type
joyhat_event = {
|
jhe_which : int ; |
|
jhe_hat : int ; |
|
jhe_value : int ; |
}
Joystick hat position change event record
type
joybutton_event = {
|
jbe_which : int ; |
|
jbe_button : int ; |
|
jbe_state : switch_state ; |
}
Joystick button event record
type
event =
The main event type
val string_of_event : event -> string
Returns a short string descriptive of the event type, for debugging
Event masks
type
event_mask = int
Event masks values are ints and should be manipulated with lor
,
land
, etc.
val active_mask : event_mask
val keydown_mask : event_mask
val keyup_mask : event_mask
val mousemotion_mask : event_mask
val mousebuttondown_mask : event_mask
val mousebuttonup_mask : event_mask
val joyaxismotion_mask : event_mask
val joyballmotion_mask : event_mask
val joyhatmotion_mask : event_mask
val joybuttondown_mask : event_mask
val joybuttonup_mask : event_mask
val quit_mask : event_mask
val syswmevent_mask : event_mask
val videoresize_mask : event_mask
val videoexpose_mask : event_mask
val userevent_mask : event_mask
val keyboard_event_mask : event_mask
val mouse_event_mask : event_mask
val joystick_event_mask : event_mask
val all_events_mask : event_mask
type
event_kind =
| |
ACTIVE_EVENT |
| |
KEYDOWN_EVENT |
| |
KEYUP_EVENT |
| |
MOUSEMOTION_EVENT |
| |
MOUSEBUTTONDOWN_EVENT |
| |
MOUSEBUTTONUP_EVENT |
| |
JOYAXISMOTION_EVENT |
| |
JOYBALL_EVENT |
| |
JOYHAT_EVENT |
| |
JOYBUTTONDOWN_EVENT |
| |
JOYBUTTONUP_EVENT |
| |
QUIT_EVENT |
| |
SYSWM_EVENT |
| |
RESIZE_EVENT |
| |
EXPOSE_EVENT |
| |
USER_EVENT |
val make_mask : event_kind list -> event_mask
val of_mask : event_mask -> event_kind list
Enabling/Disabling event collecting
val enable_events : event_mask -> unit
Specified events are collected and added to the event queue (when
pump
is called).
val disable_events : event_mask -> unit
Specified events are not collected and won't appear in the event queue.
val get_enabled_events : unit -> event_mask
The mask of currently reported events.
val get_state : event_kind -> bool
Query the reporting state of an event type.
val set_state : bool -> event_kind -> unit
Set the reporting state of one individual event type.
Handling events
val pump : unit -> unit
Pumps 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 sets the video
mode.
val wait_event : unit -> event
Wait indefinitely for the next available event and return it.
val wait : unit -> unit
Wait indefinitely for the next available event but leave it in the
queue.
val poll : unit -> event option
Poll for currently pending events and return one if available.
val has_event : unit -> bool
Poll for currently pending events and return false
if the queue is empty.
val peek : ?mask:event_mask -> int -> event list
Checks the event queue for messages : up to 'numevents' events at
the front of the event queue, matching 'mask', will be returned and
will not be removed from the queue.
val get : ?mask:event_mask -> int -> event list
Checks the event queue for messages : up to 'numevents' events at
the front of the event queue, matching 'mask', will be returned and
will be removed from the queue.
val add : event list -> unit
Add events to the back of the event queue.
Old event-handling interface
module Old: sig
.. end
Callback-based event handling.