Previous: , Up: Input   [Contents][Index]


4.4.3 Joystick

(use-modules (sly input joystick))

Joystick hooks, signals, and procedures.

Before using joystick procedures, you must first call the initialization procedure enable-joystick.

Scheme Procedure: enable-joystick

Initialize joystick module.

Scheme Procedure: joystick-num-axes idx

Get number of axes of joystick at idx.

Scheme Procedure: joystick-num-buttons idx

Get number of buttons of joystick at idx.

Scheme Variable: joystick-axis-hook

This hook is run whenever a joystick motion occurs. Procedures added to this hook should accept three arguments: which, the joystick ID; axis, the axis ID; and value, the motion coordinate.

Scheme Variable: joystick-button-press-hook

This hook is run whenever a joystick button is pressed. Procedures added to this hook should accept two arguments: which, the joystick ID; button, the button ID.

Scheme Variable: joystick-button-release-hook

This hook is run whenever a joystick button is released. Procedures added to this hook should accept two arguments: which, the joystick ID; button, the button ID.

Scheme Variable: raw-axis-min

-32768

Scheme Variable: raw-axis-max

32767

Scheme Procedure: axis-value-raw idx axis

Create a signal on the axis at axis of the joystick at idx; joystick axis values are stored in a signed 16 bit integer and so, values range from [raw-axis-min, raw-axis-max].

Scheme Procedure: axis-value idx axis

Create a signal for the value of axis on joystick idx; values are scaled to the range [-1,1].

Scheme Procedure: button-down? idx n

Create a signal for the state of button n on joystick at idx.

Scheme Procedure: make-directional-signal idx x-axis y-axis

Create a signal for a directional pad or analog stick with x and y axes. Values are scaled to the range [-1,1].

Scheme Procedure: make-directional-signal-raw idx x-axis y-axis

Create a signal for a directional pad or analog stick with x and y axes. Values range from [raw-axis-min, raw-axis-max].

Scheme Procedure: axis-scale raw-value

Map raw-value in the range [raw-axis-min, raw-axis-max] to a value in the range [-1, 1].

Scheme Procedure: joystick-name joystick

Return the name of joystick.

Scheme Procedure: num-joysticks

Return the number of joysticks available.


Previous: , Up: Input   [Contents][Index]