5.10. joystick — Joystick support

The Joystick class represents a joystick device. It can be used to retrieve the current values of the joystick and to calibrate the joystick axes. The minimum and maximum positions of the axes are automatically determined while the joystick is in use. The middle position has to be set manually by calling the setAxisMiddle() method.

class cgkit.joystick.Joystick

The scene will contain one Joystick object for every joystick that is found.


The device id of the joystick.


The name of the joystick device.


The number of axes this joystick has.


The number of hats this joystick has.


The number of balls this joystick has.


The number of buttons this joystick has.


Returns a calibrated axis value as a float. axis is the number of the axis (starting with 0).


Returns a hat value. hat is the number of the hat (starting with 0). The return value is a 2-tuple of integers (x, y).


Returns a ball value as a float. ball is the number of the ball (starting with 0).


Return the state of button button (0-based number) as a boolean.

Joystick.setAxis(axis, value)
Joystick.setHat(hat, x, y)
Joystick.setBall(ball, value)
Joystick.setButton(button, value)
Joystick.setAxisMiddle(axis=None, mid=None)

Sets the joystick axis position that will be mapped to the value 0.0. This means, if the joystick outputs the (uncalibrated) value mid, then the calibrated value will be 0.0. axis is the number of the axis you wish to set. If it is None, all axes are set at once. mid is the middle value. If it is None, the current value is used.

Previous topic

5.9. boundingbox — An axis-aligned bounding box

Next topic

6. Components

This Page