Code covered by the BSD License
01 Apr 2013
03 Apr 2013)
Portable joystick MEX file using SDL
Watch this File
A MEX function that returns joystick axes and buttons. It should be reasonably portable since it's based on SDL which runs on Mac, Linux, Win.
>> [j,b] = joystick
0 0 -0.0039 0.0039
0 0 0 0 0 0 0 0 0 0 0 0
Could be wrapped into an S-function.
Simulink comes with similar functionality if you have the 3D Animation Toolbox.
Tested on R2012b MacOS 10.8.2 (ML) with SDL 1.2.15.
Tried on Linux
1) need to replace // with /*
2) variable event not defined
Fixed bug described by Christie, also includes release of dynamically allocated memory.
The // comment problem can be fixed by specifying the C99 compiler, but is probably platform/compiler specific.