Main Content

Gamepad Joystick

Represent one control axis on x-yanalog VEX gamepad joystick and read values

  • Gamepad Joystick block

Simulink Coder Support Package for ARM Cortex-based VEX Microcontroller / Gamepad


The Gamepad Joystick block is used to represent one of the control axes of an x-y analog joystick on the VEX® gamepad. The block reads the corresponding analog value based on the position of the joystick along that axis. There are two analog joysticks on the VEX gamepad with two control axes (x-y) on each joystick.



expand all

Connect a source block, such as the Gamepad Simulator block from the Utilities library in Simulink® Support Package for ARM® Cortex®-based VEX Microcontroller.


This port appears only when you select the Add input port for simulation parameter.

Data Types: double


expand all

The block output ranges from –128 to 127 based on the position of the joystick along the specified control axis. A value of 0 indicates that the joystick has not been moved along the axis.

During simulations, without the hardware, this block emits zeroes if there is no source block connected the simulation input port (see Block Produces Zeros or Does Nothing in Simulation).

Data Types: double


expand all

This parameter is read only. You can have a pair of VEX gamepads to control the peripherals connected to the VEX microcontroller. However, in the VEX Robotics and BEST Robotics competitions, teams are allowed only one gamepad. Therefore, Joystick Number is set to 1 by default, and it cannot be changed.

Select the control axis to read on the VEX gamepad. The right joystick has horizontal axis labeled 1 and its vertical axis is labeled 2. The left joystick has horizontal axis labeled 3 and its vertical axis is labeled 4. Based on your selection, the mask icon of the block is updated in the Simulink Editor.

Select this check box to add an input port to specify an analog value during simulation.

How often the Gamepad Joystick block should read the values from the gamepad joystick specified in seconds. The default value is 0.02 seconds.

If you select the Add input port for simulation check box, the Sample time parameter is hidden and its value is inherited.

Extended Capabilities

Version History

Introduced in R2016a