package tsdl

  1. Overview
  2. Docs

Module Sdl.EventSource

event accessors and event_type constants and enumeration.

Event

Once you have determined the typ you can access fields available for that type. Safe if you use the wrong accessors: you will just end with garbage data.

Sourcetype 'b field

The type for event fields.

Sourceval create : unit -> event

create () is an uninitialized event structure.

Sourceval get : event -> 'b field -> 'b

get e f gets the field f of e.

Sourceval set : event -> 'b field -> 'b -> unit

set e f v sets the field f of e to v.

Event types and their fields

Event type aliases and misc

Sourceval first_event : event_type
Sourceval last_event : event_type

Common

These fields are common to all event types.

Sourceval timestamp : uint32 field

Application events

Sourceval app_did_enter_background : event_type
Sourceval app_did_enter_foreground : event_type
Sourceval app_low_memory : event_type
Sourceval app_terminating : event_type
Sourceval app_will_enter_background : event_type
Sourceval app_will_enter_foreground : event_type

Clipboard

Sourceval clipboard_update : event_type

Controller events

Sourceval controller_axis_motion : event_type
Sourceval controller_button_down : event_type
Sourceval controller_button_up : event_type
Sourceval controller_device_added : event_type
Sourceval controller_device_remapped : event_type
Sourceval controller_device_removed : event_type

SDL_ControllerAxisEvent fields

Sourceval controller_axis_which : joystick_id field
Sourceval controller_axis_axis : Controller.axis field
Sourceval controller_axis_value : int16 field

SDL_ControllerButtonEvent fields

Sourceval controller_button_which : joystick_id field
Sourceval controller_button_button : Controller.button field
Sourceval controller_button_state : button_state field

SDL_ControllerDeviceEvent fields

Sourceval controller_device_which : joystick_id field

Dollar gesture events

Sourceval dollar_gesture : event_type
Sourceval dollar_record : event_type

SDL_DollarGestureEvent fields

Sourceval dollar_gesture_touch_id : touch_id field
Sourceval dollar_gesture_gesture_id : gesture_id field
Sourceval dollar_gesture_num_fingers : int field
Sourceval dollar_gesture_error : float field
Sourceval dollar_gesture_x : float field
Sourceval dollar_gesture_y : float field

Drop events

Warning If you enable this event drop_file_free must be called on the event after you have finished processing it.

Sourceval drop_file : event_type
Sourceval drop_text : event_type
Sourceval drop_begin : event_type
Sourceval drop_complete : event_type
Sourceval drop_file_free : event -> unit

SDL_DropEvent fields

Sourceval drop_file_file : event -> string option
Sourceval drop_window_id : int field

Touch events

Sourceval finger_down : event_type
Sourceval finger_motion : event_type
Sourceval finger_up : event_type

SDL_TouchFingerEvent fields

Sourceval touch_finger_touch_id : touch_id field
Sourceval touch_finger_finger_id : finger_id field
Sourceval touch_finger_x : float field
Sourceval touch_finger_y : float field
Sourceval touch_finger_dx : float field
Sourceval touch_finger_dy : float field
Sourceval touch_finger_pressure : float field

Joystick events

Sourceval joy_axis_motion : event_type
Sourceval joy_ball_motion : event_type
Sourceval joy_button_down : event_type
Sourceval joy_button_up : event_type
Sourceval joy_device_added : event_type
Sourceval joy_device_removed : event_type
Sourceval joy_hat_motion : event_type

SDL_JoyAxisEvent fields

Sourceval joy_axis_which : joystick_id field
Sourceval joy_axis_axis : uint8 field
Sourceval joy_axis_value : int16 field

SDL_JoyBallEvent fields

Sourceval joy_ball_which : joystick_id field
Sourceval joy_ball_ball : uint8 field
Sourceval joy_ball_xrel : int field
Sourceval joy_ball_yrel : int field

SDL_JoyButtonEvent fields

Sourceval joy_button_which : joystick_id field
Sourceval joy_button_button : uint8 field
Sourceval joy_button_state : button_state field

SDL_JoyDeviceEvent fields

Sourceval joy_device_which : joystick_id field

SDL_JoyHatEventfields

Sourceval joy_hat_which : joystick_id field
Sourceval joy_hat_hat : uint8 field
Sourceval joy_hat_value : Hat.t field

Keyboard event

Sourceval key_down : event_type
Sourceval key_up : event_type
Sourceval keymap_changed : event_type

SDL_KeyboardEvent fields

Sourceval keyboard_window_id : int field
Sourceval keyboard_state : button_state field
Sourceval keyboard_repeat : int field
Sourceval keyboard_scancode : scancode field
Sourceval keyboard_keycode : keycode field
Sourceval keyboard_keymod : keymod field

Mouse events

Sourceval mouse_button_down : event_type
Sourceval mouse_button_up : event_type
Sourceval mouse_motion : event_type
Sourceval mouse_wheel : event_type

SDL_MouseButtonEvent fields

Sourceval mouse_button_window_id : int field
Sourceval mouse_button_which : uint32 field
Sourceval mouse_button_button : uint8 field
Sourceval mouse_button_state : button_state field
Sourceval mouse_button_clicks : uint8 field

SDL 2.0.2

Sourceval mouse_button_x : int field
Sourceval mouse_button_y : int field

SDL_MouseMotionEvent fields

Sourceval mouse_motion_window_id : int field
Sourceval mouse_motion_which : uint32 field
Sourceval mouse_motion_state : uint32 field
Sourceval mouse_motion_x : int field
Sourceval mouse_motion_y : int field
Sourceval mouse_motion_xrel : int field
Sourceval mouse_motion_yrel : int field

SDL_MouseWheelEvent fields

Sourcetype mouse_wheel_direction

2.04

Sourceval mouse_wheel_normal : mouse_wheel_direction
Sourceval mouse_wheel_flipped : mouse_wheel_direction
Sourceval mouse_wheel_window_id : int field
Sourceval mouse_wheel_which : uint32 field
Sourceval mouse_wheel_x : int field
Sourceval mouse_wheel_y : int field
Sourceval mouse_wheel_direction : mouse_wheel_direction field

2.04

Multi gesture events

Sourceval multi_gesture : event_type

SDL_MultiGestureEvent fields

Sourceval multi_gesture_touch_id : touch_id field
Sourceval multi_gesture_dtheta : float field
Sourceval multi_gesture_ddist : float field
Sourceval multi_gesture_x : float field
Sourceval multi_gesture_y : float field
Sourceval multi_gesture_num_fingers : int field

Quit events

Sourceval quit : event_type

System window manager events

Sourceval sys_wm_event : event_type

Text events

Sourceval text_editing : event_type
Sourceval text_input : event_type

SDL_TextEditingEvent fields

Sourceval text_editing_window_id : int field
Sourceval text_editing_text : string field
Sourceval text_editing_start : int field
Sourceval text_editing_length : int field

SDL_TextInputEvent fields

Sourceval text_input_window_id : int field
Sourceval text_input_text : string field

User events

Sourceval user_event : event_type

SDL_UserEvent fields

Sourceval user_window_id : int field
Sourceval user_code : int field

Locale

Sourceval locale_changed : event_type

Display events

Sourceval display_event : event_type

SDL_DisplayEvent fields

Sourceval display_display : int32 field
Sourceval display_event_id : int field
Sourceval display_data1 : int32 field

Sensor events

Sourceval sensor_update : event_type

SDL_SensorEvent fields

Sourceval sensor_which : int32 field
Sourceval sensor_data0 : float field
Sourceval sensor_data1 : float field
Sourceval sensor_data2 : float field
Sourceval sensor_data3 : float field
Sourceval sensor_data4 : float field
Sourceval sensor_data5 : float field

Window events

Sourceval window_event : event_type
Sourcetype window_event_id = int
Sourcetype window_event_enum = [
  1. | `Close
  2. | `Enter
  3. | `Exposed
  4. | `Focus_gained
  5. | `Focus_lost
  6. | `Hidden
  7. | `Hit_test
  8. | `Leave
  9. | `Maximized
  10. | `Minimized
  11. | `Moved
  12. | `Resized
  13. | `Restored
  14. | `Shown
  15. | `Size_changed
  16. | `Take_focus
  17. | `Unknown of window_event_id
]
Sourceval window_event_enum : window_event_id -> window_event_enum
Sourceval window_event_shown : window_event_id
Sourceval window_event_hidden : window_event_id
Sourceval window_event_exposed : window_event_id
Sourceval window_event_moved : window_event_id
Sourceval window_event_resized : window_event_id
Sourceval window_event_size_changed : window_event_id
Sourceval window_event_minimized : window_event_id
Sourceval window_event_maximized : window_event_id
Sourceval window_event_restored : window_event_id
Sourceval window_event_enter : window_event_id
Sourceval window_event_leave : window_event_id
Sourceval window_event_focus_gained : window_event_id
Sourceval window_event_focus_lost : window_event_id
Sourceval window_event_close : window_event_id
Sourceval window_event_take_focus : window_event_id
Sourceval window_event_hit_test : window_event_id

SDL_WindowEvent fields

Sourceval window_window_id : int field
Sourceval window_event_id : window_event_id field
Sourceval window_data1 : int32 field
Sourceval window_data2 : int32 field

Render target

Sourceval render_targets_reset : event_type
Sourceval render_device_reset : event_type

Audio hotplug events

Sourceval audio_device_added : event_type
Sourceval audio_device_removed : event_type

SDL_AudioDeviceEvent fields

Sourceval audio_device_timestamp : uint32 field
Sourceval audio_device_which : uint32 field
Sourceval audio_device_is_capture : int field

Event type enum

Sourcetype enum = [
  1. | `App_did_enter_background
  2. | `App_did_enter_foreground
  3. | `App_low_memory
  4. | `App_terminating
  5. | `App_will_enter_background
  6. | `App_will_enter_foreground
  7. | `Audio_device_added
  8. | `Audio_device_removed
  9. | `Clipboard_update
  10. | `Controller_axis_motion
  11. | `Controller_button_down
  12. | `Controller_button_up
  13. | `Controller_device_added
  14. | `Controller_device_remapped
  15. | `Controller_device_removed
  16. | `Dollar_gesture
  17. | `Dollar_record
  18. | `Drop_begin
  19. | `Drop_complete
  20. | `Drop_file
  21. | `Drop_text
  22. | `Finger_down
  23. | `Finger_motion
  24. | `Finger_up
  25. | `Keymap_changed
  26. | `Joy_axis_motion
  27. | `Joy_ball_motion
  28. | `Joy_button_down
  29. | `Joy_button_up
  30. | `Joy_device_added
  31. | `Joy_device_removed
  32. | `Joy_hat_motion
  33. | `Key_down
  34. | `Key_up
  35. | `Mouse_button_down
  36. | `Mouse_button_up
  37. | `Mouse_motion
  38. | `Mouse_wheel
  39. | `Multi_gesture
  40. | `Quit
  41. | `Render_targets_reset
  42. | `Render_device_reset
  43. | `Sys_wm_event
  44. | `Text_editing
  45. | `Text_input
  46. | `Unknown of int
  47. | `User_event
  48. | `Window_event
  49. | `Locale_changed
  50. | `Display_event
  51. | `Sensor_update
]
Sourceval enum : event_type -> enum