S-Function for reading joystick values on Simulink
Version 1.0.2 (48.5 KB) by
Johannes Soikkeli
S-Function build using Windows JOYINFOEX (Winmm.lib). This S-Function supports Rapid Accelerator. Currently outputs 4 axis and 12 buttons.
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:
Motivation:
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:
- 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).
- 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 LinuxTags
Acknowledgements
Inspired by: sfun_joystick.zip
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!Discover Live Editor
Create scripts with code, output, and formatted text in a single executable document.