Main Content

read

Read status of joystick button, axes, and POV

Since R2025a

    Description

    [a,b,p] = read(joystick) reads the status of axes, buttons, and points of view (POVs) of the specified joystick.

    [a,b,p] = read(joystick,f) applies feedback forces to a force-feedback joystick.

    Input Arguments

    collapse all

    Joystick object that interfaces a joystick device with the 3D environment, specified as a sim3d.io.Joystick object.

    Example: joystick = sim3d.io.Joystick(ID=1)

    Force feedback to be applied to joystick axis, specified as a scalar or a vector in the range [-1,1]. The number of elements in f should either match the number of elements of n, or f can be a scalar to be applied to all the axes specified by n. The force-feedback input provided to the joystick is a scaled value. This value is subsequently multiplied by the maximum force capability of the device.

    Example: f = 0.65

    Example: f = [0.65 -0.35]

    Output Arguments

    collapse all

    Status of joystick axis, returned as a real scalar or vector in the range [-1,1]. If n is a vector, multiple axes are returned.

    Status of joystick button, returned as either 0 or 1. If n is a vector, multiple buttons are returned.

    Point of view, returned as a real scalar or vector, in degrees. If this value is -1, no POV axis is selected.

    Version History

    Introduced in R2025a