• Which the release of FS2020 we see an explosition of activity on the forun and of course we are very happy to see this. But having all questions about FS2020 in one forum becomes a bit messy. So therefore we would like to ask you all to use the following guidelines when posting your questions:

    • Tag FS2020 specific questions with the MSFS2020 tag.
    • Questions about making 3D assets can be posted in the 3D asset design forum. Either post them in the subforum of the modelling tool you use or in the general forum if they are general.
    • Questions about aircraft design can be posted in the Aircraft design forum
    • Questions about airport design can be posted in the FS2020 airport design forum. Once airport development tools have been updated for FS2020 you can post tool speciifc questions in the subforums of those tools as well of course.
    • Questions about terrain design can be posted in the FS2020 terrain design forum.
    • Questions about SimConnect can be posted in the SimConnect forum.

    Any other question that is not specific to an aspect of development or tool can be posted in the General chat forum.

    By following these guidelines we make sure that the forums remain easy to read for everybody and also that the right people can find your post to answer it.

Converting HotKey Virtual Key codes to Strings and Back Again

Messages
65
Country
us-massachusetts
Hi,

Thanks so much to everyone who's helped me on this forum, I hope I'm not too annoying. I'm not exactly sure where to post this, because it's not directly related to the FSX or SimConnect API, but I figure it's probably something Flight Sim developers know how to do - if there's a better place for it, let me know. Issue is this:

As part of my LF/MF Range project, I'm trying to create a Key input configuration tool so the user can set keys to control the various radio switches. I'm using MFC CHotKeyCtrl objects to get the desired settings from the user. Then I have to convert the code returned from CHotKeyCtrl::GetHotKey() to a string, which I can write to a configuration file which can be viewed and edited by the user. This same string will also be passed to SimConnect to set up the key input notifications for my application. Then I need to convert the string back to a virtual key code with modifiers, so that I can pass it in this format as arguments to CHotKeyCtrl::SetHotKey(), so the stored settings are displayed when the configuration utility is opened.

Unfortunately, I've spent a couple days now mired in a maze of virtual key codes, unable to reliably convert back and forth between strings and virtual key codes, especially when it comes to extended keys and numpad keys. The hotkey control seems to ignore the state of scroll lock or num lock, so all the input will appear in the control as "Num 7", "Num 9", etc, but then GetHotKey() will return a VK_HOME, VK_PRIOR, etc. In addition, when loading, if I pass the control VK_NUM7, it will display as "Home". I've written a what seems like heck of a lot of code on this bit, and it's still not quite working... I can't help feeling I must be reinventing the wheel.

So my question is, is there some library, class, functions, or tutorial which already exists, which handles reading Hotkey controls, converting them to a config-file-suitable string format, converting them back? It seems like I'm writing a lot of code which probably exists in some tutorial somewhere, I just can't seem to find it. If you've written a key input tool before, how did you do it? What tools did you use? Can you give me any pointers? Is it just hard, and I need to figure it out? Am I missing something obvious? etc. Any tips would be very, very much appreciated. I apologize if I seem a little desperate.

Sincerely,
Farley
 
Back
Top