Sign in to follow this  

string to directinput key enum

This topic is 4201 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

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

This topic is 4201 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.

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