package tsdl

  1. Overview
  2. Docs

Module Tsdl.SdlSource

SDL bindings.

Integer types, bigarrays and results

Sourcetype uint8 = int

The type for unsigned 8-bit integers.

Sourcetype int16 = int

The type for signed 16-bit integers.

Sourcetype uint16 = int

The type for unsigned 16-bit integers.

Sourcetype uint32 = int32

The type for unsigned 32-bit integers.

Sourcetype uint64 = int64

The type for unsigned 64-bit integers.

Sourcetype ('a, 'b) bigarray = ('a, 'b, Bigarray.c_layout) Bigarray.Array1.t

The type for bigarrays.

Sourcetype nonrec 'a result = ('a, [ `Msg of string ]) result

The type for function results. In the error case, the string is what Sdl.get_error returned.

Basics

Initialization and shutdown

Sourcemodule Init : sig ... end

Subsystem flags.

Sourceval init : Init.t -> unit result
Sourceval init_sub_system : Init.t -> unit result
Sourceval quit : unit -> unit
Sourceval quit_sub_system : Init.t -> unit
Sourceval was_init : Init.t option -> Init.t

Hints

Sourcemodule Hint : sig ... end
Sourceval clear_hints : unit -> unit
Sourceval get_hint : Hint.t -> string option
Sourceval get_hint_boolean : Hint.t -> bool -> bool
Sourceval set_hint : Hint.t -> string -> bool
Sourceval set_hint_with_priority : Hint.t -> string -> Hint.priority -> bool

Errors

Sourceval clear_error : unit -> unit
Sourceval get_error : unit -> string
Sourceval set_error : ('b, Format.formatter, unit) format -> 'b

Log

Sourcemodule Log : sig ... end
Sourceval log : ('b, Format.formatter, unit) format -> 'b
Sourceval log_critical : Log.category -> ('b, Format.formatter, unit) format -> 'b
Sourceval log_debug : Log.category -> ('b, Format.formatter, unit) format -> 'b
Sourceval log_error : Log.category -> ('b, Format.formatter, unit) format -> 'b
Sourceval log_info : Log.category -> ('b, Format.formatter, unit) format -> 'b
Sourceval log_message : Log.category -> Log.priority -> ('b, Format.formatter, unit) format -> 'b
Sourceval log_reset_priorities : unit -> unit
Sourceval log_set_all_priority : Log.priority -> unit
Sourceval log_set_priority : Log.category -> Log.priority -> unit
Sourceval log_verbose : Log.category -> ('b, Format.formatter, unit) format -> 'b
Sourceval log_warn : Log.category -> ('b, Format.formatter, unit) format -> 'b

Version

Sourceval get_version : unit -> int * int * int
Sourceval get_revision : unit -> string
Sourceval get_revision_number : unit -> int

Files and IO abstraction

IO abstraction

Sourcetype rw_ops
Sourceval load_file : string -> string result
Sourceval load_file_rw : rw_ops -> bool -> string result
Sourceval rw_from_file : string -> string -> rw_ops result
Sourceval rw_from_const_mem : string -> rw_ops result
Sourceval rw_from_mem : bytes -> rw_ops result
Sourceval rw_close : rw_ops -> unit result

Filesystem Paths

Sourceval get_base_path : unit -> string result
Sourceval get_pref_path : org:string -> app:string -> string result

Video

Sourcetype window

Colors

Sourcetype color
Sourcemodule Color : sig ... end

Points and vertices

Sourcetype point
Sourcemodule Point : sig ... end
Sourcetype fpoint

structure SDL_FPoint

Sourcemodule Fpoint : sig ... end
Sourcetype vertex
Sourcemodule Vertex : sig ... end

Rectangles

Sourcemodule Rect : sig ... end
Sourcetype frect

structure SDL_FRect

Sourcemodule Frect : sig ... end
Sourceval enclose_points : ?clip:rect -> point list -> rect option

SDL_EnclosePoints. Returns None if all the points were outside the clipping rectangle (if provided).

Sourceval enclose_points_ba : ?clip:rect -> (int32, Bigarray.int32_elt) bigarray -> rect option

See enclose_points. Each consecutive pair in the array defines a point.

Sourceval has_intersection : rect -> rect -> bool
Sourceval intersect_rect : rect -> rect -> rect option
Sourceval intersect_rect_and_line : rect -> int -> int -> int -> int -> ((int * int) * (int * int)) option

SDL_IntersectRectAndLine. Returns the clipped segment if it intersects.

Sourceval point_in_rect : point -> rect -> bool
Sourceval rect_empty : rect -> bool
Sourceval rect_equals : rect -> rect -> bool
Sourceval union_rect : rect -> rect -> rect

Palettes

Sourcetype palette
Sourceval alloc_palette : int -> palette result
Sourceval free_palette : palette -> unit
Sourceval get_palette_ncolors : palette -> int

get_palette_ncolors p is the field ncolors of p.

Sourceval get_palette_colors : palette -> color list

get_palette_colors p is a copy of the contents of the field colors of s.

Sourceval get_palette_colors_ba : palette -> (int, Bigarray.int8_unsigned_elt) bigarray

get_palette_colors_ba p is a copy of the contents of the field colors of p.

Sourceval set_palette_colors : palette -> color list -> fst:int -> unit result
Sourceval set_palette_colors_ba : palette -> (int, Bigarray.int8_unsigned_elt) bigarray -> fst:int -> unit result

See set_palette_colors. Each consecutive quadruplet defines a color. The data is copied.

Pixels formats

The type for gamma ramps, 256 uint16 values.

Sourceval calculate_gamma_ramp : float -> gamma_ramp
Sourcemodule Blend : sig ... end
Sourcemodule Pixel : sig ... end
Sourcetype pixel_format
Sourceval free_format : pixel_format -> unit
Sourceval get_pixel_format_name : Pixel.format_enum -> string
Sourceval get_pixel_format_format : pixel_format -> Pixel.format_enum

get_pixel_format_format pf is the field format of pf.

Sourceval get_pixel_format_bits_pp : pixel_format -> int

get_pixel_format_bits_pp pf is the field BitsPerPixel of pf.

Sourceval get_pixel_format_bytes_pp : pixel_format -> int

get_pixel_format_bytes_pp pf is the field BytesPerPixel of pf.

Sourceval masks_to_pixel_format_enum : int -> uint32 -> uint32 -> uint32 -> uint32 -> Pixel.format_enum
Sourceval pixel_format_enum_to_masks : Pixel.format_enum -> (int * uint32 * uint32 * uint32 * uint32) result
Sourceval set_pixel_format_palette : pixel_format -> palette -> unit result

SDL_SetPixelFormatPalette.

Note If you allocated the palette with alloc_palette you can free_palette after.

Surface

Sourcetype surface
Sourceval blit_scaled : src:surface -> rect option -> dst:surface -> rect option -> unit result
Sourceval blit_surface : src:surface -> rect option -> dst:surface -> rect option -> unit result
Sourceval convert_pixels : w:int -> h:int -> src:Pixel.format_enum -> ('a, 'b) bigarray -> int -> dst:Pixel.format_enum -> ('c, 'd) bigarray -> int -> unit result

SDL_ConvertPixels

Note Pitches are given in bigarray elements not in bytes.

Warning. Unsafe, make sure your parameters don't result in invalid access to memory.

Sourceval create_rgb_surface : w:int -> h:int -> depth:int -> uint32 -> uint32 -> uint32 -> uint32 -> surface result
Sourceval create_rgb_surface_from : ('a, 'b) bigarray -> w:int -> h:int -> depth:int -> pitch:int -> uint32 -> uint32 -> uint32 -> uint32 -> surface result

SDL_CreateRGBSurfaceFrom

Note The pitch is given in bigarray elements not in bytes.

Warning Unsafe, make sure your parameters don't result in invalid access to memory. The bigarray data is not copied, it must remain valid until free_surface is called on the surface.

Sourceval create_rgb_surface_with_format : w:int -> h:int -> depth:int -> Pixel.format_enum -> surface result
Sourceval create_rgb_surface_with_format_from : ('a, 'b) bigarray -> w:int -> h:int -> depth:int -> pitch:int -> Pixel.format_enum -> surface result
Sourceval duplicate_surface : surface -> surface
Sourceval fill_rect : surface -> rect option -> uint32 -> unit result
Sourceval fill_rects : surface -> rect list -> uint32 -> unit result
Sourceval fill_rects_ba : surface -> (int32, Bigarray.int32_elt) bigarray -> uint32 -> unit result

See fill_rects. Each consecutive quadruplet defines a rectangle.

Sourceval free_surface : surface -> unit
Sourceval get_clip_rect : surface -> rect
Sourceval get_surface_alpha_mod : surface -> uint8 result
Sourceval get_surface_color_mod : surface -> (int * int * int) result
Sourceval get_surface_format_enum : surface -> Pixel.format_enum

get_surface_format_neum s is the pixel format enum of the field format of s.

Sourceval get_surface_pitch : surface -> int

get_surface_pitch s is the field pitch of s.

Sourceval get_surface_pixels : surface -> ('a, 'b) Bigarray.kind -> ('a, 'b) bigarray

get_surface_pixels s kind is the field pixels of s viewed as a kind bigarray. Note that you must lock the surface before accessing this.

Warning. The bigarray memory becomes invalid once the surface is unlocked or freed.

Sourceval get_surface_size : surface -> int * int

get_surface_size s is the fields w and h of s.

Sourceval load_bmp : string -> surface result
Sourceval load_bmp_rw : rw_ops -> close:bool -> surface result
Sourceval lock_surface : surface -> unit result
Sourceval lower_blit : src:surface -> rect -> dst:surface -> rect -> unit result
Sourceval lower_blit_scaled : src:surface -> rect -> dst:surface -> rect -> unit result
Sourceval save_bmp : surface -> string -> unit result
Sourceval save_bmp_rw : surface -> rw_ops -> close:bool -> unit result
Sourceval set_clip_rect : surface -> rect -> bool
Sourceval set_color_key : surface -> bool -> uint32 -> unit result
Sourceval set_surface_alpha_mod : surface -> uint8 -> unit result
Sourceval set_surface_blend_mode : surface -> Blend.mode -> unit result
Sourceval set_surface_color_mod : surface -> uint8 -> uint8 -> uint8 -> unit result
Sourceval set_surface_palette : surface -> palette -> unit result

SDL_SetSurfacePalette

Note If you allocated the palette with alloc_palette you can free_palette after.

Sourceval set_surface_rle : surface -> bool -> unit result
Sourceval unlock_surface : surface -> unit

Renderers

Sourcemodule Flip : sig ... end
Sourcetype texture
Sourcetype renderer
Sourcemodule Renderer : sig ... end
Sourcetype renderer_info = {
  1. ri_name : string;
  2. ri_flags : Renderer.flags;
  3. ri_texture_formats : Pixel.format_enum list;
  4. ri_max_texture_width : int;
  5. ri_max_texture_height : int;
}
Sourceval create_renderer : ?index:int -> ?flags:Renderer.flags -> window -> renderer result
Sourceval create_software_renderer : surface -> renderer result
Sourceval destroy_renderer : renderer -> unit
Sourceval get_num_render_drivers : unit -> int result
Sourceval get_render_draw_blend_mode : renderer -> Blend.mode result
Sourceval get_render_draw_color : renderer -> (uint8 * uint8 * uint8 * uint8) result
Sourceval get_render_driver_info : int -> renderer_info result
Sourceval get_render_target : renderer -> texture option
Sourceval get_renderer_output_size : renderer -> (int * int) result
Sourceval render_clear : renderer -> unit result
Sourceval render_copy : ?src:rect -> ?dst:rect -> renderer -> texture -> unit result
Sourceval render_copy_ex : ?src:rect -> ?dst:rect -> renderer -> texture -> float -> point option -> flip -> unit result
Sourceval render_draw_line : renderer -> int -> int -> int -> int -> unit result
Sourceval render_draw_line_f : renderer -> float -> float -> float -> float -> unit result
Sourceval render_draw_lines : renderer -> point list -> unit result
Sourceval render_draw_lines_ba : renderer -> (int32, Bigarray.int32_elt) bigarray -> unit result

See render_draw_lines. Each consecutive pair in the array defines a point.

Sourceval render_draw_point : renderer -> int -> int -> unit result
Sourceval render_draw_points : renderer -> point list -> unit result
Sourceval render_draw_points_ba : renderer -> (int32, Bigarray.int32_elt) bigarray -> unit result

See render_draw_points. Each consecutive pair in the array defines a point.

Sourceval render_draw_point_f : renderer -> float -> float -> unit result

SDL_RenderDrawPointF

Sourceval render_draw_points_f : renderer -> fpoint list -> unit result
Sourceval render_draw_points_f_ba : renderer -> (float, Bigarray.float32_elt) bigarray -> unit result

See render_draw_points. Each consecutive pair in the array defines a point.

Sourceval render_draw_rect : renderer -> rect option -> unit result
Sourceval render_draw_rects : renderer -> rect list -> unit result
Sourceval render_draw_rects_ba : renderer -> (int32, Bigarray.int32_elt) bigarray -> unit result

See render_draw_rects. Each consecutive quadruple in the array defines a rectangle.

Sourceval render_fill_rect : renderer -> rect option -> unit result
Sourceval render_fill_rects : renderer -> rect list -> unit result
Sourceval render_fill_rects_ba : renderer -> (int32, Bigarray.int32_elt) bigarray -> unit result

See render_draw_rects. Each consecutive quadruple in the array defines a rectangle.

Sourceval render_geometry : ?indices:int list -> ?texture:texture -> renderer -> vertex list -> unit result
Sourceval render_geometry_raw : ?indices:(int32, Bigarray.int32_elt) bigarray -> ?texture:texture -> renderer -> xy:(float, Bigarray.float32_elt) bigarray -> ?xy_stride:int -> color:(int, Bigarray.int8_unsigned_elt) bigarray -> ?color_stride:int -> uv:(float, Bigarray.float32_elt) bigarray -> ?uv_stride:int -> num_vertices:int -> unit -> unit result

SDL_RenderGeometryRaw

Note. The stride arguments are in bytes, like in the C call. The defaults assume packed arrays.

Sourceval render_get_clip_rect : renderer -> rect
Sourceval render_get_integer_scale : renderer -> bool
Sourceval render_get_logical_size : renderer -> int * int
Sourceval render_get_scale : renderer -> float * float
Sourceval render_get_viewport : renderer -> rect
Sourceval render_is_clip_enabled : renderer -> bool
Sourceval render_present : renderer -> unit
Sourceval render_read_pixels : renderer -> rect option -> Pixel.format_enum option -> ('a, 'b) bigarray -> int -> unit result
Sourceval render_set_clip_rect : renderer -> rect option -> unit result
Sourceval render_set_integer_scale : renderer -> bool -> unit result
Sourceval render_set_logical_size : renderer -> int -> int -> unit result
Sourceval render_set_scale : renderer -> float -> float -> unit result
Sourceval render_set_viewport : renderer -> rect option -> unit result
Sourceval render_target_supported : renderer -> bool
Sourceval set_render_draw_blend_mode : renderer -> Blend.mode -> unit result
Sourceval set_render_draw_color : renderer -> uint8 -> uint8 -> uint8 -> uint8 -> unit result
Sourceval set_render_target : renderer -> texture option -> unit result

Textures

Sourcemodule Texture : sig ... end
Sourceval create_texture : renderer -> Pixel.format_enum -> Texture.access -> w:int -> h:int -> texture result
Sourceval create_texture_from_surface : renderer -> surface -> texture result
Sourceval destroy_texture : texture -> unit
Sourceval get_texture_alpha_mod : texture -> uint8 result
Sourceval get_texture_color_mod : texture -> (uint8 * uint8 * uint8) result
Sourceval lock_texture : texture -> rect option -> ('a, 'b) Bigarray.kind -> (('a, 'b) bigarray * int) result

SDL_LockTexture

Note. The returned pitch is in bigarray element, not in bytes.

Sourceval query_texture : texture -> (Pixel.format_enum * Texture.access * (int * int)) result
Sourceval set_texture_alpha_mod : texture -> uint8 -> unit result
Sourceval set_texture_blend_mode : texture -> Blend.mode -> unit result
Sourceval set_texture_color_mod : texture -> uint8 -> uint8 -> uint8 -> unit result
Sourceval unlock_texture : texture -> unit
Sourceval update_texture : texture -> rect option -> ('a, 'b) bigarray -> int -> unit result

SDL_UpdateTexture

Note The pitch is given in bigarray elements not in bytes.

Sourceval update_yuv_texture : texture -> rect option -> y:(int, Bigarray.int8_unsigned_elt) bigarray -> int -> u:(int, Bigarray.int8_unsigned_elt) bigarray -> int -> v:(int, Bigarray.int8_unsigned_elt) bigarray -> int -> unit result

Video drivers

Sourceval get_current_video_driver : unit -> string option
Sourceval get_num_video_drivers : unit -> int result
Sourceval get_video_driver : int -> string result
Sourceval video_init : string option -> unit result
Sourceval video_quit : unit -> unit

Displays

Sourcetype driverdata

Note. Nothing can be done with that.

Sourcetype display_mode = {
  1. dm_format : Pixel.format_enum;
  2. dm_w : int;
  3. dm_h : int;
  4. dm_refresh_rate : int option;
  5. dm_driverdata : driverdata option;
}
Sourceval get_closest_display_mode : int -> display_mode -> display_mode option
Sourceval get_current_display_mode : int -> display_mode result
Sourceval get_desktop_display_mode : int -> display_mode result
Sourceval get_display_bounds : int -> rect result
Sourceval get_display_dpi : int -> (float * float * float) result
Sourceval get_display_mode : int -> int -> display_mode result
Sourceval get_display_name : int -> string result
Sourceval get_display_usable_bounds : int -> rect result
Sourceval get_num_display_modes : int -> int result
Sourceval get_num_video_displays : unit -> int result

Windows

Sourcemodule Window : sig ... end
Sourceval create_window : string -> ?x:int -> ?y:int -> w:int -> h:int -> Window.flags -> window result
Sourceval create_window_and_renderer : w:int -> h:int -> Window.flags -> (window * renderer) result
Sourceval destroy_window : window -> unit
Sourceval get_window_borders_size : window -> (int * int * int * int) result
Sourceval get_window_brightness : window -> float
Sourceval get_window_display_index : window -> int result
Sourceval get_window_from_id : int -> window result
Sourceval get_window_grab : window -> bool
Sourceval get_grabbed_window : unit -> window
Sourceval get_window_id : window -> int
Sourceval get_window_maximum_size : window -> int * int
Sourceval get_window_minimum_size : window -> int * int
Sourceval get_window_opacity : window -> float result
Sourceval get_window_position : window -> int * int
Sourceval get_window_size : window -> int * int
Sourceval get_window_surface : window -> surface result

SDL_GetWindowSurface.

Note. According to SDL's documentation the surface is freed when the window is destroyed.

Sourceval get_window_title : window -> string
Sourceval hide_window : window -> unit
Sourceval maximize_window : window -> unit
Sourceval minimize_window : window -> unit
Sourceval raise_window : window -> unit
Sourceval restore_window : window -> unit
Sourceval set_window_bordered : window -> bool -> unit
Sourceval set_window_brightness : window -> float -> unit result
Sourceval set_window_display_mode : window -> display_mode -> unit result
Sourceval set_window_fullscreen : window -> Window.flags -> unit result
Sourceval set_window_gamma_ramp : window -> gamma_ramp -> gamma_ramp -> gamma_ramp -> unit result
Sourceval set_window_grab : window -> bool -> unit
Sourceval set_window_icon : window -> surface -> unit
Sourceval set_window_input_focus : window -> unit result
Sourceval set_window_maximum_size : window -> w:int -> h:int -> unit
Sourceval set_window_minimum_size : window -> w:int -> h:int -> unit
Sourceval set_window_modal_for : modal:window -> parent:window -> unit result
Sourceval set_window_opacity : window -> float -> unit result
Sourceval set_window_position : window -> x:int -> y:int -> unit
Sourceval set_window_resizable : window -> bool -> unit
Sourceval set_window_size : window -> w:int -> h:int -> unit
Sourceval set_window_title : window -> string -> unit
Sourceval show_window : window -> unit
Sourceval update_window_surface : window -> unit result
Sourceval update_window_surface_rects : window -> rect list -> unit result
Sourceval update_window_surface_rects_ba : window -> (int32, Bigarray.int32_elt) bigarray -> unit result

See update_window_surface_rects. Each consecutive quadruplet defines a rectangle.

OpenGL contexts

Sourcetype gl_context

SDL_GLContext

Sourcemodule Gl : sig ... end
Sourceval gl_bind_texture : texture -> (float * float) result
Sourceval gl_delete_context : gl_context -> unit
Sourceval gl_extension_supported : string -> bool
Sourceval gl_get_attribute : Gl.attr -> int result
Sourceval gl_get_current_context : unit -> gl_context result
Sourceval gl_get_drawable_size : window -> int * int
Sourceval gl_get_swap_interval : unit -> int result
Sourceval gl_make_current : window -> gl_context -> unit result
Sourceval gl_set_attribute : Gl.attr -> int -> unit result
Sourceval gl_set_swap_interval : int -> unit result
Sourceval gl_swap_window : window -> unit
Sourceval gl_reset_attributes : unit -> unit
Sourceval gl_unbind_texture : texture -> unit result

SDL_GL_UnbindTexture Warning Segfaults on SDL 2.0.1 see this report.

Vulkan

Sourcemodule Vulkan : sig ... end

Screen saver

Sourceval disable_screen_saver : unit -> unit
Sourceval enable_screen_saver : unit -> unit
Sourceval is_screen_saver_enabled : unit -> bool

Message boxes

Sourcemodule Message_box : sig ... end
Sourceval show_message_box : Message_box.data -> int result
Sourceval show_simple_message_box : Message_box.flags -> title:string -> string -> window option -> unit result

Clipboard

Sourceval get_clipboard_text : unit -> string result
Sourceval has_clipboard_text : unit -> bool
Sourceval set_clipboard_text : string -> unit result

Input

Sourcetype button_state
Sourceval pressed : button_state
Sourceval released : button_state
Sourcetype toggle_state
Sourceval disable : toggle_state
Sourceval enable : toggle_state

Keyboard

Sourcetype scancode = int
Sourcemodule Scancode : sig ... end

Constants and enumeration for scancode

Sourcetype keycode = int
Sourcemodule K : sig ... end

Constants for keycode

Sourcetype keymod = int
Sourcemodule Kmod : sig ... end

Constants for keymod

Sourceval get_keyboard_focus : unit -> window option
Sourceval get_keyboard_state : unit -> (int, Bigarray.int8_unsigned_elt) bigarray
Sourceval get_key_from_name : string -> keycode
Sourceval get_key_from_scancode : scancode -> keycode
Sourceval get_key_name : keycode -> string
Sourceval get_mod_state : unit -> keymod
Sourceval get_scancode_from_key : keycode -> scancode
Sourceval get_scancode_from_name : string -> scancode
Sourceval get_scancode_name : scancode -> string
Sourceval has_screen_keyboard_support : unit -> bool
Sourceval is_screen_keyboard_shown : window -> bool
Sourceval is_text_input_active : unit -> bool
Sourceval set_mod_state : keymod -> unit
Sourceval set_text_input_rect : rect option -> unit
Sourceval start_text_input : unit -> unit
Sourceval stop_text_input : unit -> unit

Mouse

Sourcetype cursor
Sourcemodule System_cursor : sig ... end
Sourcemodule Button : sig ... end
Sourceval capture_mouse : bool -> unit result
Sourceval create_color_cursor : surface -> hot_x:int -> hot_y:int -> cursor result
Sourceval create_cursor : (int, Bigarray.int8_unsigned_elt) bigarray -> (int, Bigarray.int8_unsigned_elt) bigarray -> w:int -> h:int -> hot_x:int -> hot_y:int -> cursor result
Sourceval free_cursor : cursor -> unit
Sourceval get_cursor : unit -> cursor option
Sourceval get_default_cursor : unit -> cursor option
Sourceval get_global_mouse_state : unit -> uint32 * (int * int)
Sourceval get_mouse_focus : unit -> window option
Sourceval get_mouse_state : unit -> uint32 * (int * int)
Sourceval get_relative_mouse_mode : unit -> bool
Sourceval get_relative_mouse_state : unit -> uint32 * (int * int)
Sourceval get_cursor_shown : unit -> bool result

SDL_ShowCursor with SDL_QUERY.

Sourceval set_cursor : cursor option -> unit
Sourceval set_relative_mouse_mode : bool -> unit result
Sourceval show_cursor : bool -> bool result
Sourceval warp_mouse_global : x:int -> y:int -> unit result
Sourceval warp_mouse_in_window : window option -> x:int -> y:int -> unit

Touch and gestures

Sourcetype touch_id = int64
Sourceval touch_mouse_id : touch_id
Sourcetype gesture_id = int64
Sourcetype finger_id = int64
Sourcetype finger
Sourcemodule Finger : sig ... end
Sourceval get_num_touch_devices : unit -> int
Sourceval get_num_touch_fingers : touch_id -> int
Sourceval get_touch_device : int -> touch_id result
Sourceval get_touch_finger : touch_id -> int -> finger option
Sourceval load_dollar_templates : touch_id -> rw_ops -> unit result
Sourceval record_gesture : touch_id -> unit result
Sourceval save_dollar_template : gesture_id -> rw_ops -> unit result
Sourceval save_all_dollar_templates : rw_ops -> unit result

Joystick

Sourcetype joystick_guid
Sourcetype joystick_id = int32
Sourcetype joystick
Sourcemodule Hat : sig ... end
Sourcemodule Joystick_power_level : sig ... end
Sourcemodule Joystick_type : sig ... end
Sourceval joystick_close : joystick -> unit
Sourceval joystick_from_instance_id : joystick_id -> joystick
Sourceval joystick_get_device_instance_id : int -> joystick_id
Sourceval joystick_get_device_product : int -> int16
Sourceval joystick_get_device_product_version : int -> int16
Sourceval joystick_get_device_type : int -> Joystick_type.t
Sourceval joystick_get_device_vendor : int -> int16
Sourceval joystick_get_event_state : unit -> toggle_state result

SDL_JoystickEventState with SDL_QUERY.

Sourceval joystick_get_attached : joystick -> bool
Sourceval joystick_get_axis : joystick -> int -> int16
Sourceval joystick_get_ball : joystick -> int -> (int * int) result
Sourceval joystick_get_button : joystick -> int -> uint8
Sourceval joystick_get_device_guid : int -> joystick_guid
Sourceval joystick_get_guid_from_string : string -> joystick_guid
Sourceval joystick_get_guid_string : joystick_guid -> string
Sourceval joystick_get_hat : joystick -> int -> Hat.t
Sourceval joystick_get_product : joystick -> int16
Sourceval joystick_get_product_version : joystick -> int16
Sourceval joystick_get_vendor : joystick -> int16
Sourceval joystick_name : joystick -> string result
Sourceval joystick_name_for_index : int -> string result
Sourceval joystick_num_axes : joystick -> int result
Sourceval joystick_num_balls : joystick -> int result
Sourceval joystick_num_buttons : joystick -> int result
Sourceval joystick_num_hats : joystick -> int result
Sourceval joystick_open : int -> joystick result
Sourceval joystick_update : unit -> unit
Sourceval num_joysticks : unit -> int result

Game controller

Sourcetype game_controller
Sourcemodule Controller : sig ... end
Sourceval game_controller_add_mapping : string -> bool result
Sourceval game_controller_add_mapping_from_rw : rw_ops -> bool -> int result
Sourceval game_controller_close : game_controller -> unit
Sourceval game_controller_from_instance_id : joystick_id -> game_controller
Sourceval game_controller_get_event_state : unit -> toggle_state result
Sourceval game_controller_get_attached : game_controller -> bool
Sourceval game_controller_get_axis_from_string : string -> Controller.axis
Sourceval game_controller_get_button_from_string : string -> Controller.button
Sourceval game_controller_get_product : game_controller -> uint16
Sourceval game_controller_get_product_version : game_controller -> uint16
Sourceval game_controller_get_string_for_axis : Controller.axis -> string option
Sourceval game_controller_get_string_for_button : Controller.button -> string option
Sourceval game_controller_get_vendor : game_controller -> uint16
Sourceval game_controller_mapping : game_controller -> string result
Sourceval game_controller_mapping_for_index : int -> string result
Sourceval game_controller_mapping_for_guid : joystick_guid -> string result
Sourceval game_controller_name : game_controller -> string result
Sourceval game_controller_name_for_index : int -> string result
Sourceval game_controller_num_mappings : unit -> int
Sourceval game_controller_open : int -> game_controller result
Sourceval game_controller_update : unit -> unit
Sourceval is_game_controller : int -> bool

Events

Sourcetype event_type = int

SDL_EventType. See Event for constants.

Sourcetype event
Sourcemodule Event : sig ... end

event accessors and event_type constants and enumeration.

Sourceval get_event_state : event_type -> toggle_state

SDL_EventState with SDL_QUERY.

Sourceval set_event_state : event_type -> toggle_state -> unit
Sourceval flush_event : event_type -> unit
Sourceval flush_events : event_type -> event_type -> unit
Sourceval has_event : event_type -> bool
Sourceval has_events : event_type -> event_type -> bool
Sourceval poll_event : event option -> bool
Sourceval pump_events : unit -> unit
Sourceval push_event : event -> bool result
Sourceval register_event : unit -> event_type option

SDL_RegisterEvents called with 1.

Sourceval wait_event : event option -> unit result
Sourceval wait_event_timeout : event option -> int -> bool

Force Feedback

Sourcetype haptic
Sourcetype haptic_effect
Sourcetype haptic_effect_id
Sourcemodule Haptic : sig ... end
Sourceval haptic_close : haptic -> unit
Sourceval haptic_destroy_effect : haptic -> haptic_effect_id -> unit
Sourceval haptic_effect_supported : haptic -> haptic_effect -> bool result
Sourceval haptic_get_effect_status : haptic -> haptic_effect_id -> bool result
Sourceval haptic_index : haptic -> int result
Sourceval haptic_name : int -> string result
Sourceval haptic_num_axes : haptic -> int result
Sourceval haptic_num_effects : haptic -> int result
Sourceval haptic_num_effects_playing : haptic -> int result
Sourceval haptic_open : int -> haptic result
Sourceval haptic_open_from_joystick : joystick -> haptic result
Sourceval haptic_open_from_mouse : unit -> haptic result
Sourceval haptic_opened : int -> bool
Sourceval haptic_pause : haptic -> unit result
Sourceval haptic_query : haptic -> int
Sourceval haptic_rumble_init : haptic -> unit result
Sourceval haptic_rumble_play : haptic -> float -> uint32 -> unit result
Sourceval haptic_rumble_stop : haptic -> unit result
Sourceval haptic_rumble_supported : haptic -> bool result
Sourceval haptic_run_effect : haptic -> haptic_effect_id -> uint32 -> unit result
Sourceval haptic_set_autocenter : haptic -> int -> unit result
Sourceval haptic_set_gain : haptic -> int -> unit result
Sourceval haptic_stop_all : haptic -> unit result
Sourceval haptic_stop_effect : haptic -> haptic_effect_id -> unit result
Sourceval haptic_unpause : haptic -> unit result
Sourceval joystick_is_haptic : joystick -> bool result
Sourceval mouse_is_haptic : unit -> bool result
Sourceval num_haptics : unit -> int result

Audio

Sourcemodule Audio : sig ... end

Audio drivers

Sourceval audio_init : string option -> unit result
Sourceval audio_quit : unit -> unit
Sourceval get_audio_driver : int -> string result
Sourceval get_current_audio_driver : unit -> string option
Sourceval get_num_audio_drivers : unit -> int result

Audio devices

Sourcetype audio_device_id = uint32
Sourcetype audio_callback

The type for audio callbacks.

Sourceval audio_callback : ('a, 'b) Bigarray.kind -> (('a, 'b) bigarray -> unit) -> audio_callback

audio_callback k f is an audio callback. A reference needs to be kept on the callback value until it is no longer needed.

Sourcetype audio_spec = {
  1. as_freq : int;
  2. as_format : Audio.format;
  3. as_channels : uint8;
  4. as_silence : uint8;
  5. as_samples : uint8;
  6. as_size : uint32;
  7. as_callback : audio_callback option;
}
Sourceval close_audio_device : audio_device_id -> unit
Sourceval free_wav : ('a, 'b) bigarray -> unit
Sourceval get_audio_device_name : int -> bool -> string result
Sourceval get_num_audio_devices : bool -> int result
Sourceval load_wav_rw : rw_ops -> audio_spec -> ('a, 'b) Bigarray.kind -> (audio_spec * ('a, 'b) bigarray) result
Sourceval lock_audio_device : audio_device_id -> unit
Sourceval open_audio_device : string option -> bool -> audio_spec -> Audio.allow -> (audio_device_id * audio_spec) result
Sourceval pause_audio_device : audio_device_id -> bool -> unit
Sourceval unlock_audio_device : audio_device_id -> unit
Sourceval queue_audio : audio_device_id -> ('a, 'b) bigarray -> unit result
Sourceval dequeue_audio : audio_device_id -> ('a, 'b) bigarray -> int
Sourceval get_queued_audio_size : audio_device_id -> int
Sourceval clear_queued_audio : audio_device_id -> unit

Timer

Sourceval delay : uint32 -> unit
Sourceval get_ticks : unit -> uint32
Sourceval get_ticks64 : unit -> uint64
Sourceval get_performance_counter : unit -> uint64
Sourceval get_performance_frequency : unit -> uint64

Platform and CPU information

Sourceval get_platform : unit -> string
Sourceval get_cpu_cache_line_size : unit -> int result
Sourceval get_cpu_count : unit -> int
Sourceval get_system_ram : unit -> int
Sourceval has_3d_now : unit -> bool
Sourceval has_altivec : unit -> bool
Sourceval has_avx : unit -> bool

SDL_HasAVX (SDL 2.0.2)

Sourceval has_avx2 : unit -> bool

SDL_HasAVX2 (SDL 2.0.4)

Sourceval has_mmx : unit -> bool
Sourceval has_neon : unit -> bool

( 2.06.0 )

Sourceval has_rdtsc : unit -> bool
Sourceval has_sse : unit -> bool
Sourceval has_sse2 : unit -> bool
Sourceval has_sse3 : unit -> bool
Sourceval has_sse41 : unit -> bool
Sourceval has_sse42 : unit -> bool

Power

Sourcetype power_state = [
  1. | `Unknown
  2. | `On_battery
  3. | `No_battery
  4. | `Charging
  5. | `Charged
]
Sourcetype power_info = {
  1. pi_state : power_state;
  2. pi_secs : int option;
  3. pi_pct : int option;
}
Sourceval get_power_info : unit -> power_info

Binding Coverage

Everything except the following functions/categories are available.

Unbound categories

Unbound functions