Jump to content
The simFlight Network Forums

Can I map ALT key to button?


Recommended Posts

I'd like to tack on another question here, hope you don't mind too much.

I'm using an old Saitek P8000, which is pad a with a hat and 37 buttons. FSUIPC only sees the first 32 buttons. Is there any way to get it to see the other five?

Thanks again.

Link to comment
Share on other sites

For your first question:

open editor or WordPad or anything else and insert this line into:

ipc.keypressplus(18,1,4) -- ALT and focus to FS

save this as ALTKey.LUA into your modules folder.

Start FS and go into FSUIPC menu choose a button and choose from pull down "LUA ALTKey".

Should work.

note: I talk for FSX I don't know how that works with FS9, but I think it should (Pete?)

Link to comment
Share on other sites

note: I talk for FSX I don't know how that works with FS9, but I think it should (Pete?)

Yes. Same for both.

On the other question:

I'm using an old Saitek P8000, which is pad a with a hat and 37 buttons. FSUIPC only sees the first 32 buttons. Is there any way to get it to see the other five?

Sorry, no. FSUIPC uses the old, simple, more efficient "joy" API into Windows, which only supports 32 buttons per joystick.

Regards

Pete

Link to comment
Share on other sites

Thanks for the replies.

I am running FSX; but the lua file did not work for me. I created the file, and was able to assign the alt lua to a button - but in FSX nothing happens. Is there any other way of doing this; or maybe I'm doing something wrong?

I'd also like to map the "ESC" key to a button so I can "end flight" - is this possible?

Link to comment
Share on other sites

I am running FSX; but the lua file did not work for me. I created the file, and was able to assign the alt lua to a button - but in FSX nothing happens. Is there any other way of doing this; or maybe I'm doing something wrong?

Please try things in FSX using the keyboard. You will find that pressing ALT alone does not bring up a specific menu, you then have to either press another button to select the specific menu, or TAB to it and press Enter. I'm not sure how you intended to use ALT alone?

Note that the "ipc.keypressplus" line with (18,1,4) parameters presses the ALT key but doesn't release it. You really need another keypressplus line after it to select the menu, and a further line to release the ALT key. Or you can just have one line pressing and releasing a specific ALT+letter combination.

For a specific menu, have you tried simply assigning a button to ALT+? That should work, but then you would still need a Lua plug-in to send further keys, as once you are in a menu FSUIPC cannot do much. FS's menus are modal (they take over).

Maybe if you describe how you intend to use whatever menu it is from joystick buttons after you have it displayed, we could be more helpful. Unless you use only buttons I don't see the point -- using a button to bring up a menu and then having to use the keyboard seems to completely defeat the object, doesn't it?

I'd also like to map the "ESC" key to a button so I can "end flight" - is this possible?

Yes, either the same way but using the ESC keycode, or by assigning the button to something else first, like "a", then editing the FSUIPC4.INI file entry that generates to show 27 (the ESCape keycode) instead of 65 (the "a" keycode).

But there's really no good reason to assign buttons to keystrokes which are assigned to FS controls -- you should assign the button to the FS control in the first place. Then the keyboard is irrelevant. To end a flight you use the "User interrupt" control. You can find the proper name for any FS control, whether assigned to button or key, by enabling FSUIPC's Event logging, using the control, and looking in the FSUIPC4.LOG file (which you'll find in the Modules folder).

BTW for further reference, Keycodes and shiftcodes are listed in the FSUIPC4 advanced user's document. Look in the Button programming section. And the Lua facilities in FSUIPC are detailed in the two Lua documents. All the FSUIPC documentation you need is stored in your FSX Modules folder.

Regards

Pete

Link to comment
Share on other sites

Thanks for all the suggestions, I'm sure the answer is in there. I'll give it all a go (I'd forgotten about using the logging).

"Please try things in FSX using the keyboard. You will find that pressing ALT alone does not bring up a specific menu, you then have to either press another button to select the specific menu, or TAB to it and press Enter. I'm not sure how you intended to use ALT alone?"

For me in FSX, the ALT key brings up the menu "bar". This is all I'm trying to achieve, I don't want to replicate a specific function. I can the use the mouse to select the menu I want. Holding down the ALT key, then makes the menu go away.

Link to comment
Share on other sites

For me in FSX, the ALT key brings up the menu "bar". This is all I'm trying to achieve, I don't want to replicate a specific function. I can the use the mouse to select the menu I want. Holding down the ALT key, then makes the menu go away.

Hmm.

Getting the menu bar up is easy. (Incidentally, I just noticed why that original Lua example didn't work correctly. The parameters should be either (18,8) or (0,24) for a press-and-release. (18,8) is the ALT virtual keycode, and 8 means "normal", whilst (0,24) says no keycode but with ALT pressed. Both end up sending the same thing, but the latter is more "proper" as it will also set the "system key" flag in the Windows message.

In both cases you can add a third parameter, "1" to "press" only (instead of "press and release", and "2" to release.

Even though, therefore, we can simulate holding the ALT key down for a second, or whatever, getting the menu to disappear is tricky. I'm not sure that's possible from a button. It looks like FSX reads the keyboard directly for that function. Sending a Press for ALT then a release a second or so later doesn't help.

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.