locked
DirectInput and Mouse Acceleration RRS feed

  • Question

  • I am using the Managed Direct Input library to gather mouse input for a graphical research app.  However, my testing shows that the application is affected by mouse acceleration despite using the Direct Input API. My understanding was that only driver level acceleration could affect the Direct Input data, but if I test some of the samples that ship with the DirectX SDK I don't see the same problem.  The documentation is weak on this topic.  However, there seems to be a knowledge base out there amongst developers.  Does anyone have any ideas I can try.  The applicaition is running under Windows XP and I was testing with the Logitech 9.80 mouse driver.  Thanks.
    Monday, July 25, 2005 5:29 PM

Answers

  • If the hardware vendor supplies acceleration as part of the driver, that may be causing the issue.  Try your applications without using the Logitech driver and see if you have the same symptoms.

    Wednesday, August 17, 2005 9:11 PM

All replies

  • Can we see some of your code when using the mouse input? This would help out with tracking down the problem.

    Monday, July 25, 2005 9:31 PM
  • The application is structured so that most of it centers around a set of windows forms.  DirectX shows up when it is time to administer a "test".  At this point I use DirectXDraw in full-screen exclusive mode and DirectInput in exclusive mode.  The class that handles both is derived from System.Windows.Form.  When the main application is ready to administer a set of tests, it feeds the necessary information to the class and calls Display().  Here is the general code.  If more detail is needed, let me know.  I hope someone can help me figure this out.

    public void Display()
    {
      InitDirectDraw();  //Creates the DirectXDraw device and sets it up (640x480)
      InitDirectInput();  //(create mouse, set exclusive/foreground, acquire)
      Rendering =
    true;

      while (Rendering)
      {
        HandleInput();  //Shown below
        DisplayFrame(); //Renders to the DirectXDraw surface
        Application.DoEvents();
      }
      // Clean up
      MouseDevice.Unacquire();
      DisplayDevice.RestoreDisplayMode();
      DisplayDevice.SetCooperativeLevel(
    this,DXD.CooperativeLevelFlags.Normal);
    }

    protected override void HandleInput()
    {
      base.HandleInput();

      // Get the current state of the mouse device.
      MouseState mouseStateData = new MouseState();
      if (!GetMouseState(ref mouseStateData))
        return;

      ...Handle the data in mouseStateData.X and mouseStateData.Y
      ...Look for end of test conditions (mouse past a certain point)
    }

    Saturday, August 6, 2005 12:48 PM
  • If the hardware vendor supplies acceleration as part of the driver, that may be causing the issue.  Try your applications without using the Logitech driver and see if you have the same symptoms.

    Wednesday, August 17, 2005 9:11 PM
  • I dug into this again today. 

    I noticed that the C# DirectInput mouse sample in the SDK was not affected by mouse acceleration.  I mimiced the code by my application was still affected.  So I set out to find out why.

    I noticed that my form that was calling into DirectInput was not a top level form but was brought up from another.  So I added another form the sample app, replaced the frmUI in the Application.Run() call and added a button to bring up frmUI.

    From my testing it appears that if the form in the C# DirectInput mouse app is not the form used in Application.Run(), but is instead brought up using frmUI.Show() or frmUI.ShowDialog() then the form is affected by mouse acceleration.  I'm not certain how C# sets up its message loop, or how that interacts with the way that app is set up to deal with mouse input.  It seems strange to me.  Any ideas?
    Saturday, August 27, 2005 7:43 PM