Skip to main content
GameDev.net gamedev.net
🔒 Locked

[.net] DirectInput problem - custom keys

Started by Fallen_Angel Jan 11, 2005 at 9:34 PM 1 replies 700+ views
Original Post
Fallen_Angel
Fallen_Angel
I'm having some trouble setting up custom input keys. I am able to assign the keys on startup however am not able to detect them during gameplay. Here is what I am currently doing:

KeyboardState state = deviceKeyboard.GetCurrentKeyboardState();

//What I am currently doing:
if (state[Key.Up])
{
	//Do something...
}

//What I want to do:
if ((state[Key.Up]) || (state[strKeyUp]))
{
	//Do something...
}


However this is not doing anything with the variable keys. My only other thought on this is to check the state of every key and then see if that key is assigned to one of my keys, but I'm sure that there has to be a better way than that of doing this?
DaWanderer
DaWanderer
String MyCustomKey = "Up"; //any name in the Keys enumerationKeys CustomKeyValue = (Keys)Enum.Parse(typeof(Keys), MyCustomKey); //add a true boolean parameter to ignore caseif (state[CustomKeyValue]){   //...}

Topic Locked

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

Sign in to reply to this topic.