Skip to main content
gamedev.net
🔒 Locked

keyboard error

Started by cptrnet Nov 2, 2005 at 3:10 PM 3 replies 600+ views
Original Post
cptrnet
cptrnet
I am trying to get the keyboard to work. I have this code,

public void InitKeyboard()
{
	keyb = new Microsoft.DirectX.DirectInput.Device(SystemGuid.Keyboard);
	keyb.SetCooperativeLevel(this, CooperativeLevelFlags.Background | CooperativeLevelFlags.NonExclusive);
	keyb.Acquire();
}

but when it gets ran it gives me this error, right around the Acquire part. Do i have to reinstall directx, or do I have a different version. That code should work shouldn't it?

"An unhandled exception of type 'Microsoft.DirectX.DirectInput.UnsupportedException' occurred in microsoft.directx.directinput.dll"

If you insist on saying "DUH", try to make a post that makes a little more sense
Dave Hunt
Dave Hunt
Unsupported Exception means that you've requested a behavior that is not supported. You aren't allowed to get background access to the keyboard. You should specify CooperativeLevelFlags.Foreground instead of CooperativeLevelFlags.Background.
cptrnet
cptrnet
Now I get this error. It is the only program running too.

"Microsoft.DirectX.DirectInput.OtherApplicationHasPriorityException"
If you insist on saying "DUH", try to make a post that makes a little more sense
Dave Hunt
Dave Hunt
You should wait to acquire the device until after the application has been activated (usually by a Form.Show() call). If you are doing the acquire before the form is up, the acquire will fail.
cptrnet
cptrnet
Thanks alot.
If you insist on saying "DUH", try to make a post that makes a little more sense

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.