title: How to use DirectX.DirectInput in XNA
body: <p>joystick.cs</p>
  
  <pre><code>using System;
  using Microsoft.DirectX.DirectInput;
  
  namespace gameproject
  {
      /// &lt;summary&gt;
      /// Description of device.
      /// &lt;/summary&gt;
      class joysticks
      {
  
          public static Device joystick;
          public static JoystickState state;
  
          public static void InitDevices() //Function of initialize device
          {
              //create joystick device.
              foreach (DeviceInstance di in Manager.GetDevices(
                  DeviceClass.GameControl,
                  EnumDevicesFlags.AttachedOnly))
              {
                  joystick = new Device(di.InstanceGuid);
                  break;
              }
  
              if (joystick == null)
              {
                  //Throw exception if joystick not found.
              }
  
              //Set joystick axis ranges.
              else {
                  foreach (DeviceObjectInstance doi in joystick.Objects)
                  {
                      if ((doi.ObjectId &amp; (int)DeviceObjectTypeFlags.Axis) != 0)
                      {
                          joystick.Properties.SetRange(
                              ParameterHow.ById,
                              doi.ObjectId,
                              new InputRange(-5000, 5000));
                      }
  
                  }
  
                  joystick.Properties.AxisModeAbsolute = true;
                  joystick.SetCooperativeLevel(null,CooperativeLevelFlags.NonExclusive | CooperativeLevelFlags.Background);
  
                  //Acquire devices for capturing.
                  joystick.Acquire();
                  state = joystick.CurrentJoystickState;
              }
          }
  
          public static void UpdateJoystick()   // Capturing from device joystick
          {
              //Get Joystick State.
              if(joystick!=null)
                  state = joystick.CurrentJoystickState;
          }
  
      }
  }
  </code></pre>
  
  <p><strong>In this line, an error occurred,</strong></p>
  
  <pre><code>    joystick.SetCooperativeLevel(null,CooperativeLevelFlags.NonExclusive 
  | CooperativeLevelFlags.Background);
  </code></pre>
  
  <p><strong>error,</strong></p>
  
  <pre><code>Error 1 The type 'System.Windows.Forms.Control' is defined in an 
  assembly that is not referenced.
       You must add a reference to assembly 'System.Windows.Forms...
  </code></pre>
  
  <p>I'm working on,XNA 3.0 and .NET 3.5, so what means that error? </p>