-
Notifications
You must be signed in to change notification settings - Fork 362
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Fix DebugConsole to work with all keyboards. #640
base: master
Are you sure you want to change the base?
Conversation
Unfortunately, Window.TextInput wasnt in the XNA spec so it doesnt exist in FNA. I'll see if I can add a divergent path behind a compiler flag to use FNA's |
Ah, I forgot about FNA not having all Monogame features. I'll pull FNA and see if I can work something out. |
I've changed it so that it has old behaviour on FNA, and improved behaviour with monogame, using conditional compilation tags (#if FNA). It's pretty messy, but it does work. Ideally I want to find a way to get correct key input on FNA, so I'll do some more investigating. I understand if you don't want to merge a half-solution that only works on Monogame and adds a lot of mess. |
Ok. The code is even messier, but it now works fully on both monogame and FNA. Keys typed now match user keyboard layout, and you can hold keys to keep typing, including tab and backspace. Functionality has not changed. The bug relating to BitmapFont crashing when a character is missing still needs fixing. I will open another PR if you want. If you don't want to merge this because of the messy code, that's fine. I mostly made this for myself. |
I'll see if i can do some cleansing in there and unifiy the FNA/MG code paths somehow. |
The DebugConsole used a really bad switch statement to detect key input.
It was hard-coded to work with a standard US keyboard layout. If using another keyboard layout, it would not work (added wrong character).
It also didn't allow for smooth typing (holding down a key would only type 1 character).
I've changed it to use Core.Window.TextInput event to get the character that the user actually typed. This makes it work with all keyboard layouts, and whatever keyboard profile the user currently has active.
As far I'm aware, this should work for all supported (desktop) platforms. All console functionality remains intact.
Note, that when typing a character that does not exist in the BitmapFont, the font will throw an exception. This is another bug, for another pull request...