S-Function for reading joystick values on Simulink

S-Function build using Windows JOYINFOEX (Winmm.lib). This S-Function supports Rapid Accelerator. Currently outputs 4 axis and 12 buttons.
Updated 16 Feb 2024

View License

S-Function for reading joystick values on Simulink
The S-Function supports "Rapid Acceleration".
The sfun_joyinfoex.c is build using the Windows JOYINFOEX function part of the Winmm library:
I needed a joystick interface that can support Rapid Acceleration mode as this is part of a large flight dynamics simulator and Rapid Accelerator enables large performance gains. The standard Simulink joystick block does not support code generation / Rapid Accelerator and hence I had to generate one. The original version is from Per Hillerborg but istead of JOYINFO (only three axis) it was changed to JOYINFOEX supporting more axis and buttons (also other parts of S-Function itself has been changed a bit).
To build the S-Function:
  1. You need to have WinMM.lib (needed for building) in the same folder (or you can of course include the path into the build command).The WinMM.lib file is part of the Windows SDK (You can just navigate to the generated Windows Kit folder and search for it and make sure to pick the correct file according to your CPU architecture).
  2. Run following command on MATLAB terminal:
mex sfun_joyinfoex.c -lwinmm

Cite As

Johannes Soikkeli (2024). S-Function for reading joystick values on Simulink (https://www.mathworks.com/matlabcentral/fileexchange/111265-s-function-for-reading-joystick-values-on-simulink), MATLAB Central File Exchange. Retrieved .

MATLAB Release Compatibility
Created with R2021b
Compatible with any release
Platform Compatibility
Windows macOS Linux

Inspired by: sfun_joystick.zip

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!
Version Published Release Notes

Removed the WinMM.dll file based on MathWorks policies.


Removed already compiled .mex file due to MathWorks policies.