title: Joystick Simulink s-function using mmsystem.h
body: <p>I am trying to develop an s-function block to get Joystick input in Simulink. While it seems pretty straight forward with mmsystem.h, now I got lots of nonsense samples between real values. I basically use S-Function Builder with no inputs and an output that has the values from joystick. I use continuous sample mode. I have the below code in my Outputs tab.</p>
  
  <pre><code>JOYINFOEX joyInfoEx;
  joyGetPosEx(0, &amp;joyInfoEx);
  
  y0[0] = joyInfoEx.dwXpos;
  y0[1]=  joyInfoEx.dwYpos;
  y0[2] = joyInfoEx.dwZpos;
  y0[3] = joyInfoEx.dwRpos;
  
  y0[4]= joyInfoEx.dwPOV;
  </code></pre>
  
  <p>My Continuous Derivatives and Discrete Update tabs are empty. But what I get when I run this s-fiction is something like below.</p>
  
  <p><img src="https://i.stack.imgur.com/DpicP.jpg" alt="enter image description here"></p>
  
  <p>I ask for any ideas or experience to tackle this problem.</p>