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.
-
Joystick.id
- The device id of the joystick.
-
Joystick.name
- The name of the joystick device.
-
Joystick.numaxes
- The number of axes this joystick has.
-
Joystick.numhats
- The number of hats this joystick has.
-
Joystick.numballs
- The number of balls this joystick has.
-
Joystick.numbuttons
- The number of buttons this joystick has.
-
Joystick.getAxis(axis)
- Returns a calibrated axis value as a float. axis is the number of the axis
(starting with 0).
-
Joystick.getHat(hat)
- 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).
-
Joystick.getBall(ball)
- Returns a ball value as a float. ball is the number of the ball (starting with
0).
-
Joystick.getButton(button)
- 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.