Jump to content
  • Advertisement
Sign in to follow this  
rzrzero

string to directinput key enum

This topic is 4490 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
Advertisement
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
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!