title: Joystick acquisition with SharpDX
body: <p>I'm new about C# and Sharpdx. I have this code problem from a couple of days and I don't understand way doesn't work! This is a simple task about acquiring a value of one axis of a Joystick and show it on a text box in a Form.</p>
  
  <p>I did a new project on Visual Studio 2010 express and I did a Form with a button and a textBox for show the value of the joystick axis (X axis).</p>
  
  <p>The first part of code down here is the example on the sharpdx documentation, the second part is a little bit different.</p>
  
  <p>The problem is that the value doesn't change every time I push the button</p>
  
  <p>Something is wrong but I don't know what</p>
  
  <pre><code>private void button3_Click(object sender, EventArgs e)
  {
    // Initialize DirectInput
    var directInput = new DirectInput();
  
    // Find a Joystick Guid
    var joystickGuid = Guid.Empty;
  
    foreach (var deviceInstance in directInput.GetDevices(DeviceType.Gamepad,  DeviceEnumerationFlags.AllDevices))
      joystickGuid = deviceInstance.InstanceGuid;
  
    // If Gamepad not found, look for a Joystick
    if (joystickGuid == Guid.Empty)
      foreach (var deviceInstance in directInput.GetDevices(DeviceType.Joystick,  DeviceEnumerationFlags.AllDevices))
        joystickGuid = deviceInstance.InstanceGuid;
  
    // If Joystick not found, throws an error
    if (joystickGuid == Guid.Empty)
    {
        Console.WriteLine("No joystick/Gamepad found.");
        Console.ReadKey();
        Environment.Exit(1);
    }  
  
    // Instantiate the joystick e stato
    Joystick joystick = new Joystick(directInput, joystickGuid);
    JoystickState stato = new JoystickState();
  
    // specifico se relativo o assoluto
    joystick.Properties.AxisMode = DeviceAxisMode.Absolute;
  
    // effettuo un collegamento con il joystick
    joystick.Acquire();
  
    // qui faccio una acquisizione dello stato che memorizzo
    joystick.Poll();
  
    // effettuo una lettura dello stato
    joystick.GetCurrentState(ref stato);
  
    // stampo il valore dell'ordinata
    textBox1.Text = stato.X.ToString();
  }
  </code></pre>