OCamlSDL 0.9.1 : Sdljoystick

# Module Sdljoystick

    module Sdljoystick: sig .. end

Module for SDL joystick event handling

In order to use these functions, `Sdl.init` must have been called with the `JOYSTICK flag. This causes SDL to scan the system for joysticks, and load appropriate drivers.

    exception SDLjoystick_exception of string

exception for error reporting

    type t

The joystick abstract type used to identify an SDL joystick

    val num_joysticks : unit -> int

Count the number of joysticks attached to the system

    val name : int -> string

Get the implementation dependent name of a joystick. This can be called before any joysticks are opened.

    val open_joystick : int -> t

Open a joystick for use - the index passed as an argument refers to the N'th joystick on the system. This index is the value which will identify this joystick in future joystick events.
Raises `SDLjoystick_exception` if an error occurred

    val opened : int -> bool

Returns `true` if joystick has been opened

    val index : t -> int

Get the device index of an opened joystick

    val num_axes : t -> int

Get the number of general axis controls on a joystick

    val num_balls : t -> int

Get the number of trackballs on a joystick Joystick trackballs have only relative motion events associated with them and their state cannot be polled.

    val num_hats : t -> int

Get the number of POV hats on a joystick

    val num_buttons : t -> int

Get the number of buttons on a joystick

### Joystick state

    val update : t -> unit

Update the current state of the open joysticks. This is called automatically by the event loop if any joystick events are enabled.
Enable/disable joystick event polling. If joystick events are disabled, you must call `Sdljoystick.update` yourself and check the state of the joystick when you want joystick information.

    val set_event_state : bool -> unit

    val get_event_state : unit -> bool

    type hat_value = int

    val hat_centered : hat_value

    val hat_up : hat_value

    val hat_right : hat_value

    val hat_down : hat_value

    val hat_left : hat_value

    val hat_rightup : hat_value

    val hat_rightdown : hat_value

    val hat_leftup : hat_value

    val hat_leftdown : hat_value

    val get_axis : t -> int -> int

    val get_hat : t -> int -> hat_value

    val get_ball : t -> int -> int * int

    val get_button : t -> int -> bool

    val close : t -> unit

Close a joystick previously opened with `Sdljoystick.open_joystick`