string to directinput key enum

Started by
1 comment, last by rzrzero 17 years, 10 months ago
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).
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.
c# has Hashtable and Dictionary <,>

This topic is closed to new replies.

Advertisement