Jump to content
  • Advertisement
Sign in to follow this  
Thevenin

[MDX] Other Application Has Priority Exception

This topic is 4685 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

So I finished writing my DirectInput wrapper and to my dismay, it won't allow me to get the input. When I attempt to acquire the device I get this error... "Other Application Has Priority Exception" ... and I'm not too sure why I'm getting this. Here is the relevent parts of my code...
public class cDirectXInput
{

    private MouseState MyMouse;
    private KeyboardState MyKeyboard;
    private Guid MyMouseGuid;
    private Guid MyKeyboardGuid;

    private Device MyKeyboardDevice = null;
    private Device MyMouseDevice = null; 

    private bool[] MyLockedKeys; 


    public cDirectXInput(Control MyTargetControl)
    {
        /* Locked keys means we only see presses instead of press/frame. */
        MyLockedKeys = new bool[256];

        /* Grab the global unique identifer for both the keyboard and the mouse. */
        MyMouseGuid = SystemGuid.Mouse;
        MyKeyboardGuid = SystemGuid.Keyboard;


        /* Create the keyboard and mouse device. */
        MyKeyboardDevice = new Device(MyKeyboardGuid);
        MyMouseDevice = new Device(MyMouseGuid);

        /* Check that it went through. */
        if (MyKeyboardDevice == null /*|| MyMouseDevice == null*/)
            throw new DirectXException("DirectInput Error; you have no control.");

        /* Configure the cooperativity of the devices. */
        MyKeyboardDevice.SetCooperativeLevel(MyTargetControl,
            CooperativeLevelFlags.Foreground | CooperativeLevelFlags.NonExclusive);
        MyMouseDevice.SetCooperativeLevel(MyTargetControl,
            CooperativeLevelFlags.Foreground | CooperativeLevelFlags.NonExclusive);

        /* Tell them to start working right away~!*/
        MyKeyboardDevice.Acquire();
        MyMouseDevice.Acquire();
    }
}
At the line...
MyKeyboardDevice.Acquire();
.. the exception is thrown. I'm using this class like so...
public partial class MyWindow : Form
{
    public MyWindow()
    {
        cDirectXInput MyTest = new cDirectXInput(this);
        InitializeComponent();
    }
}
Any ideas?

Share this post


Link to post
Share on other sites
Advertisement
Try setting the flags of the device to CooperativeLevelFlags.NonExclusive | CooperativeLevelFlags.Background, this will get rid of your problem.

I hope this helps.
Take care.

Share this post


Link to post
Share on other sites
Quote:
Original post by Armadon
Try setting the flags of the device to CooperativeLevelFlags.NonExclusive | CooperativeLevelFlags.Background, this will get rid of your problem.

I hope this helps.
Take care.


Thanks [smile]
ratings++;

Share this post


Link to post
Share on other sites
Afair this has to do with visual studio, it creates some DirectInput device while debugging.
In a "normal" environment this problem should not happen.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!