text
stringlengths
0
601k
let get_cursor_shown ( ) = show_cursor ( - 1 )
let set_cursor = foreign " SDL_SetCursor " ( cursor_opt @-> returning void )
let set_relative_mouse_mode = foreign " SDL_SetRelativeMouseMode " ( bool @-> returning zero_to_ok )
let show_cursor b = show_cursor ( if b then 1 else 0 )
let warp_mouse_in_window = foreign " SDL_WarpMouseInWindow " ( window_opt @-> int @-> int @-> returning void )
let warp_mouse_in_window w ~ x ~ y = warp_mouse_in_window w x y
let warp_mouse_global = foreign " SDL_WarpMouseGlobal " ( int @-> int @-> returning zero_to_ok )
let warp_mouse_global ~ x ~ y = warp_mouse_global x y
let touch_mouse_id = Int64 . of_int32 ( sdl_touch_mouseid )
type finger = _finger structure
let finger : finger typ = structure " SDL_Finger "
let finger_finger_id = field finger " id " finger_id
let finger_x = field finger " x " float
let finger_y = field finger " y " float
let finger_pressure = field finger " pressure " float
let ( ) = seal finger
module Finger = struct let id f = getf f finger_finger_id let x f = getf f finger_x let y f = getf f finger_y let pressure f = getf f finger_pressure end
let get_num_touch_devices = foreign " SDL_GetNumTouchDevices " ( void @-> returning int )
let get_num_touch_fingers = foreign " SDL_GetNumTouchFingers " ( touch_id @-> returning int )
let get_touch_device = foreign " SDL_GetTouchDevice " ( int @-> returning touch_id )
let get_touch_device i = match get_touch_device i with | 0L -> error ( ) | id -> Ok id
let get_touch_finger = foreign " SDL_GetTouchFinger " ( touch_id @-> int @-> returning ( ptr_opt finger ) )
let get_touch_finger id i = match get_touch_finger id i with | None -> None | Some p -> Some ( !@ p )
let load_dollar_templates = foreign " SDL_LoadDollarTemplates " ( touch_id @-> rw_ops @-> returning zero_to_ok )
let record_gesture = foreign " SDL_RecordGesture " ( touch_id @-> returning one_to_ok )
let save_dollar_template = foreign " SDL_SaveDollarTemplate " ( gesture_id @-> rw_ops @-> returning zero_to_ok )
let save_all_dollar_templates = foreign " SDL_SaveAllDollarTemplates " ( rw_ops @-> returning zero_to_ok )
type joystick_guid = _joystick_guid structure
let joystick_guid : joystick_guid typ = structure " SDL_JoystickGUID "
let _ = field joystick_guid " data0 " uint8_t
let _ = field joystick_guid " data1 " uint8_t
let _ = field joystick_guid " data2 " uint8_t
let _ = field joystick_guid " data3 " uint8_t
let _ = field joystick_guid " data4 " uint8_t
let _ = field joystick_guid " data5 " uint8_t
let _ = field joystick_guid " data6 " uint8_t
let _ = field joystick_guid " data7 " uint8_t
let _ = field joystick_guid " data8 " uint8_t
let _ = field joystick_guid " data9 " uint8_t
let _ = field joystick_guid " data10 " uint8_t
let _ = field joystick_guid " data11 " uint8_t
let _ = field joystick_guid " data12 " uint8_t
let _ = field joystick_guid " data13 " uint8_t
let _ = field joystick_guid " data14 " uint8_t
let _ = field joystick_guid " data15 " uint8_t
let ( ) = seal joystick_guid
type joystick = unit ptr
let joystick : joystick typ = ptr void
let joystick_opt : joystick option typ = ptr_opt void
let unsafe_joystick_of_ptr addr : joystick = ptr_of_raw_address addr
let unsafe_ptr_of_joystick joystick = raw_address_of_ptr ( to_voidp joystick )
module Hat = struct type t = int let centered = sdl_hat_centered let up = sdl_hat_up let right = sdl_hat_right let down = sdl_hat_down let left = sdl_hat_left let rightup = sdl_hat_rightup let rightdown = sdl_hat_rightdown let leftup = sdl_hat_leftup let leftdown = sdl_hat_leftdown end
module Joystick_power_level = struct type t = int let unknown = sdl_joystick_power_unknown let low = sdl_joystick_power_low let medium = sdl_joystick_power_medium let full = sdl_joystick_power_full let wired = sdl_joystick_power_wired let max = sdl_joystick_power_max end
module Joystick_type = struct type t = int let unknown = sdl_joystick_type_unknown let gamecontroller = sdl_joystick_type_gamecontroller let wheel = sdl_joystick_type_wheel let arcade_stick = sdl_joystick_type_arcade_stick let flight_stick = sdl_joystick_type_flight_stick let dance_pad = sdl_joystick_type_dance_pad let guitar = sdl_joystick_type_guitar let drum_kit = sdl_joystick_type_drum_kit let arcade_pad = sdl_joystick_type_arcade_pad let throttle = sdl_joystick_type_throttle end
let joystick_close = foreign " SDL_JoystickClose " ( joystick @-> returning void )
let joystick_current_power_level = foreign " SDL_JoystickCurrentPowerLevel " ( joystick @-> returning int )
let joystick_event_state = foreign " SDL_JoystickEventState " ( int @-> returning nat_to_ok )
let joystick_from_instance_id = foreign " SDL_JoystickFromInstanceID " ( joystick_id @-> returning joystick )
let joystick_get_event_state ( ) = joystick_event_state sdl_query
let joystick_set_event_state s = joystick_event_state s
let joystick_get_attached = foreign " SDL_JoystickGetAttached " ( joystick @-> returning bool )
let joystick_get_axis = foreign " SDL_JoystickGetAxis " ( joystick @-> int @-> returning int16_t )
let joystick_get_axis_initial_state = foreign " SDL_JoystickGetAxisInitialState " ( joystick @-> int @-> returning int16_t )
let joystick_get_ball = foreign " SDL_JoystickGetBall " ( joystick @-> int @-> ( ptr int ) @-> ( ptr int ) @-> returning int )
let joystick_get_ball j i = let x = allocate int 0 in let y = allocate int 0 in match joystick_get_ball j i x y with | 0 -> Ok ( !@ x , !@ y ) | _ -> error ( )
let joystick_get_button = foreign " SDL_JoystickGetButton " ( joystick @-> int @-> returning int_as_uint8_t )
let joystick_get_device_guid = foreign " SDL_JoystickGetDeviceGUID " ( int @-> returning joystick_guid )
let joystick_get_device_product = foreign " SDL_JoystickGetDeviceProduct " ( int @-> returning int_as_uint16_t )
let joystick_get_device_product_version = foreign " SDL_JoystickGetDeviceProductVersion " ( int @-> returning int_as_uint16_t )
let joystick_get_device_type = foreign " SDL_JoystickGetDeviceType " ( int @-> returning int )
let joystick_get_device_instance_id = foreign " SDL_JoystickGetDeviceInstanceID " ( int @-> returning joystick_id )
let joystick_get_device_vendor = foreign " SDL_JoystickGetDeviceVendor " ( int @-> returning int_as_uint16_t )
let joystick_get_guid = foreign " SDL_JoystickGetGUID " ( joystick @-> returning joystick_guid )
let joystick_get_guid_from_string = foreign " SDL_JoystickGetGUIDFromString " ( string @-> returning joystick_guid )
let joystick_get_guid_string = foreign " SDL_JoystickGetGUIDString " ( joystick_guid @-> ptr char @-> int @-> returning void )
let joystick_get_guid_string guid = let len = 33 in let s = CArray . start ( CArray . make char 33 ) in joystick_get_guid_string guid s len ; coerce ( ptr char ) string s
let joystick_get_hat = foreign " SDL_JoystickGetHat " ( joystick @-> int @-> returning int_as_uint8_t )
let joystick_get_product = foreign " SDL_JoystickGetProduct " ( joystick @-> returning int_as_uint16_t )
let joystick_get_product_version = foreign " SDL_JoystickGetProductVersion " ( joystick @-> returning int_as_uint16_t )
let joystick_get_type = foreign " SDL_JoystickGetType " ( joystick @-> returning int )
let joystick_get_vendor = foreign " SDL_JoystickGetVendor " ( joystick @-> returning int_as_uint16_t )
let joystick_instance_id = foreign " SDL_JoystickInstanceID " ( joystick @-> returning joystick_id )
let joystick_instance_id j = match joystick_instance_id j with | n when n < 0l -> error ( ) | n -> Ok n
let joystick_name = foreign " SDL_JoystickName " ( joystick @-> returning ( some_to_ok string_opt ) )
let joystick_name_for_index = foreign " SDL_JoystickNameForIndex " ( int @-> returning ( some_to_ok string_opt ) )
let joystick_num_axes = foreign " SDL_JoystickNumAxes " ( joystick @-> returning nat_to_ok )
let joystick_num_balls = foreign " SDL_JoystickNumBalls " ( joystick @-> returning nat_to_ok )
let joystick_num_buttons = foreign " SDL_JoystickNumButtons " ( joystick @-> returning nat_to_ok )
let joystick_num_hats = foreign " SDL_JoystickNumHats " ( joystick @-> returning nat_to_ok )
let joystick_open = foreign " SDL_JoystickOpen " ( int @-> returning ( some_to_ok joystick_opt ) )
let joystick_update = foreign " SDL_JoystickUpdate " ( void @-> returning void )
let num_joysticks = foreign " SDL_NumJoysticks " ( void @-> returning nat_to_ok )
type game_controller = unit ptr
let game_controller : game_controller typ = ptr void
let game_controller_opt : game_controller option typ = ptr_opt void
let unsafe_game_controller_of_ptr addr : game_controller = ptr_of_raw_address addr
let unsafe_ptr_of_game_controller game_controller = raw_address_of_ptr ( to_voidp game_controller )
let button_bind : _button_bind structure typ = structure " SDL_GameControllerBindType "
let button_bind_bind_type = field button_bind " bindType " int
let button_bind_value1 = field button_bind " value1 " int