Sign in to follow this  
rzrzero

string to directinput key enum

Recommended Posts

Let's say I have the string name of a key that I saved in a config file, like "space". I want to read that in and convert it to a DirectInput.Key enum in MDX or something like a DIK_???. See here: MSDN page I looked all over the place, but it seems like I have to make a table with the string to int correspondence. Is there any other way besides making a table with values like from that link above? P.S. Going the other direction (enum to string) is easy(ier).

Share this post


Link to post
Share on other sites
No, not that I know of.

If you program in C, then the fastest thing you can do is create a hash-table is you are worried about performance.

If you program in C++, use a map (STL object) to associate some string with an int.

If you program in C#, well, you are on your own. Find something with C++'s STL map in functionality.
You might try to see if:


Map m = new HashMap();

works. That is for Java, but it likely exists on .NET because M$ loves to steal code AND ideas.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this