Main Content

sim3d.io.Joystick

Create joystick device interface

Since R2025a

    Description

    Use the sim3d.io.Joystick object to create an interface between a joystick input device and the 3D environment.

    Creation

    Description

    joystick = sim3d.io.Joystick() creates a joystick object capable of interfacing with a joystick device.

    joystick = sim3d.io.Joystick(Name=Value) specifies options using one or more name-value arguments. For example, if the joystick supports force-feedback capability, to enable force feedback, set ForceFeedback to 1.

    The sim3d.io.Joystick object supports all joystick devices that use the Microsoft® APIs DirectInput and XInput components as their communication protocols.

    Name-Value Arguments

    expand all

    Specify optional pairs of arguments as Name1=Value1,...,NameN=ValueN, where Name is the argument name and Value is the corresponding value. Name-value arguments must appear after other arguments, but the order of the pairs does not matter.

    Example: joystick = sim3d.io.Joystick(ID=1,ForceFeedback=1) creates a joystick object that interfaces with the joystick device connected to your computer with the specified system ID and force feedback.

    System ID for joystick device, specified as a real positive scalar. ID is a one-based joystick ID. The joystick ID is the system ID assigned to the given joystick device. You can find the properties of the joystick that is connected to the system in the Game Controllers section of the system Control Panel.

    Option to enable force feedback if the joystick supports this capability, specified as 0 (false) if force feedback is disabled or 1 (true) if it is enabled.

    Output Arguments

    expand all

    Actor object, returned as a sim3d.io.Joystick object.

    Properties

    expand all

    This property is read-only.

    Number of axes supported by the joystick device, specified as a real positive scalar.

    Example: joystick.Axes = 8

    Data Types: double

    This property is read-only.

    Number of buttons on the joystick device, specified as a real positive scalar.

    Example: joystick.Buttons = 8

    Data Types: double

    This property is read-only.

    Number of POV axes on the joystick device that support point of view, specified as a real positive scalar.

    Example: joystick.POVs = 4

    Data Types: double

    This property is read-only.

    Number of axes with force feedback on the joystick device, specified as a real positive scalar.

    Example: joystick.Forces = 2

    Data Types: double

    Object Functions

    axisRead status of joystick
    buttonRead status of joystick
    capsJoystick capabilities
    forceApply force feedback to joystick axis
    povRead status of joystick point of view
    readRead status of joystick button, axes, and POV

    Version History

    Introduced in R2025a