Sign in to follow this  

[MDX / C#] scan2ascii - managed version?

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

Hello all, I'm using DirectInput to input for a chat box and I would really like to support "special" chars like å, ä and ö. I learned that I should use windows api to query these keys instead of directinput but it would be really sweet to do all keyboard input with directinput so I found scan2ascii here at gamedev but it's unmanaged. Now I'm new to MDX and C#, is it possible to convert this to managed code so I can use it to more easily handle keyboard input? Or maybe I should stop looking for a solution and just use the standard Win API to query the keys? Any help appreciated.

Share this post


Link to post
Share on other sites
For regular text input, try using the WM_CHAR message (sorry, I don't know the managed equivalent). This automatically takes care of all the normal text stuff, like shift keys, different keysets (ie American, UK, German, ect...), and key repeating (ie if you hold a key down, it only repeats every so often). It is *tons* easier to use for text box input than DInput.

Share this post


Link to post
Share on other sites
I think you should use the WM_CHAR. I can't help but feel that there is some ungainly overhead in that scan2ascii code, but I can't prove it.

See my post here for some direction on using WM_CHAR:


http://www.gamedev.net/community/forums/topic.asp?topic_id=363452


I was concerned with having disparate input methods within my application. I will say that since you are merely implementing an interface and adding the filter to Application, you can very well implement the interface in your DirectInput wrapper and still have all of your input functionality contained in one class.


public class DirectInputWrapper : IMessageFilter
{
...
}

Share this post


Link to post
Share on other sites
Those Windows API functions being used in the sample you linked can be accessed from C#, you just need to manually import them. If you look around http://www.pinvoke.net you should find prototypes for the functions and any associated structures that you can just cut and paste into your code.

In response to the above post, I wouldn't be surprised if Windows internally does more or less exactly the same thing as the scan2ascii sample and just sends the result out as the WM_CHAR message.

Share this post


Link to post
Share on other sites

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