Jump to content
The simFlight Network Forums

Basic Hot Key Question


Recommended Posts

Hi Pete

Just looking at how to implement hot keys using offsets 320C etc. I think I understand the process. As I read it the value in 320C should be 56. if it is zero then something is wrong!

As far as the virtual keycode is concerned I write that to byte zero of a free slot and any shift state in byte 1. I monitor byte 3 for non zero and that tells me the key has been pressed. Looking at byte 2 it seems that I would trap this and the key would not pass to FS unless I set bit 1 of byte 2.

I checked the advanced user guide for virtual key codes - I am interested in the main keyboard numbers 1 thru 3 and these have the codes 97, 98, and 99. In the advanced user guide it says that the virtual keycode is the number followed by K. Is the K required for the hot key function or do I just write the value?

thanks in advance

Link to comment
Share on other sites

In the advanced user guide it says that the virtual keycode is the number followed by K. Is the K required for the hot key function or do I just write the value?

You are correct about the other things, but where does it say to follow a keycode by K? Are you by any chance mis-reading the sentence:

For key presses, the value following the letter ‘K’ is the virtual key code ...

which is referring back to the Format of the [buttons] programming entry in the FSUIPC.INI file? i.e.

For keypresses:

= ,,K,

The K is used in that entry to distinguish Keycodes from Controls ('C'). But that's all to do with FSUIPC buttons programming in the INI file, nothing whatsoever to do with programming hot keys in any application.

You can find all the Virtual Keycodes in any Windows programming reference too. They are known by names starting VK_ and are returned by Windows WM_KEYDOWN and WM_KEYUP messages.

Regards,

Pete

Link to comment
Share on other sites

Pete

Quick follow-up. Am I right in assuming that once a key is pressed the state of byte 3 persists. In othe words if I am looking for the user to press say '1' but '2' get pressed by mistake then FSUIPC will show that '2' was pressed until my application clears it?

Dunno if I am explaining it very well but if I am checking for a keypress every second say then I need to clear all the byte 3's down to zero after the test otherwise if I test for '2' later in the program it will be set even though it was not pressed when I expected it but earlier by mistake

=======================

OK re-reading the programmers guide I think that answers the question - I do need to clear them

=========================

thanks

Link to comment
Share on other sites

Am I right in assuming that once a key is pressed the state of byte 3 persists.

FSUIPC never clears that byte. As it says "This byte needs to be cleared by the application so that it can detect when the Hot Key occurs." Since FSUIPC doesn't know how often you are scanning, it cannot risk clearing anything.

Dunno if I am explaining it very well but if I am checking for a keypress every second say then I need to clear all the byte 3's down to zero after the test

You should be scanning your list of hotkeys regularly, and clearing them down. If your program is going through phases where you only want to look at one key at a time you could conceivably do it by clearing byte 3 for those keys ABOUT to become 'valid', but obviously it would be easier to have a little procedure which checks all of them, and clears all of them, on each cycle whether you then act on them al or not.

Take care only to clear Byte 3 on those entries you are using. These may not be contiguous of course. Other programs may have come and gone and occupied some of the slots.

Regards

Pete

Link to comment
Share on other sites

Thanks Pete

but obviously it would be easier to have a little procedure which checks all of them, and clears all of them, on each cycle whether you then act on them al or not.

That is what I am doing - checking them and then clearing them on a regular cycle.

Take care only to clear Byte 3 on those entries you are using. These may not be contiguous of course. Other programs may have come and gone and occupied some of the slots

Yep - been there made that mistake :oops: in normal closure my program cleans up the hot key entries it creates. Presumably since FSUIPC does no clearing itself any program which ends abnormally will leave it's key assignments in the table?

Link to comment
Share on other sites

Presumably since FSUIPC does no clearing itself any program which ends abnormally will leave it's key assignments in the table?

Yes. In some of the facilities I do insist on a refresh every so many seconds, else there's automatic clearance, but this is a bit awkward with so many possible entries all with probably different last-written times. It's never really posed a problem. After all, if several applications want the same keystroke, they will all get it, as it says, so the only possible harm done is if the table became full. Not happened yet (touches wood, crosses fingers! :wink: ).

Generally if things around FS crash untidily it is often a good idea to restart FS too. There may be other things not quite right else. I can't watch everything! :)

Regards,

Pete

Link to comment
Share on other sites

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
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use. Guidelines Privacy Policy We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.