Jump to content
The simFlight Network Forums

A Key "holding" program


Recommended Posts

Afer about 10 years of simming, I've finally gotten into the "cockpit-building" stage! Previous expenses now seem trivial! At any rate....

In button programming, FSUIPC permits numerous "actions" including holding a key down until the button is released. I would dearly love to see the same capability with the key programming, if possible.

I built a switch panel and have been able to vary some of the switching requirements from plane to plane, using "aircraft specific" checkbox in FSUIPC. For starting various planes, I need more switches with the capability of "holding" the keypress. If I were pressing a button instead of pushing a key (which is what the switches actually do - the switches are run through a keyboard encoder from Hagstrom Electronics) I'd have it made, but...

Is there any possibility for the future of having "actions" available for keypresses as well as for buttons?

I must add, without FSUIPC, what I've done so far would work, but not nearly as well. The ability of (a) the aircraft specific checkbox is awesome and (b) the ability to make two (or three) things happen with a single keypress has really expanded my options - and my imagination!

Art Burke

Leesburg, FL, USA

Link to comment
Share on other sites

In button programming, FSUIPC permits numerous "actions" including holding a key down until the button is released. I would dearly love to see the same capability with the key programming, if possible.

I'm sorry, I am completely lost. Keys are keys. Why would you want to program a key from a key? All FSUIPC is doing is trapping the WM_KEYDOWN and WM_KEYUP messages and using them to issue an FS Control. Are you saying it should be able to take a WM_KEYDOWN and convert it to another KEY for some reason? And then discard the WM_KEYUP, so the Key stays pressed all the time? That will mess up things for sure.

If I were pressing a button instead of pushing a key (which is what the switches actually do - the switches are run through a keyboard encoder from Hagstrom Electronics) I'd have it made

But surely the encoder can allow a key to be held -- doesn't it simulate a keyboard as far as the PC is concerned? It must be providing Key Down indications when a key is pressed and Key Up when released?

Is there any possibility for the future of having "actions" available for keypresses as well as for buttons?

I'm really confused about what you hope to occur here. FSUIPC sees keyboard actions -- keys being pressed, released, repeated, whatever. That's all. I provide the facility for actions to occur on the press (which the keyboard system in windows can repeat) and on the release. What else can I do? Can you explain more? Is this some problem with the encoder rather than the way FSUIPC is seeing things?

Regards,

Pete

Link to comment
Share on other sites

I'm sorry, I am completely lost. Keys are keys. Why would you want to program a key from a key? All FSUIPC is doing is trapping the WM_KEYDOWN and WM_KEYUP messages and using them to issue an FS Control. Are you saying it should be able to take a WM_KEYDOWN and convert it to another KEY for some reason? And then discard the WM_KEYUP, so the Key stays pressed all the time? That will mess up things for sure.

Okay, my apologies. I was afraid of providing too much detail and erroneously provided insufficient detail instead!

I built the switch panel using the keyboard encoder. To "start" the engines, I set those two switches (left and right engine for the DC-3) to be "held" in my configuration file. That actually takes place by telling it to "repeat" as long as it's in the ON state. However, when I fly the C-130, there are four instead of two engines. I would like to use a couple of other switches that are not used in the C-130 (specifically, the electric fuel pumps) as starters for the other two engines. However, I can't tell the keyboard encoder to "hold" those keys as they are generally either ON or OFF only.

My temporary workaround is to have FSUIPC start the right side engines with one starter and the left side engines with the other starter.

As a further example: The switch I use for Propeller De-Ice is TAB + PageUp to toggle it on and TAB + PageDn to toggle it off. Then, in FSUIPC, I put some codes in "aircraft specific" for those same keys to (a) arm the Auto-Throttle (in the BAC 1-11) and (b) turn on IAS Hold. This allows me to use the switch for Prop De-Ice in the DC-3, but use it for IAS Hold in the BAC. Does that make sense?

However, since I can't (at least not in the practical sense) program in a "holding sequence" for different aircraft, using my keyboard encoder, I was hoping to find a way to "fake" the "held key" in FSUIPC so I could assign other keys as starters when flying the C-130 or whatever.

If I were using some kind of cannabalized joystick, i.e., something FSUIPC recognizes with *buttons* I could get the job done with conditional programming in the buttons section.

Technically speaking, I *could* use the switch panel for more than one plane, with all kinds of different coding, but that would require loading different configurations for each differing plane. Thanks to my beloved Windoze XP Operating System (can you smell the sarcasm from there?) I can't load the config file through the keyport - it has to be via the serial port. Guess I just need a switchbox and little quickie program that sees what plane I'm going to fly.....

Did that make a little more sense? Thanks for your patience and indulgence. If you hadn't made such a great utility I wouldn't have the opportunity to challenge your thinking!

I think I'm on the verge of buying a bunch of GoFlight modules and the programming capability of those devices may eventually render my quest moot. For the moment, I'm having fun with the DIY concept.

Art

Link to comment
Share on other sites

To "start" the engines, I set those two switches (left and right engine for the DC-3) to be "held" in my configuration file. That actually takes place by telling it to "repeat" as long as it's in the ON state. However, when I fly the C-130, there are four instead of two engines. I would like to use a couple of other switches that are not used in the C-130 (specifically, the electric fuel pumps) as starters for the other two engines. However, I can't tell the keyboard encoder to "hold" those keys as they are generally either ON or OFF only.

So this is not a deficiency in the encoder, just in the way you've programmed those two switches?

However, since I can't (at least not in the practical sense) program in a "holding sequence" for different aircraft, using my keyboard encoder, I was hoping to find a way to "fake" the "held key" in FSUIPC

Er, I'm still not clear. The holding down and repeating of a key would need to be in code effectively preceding FSUIPC's conversion of the keypress to an FS control. It's a really messy operation dealing with WM_KEYDOWN and WM_KEYUP messages, or discarding those it does see.

For instance it would mean discarding all the WM_KEYUP messages associated with this particular key combination, thus inducing stuck keys. This is normally very bad news.

Then what happens to generate the repeats? Is it the encoder that generates the repeats, like a real keyboard controller, or is it relying on some BIOS or Windows action? Without the repeats the holding down probably isn't of much use.

And, most importantly, what sort of signal would there be to make it release? What if that were missed? When it did occur, they partucular KEYDOWN/KEYUPs associated with that signal would have to be discarded, and all the originally discarded KEYUPs for the original signal regenerated. Really ugh!

Or are you thinking that FSUIPC should take and allow all the Key messages as normal, but from that starting signal start a sequence of controls repeating over and over till some other key sequence arrives? Or it is always the same key sequence again?

That might be less dangerous, but it's still a lot of messy programming.

Can't you think of a solution the other way round. Make the encoder do the hardest bit -- i.e. program those two keys to do the holding and repeating, then adapt things to still work in the case where you want simple Ons and Offs? Or am I still missing something?

Regards,

Pete

Link to comment
Share on other sites

Pete, you may not still have it perfectly, but you have the gist of it. I may still have not done a very good job of explaining, but I think you're definitely on the right track!

Yes, the "responsibility" of the encoder is to handle the "holding" (in this case I'm creating the "holding" effect by repeating the keystroke). Again, if I were pushing joystick (either real, pseudo or faking a button!) buttons, the programming you've provided for buttons would do everything I want to do. However...

I'm experimenting now with loading separate configuration files for the encoder, dependent on what plane I want to fly. That means I can't change planes at whim, but that's certainly not the end of the world. With the approach, I can do exactly as you suggest and handle just about everything from the encoder programming. Again, FSUIPC *still* bails me out (thank you very much!) by being aircraft specific. In a worst case, I can have differing entries for everything in my hangar, if need be.

I've learned more from the dialog and have a couple of potential ideas. With the GoFlight modules (thank heavens I don't need the throttle quadrant - there appear to be some difficulties there) I think I can ultimately solve just about all my cockpit needs (with the assistance of FSUIPC!).

After I win the lottery I'm going to build one of those monstrous cockpit thingies with five big-screen TVs - then I'll get to use even more of your modules!

Thanks for the feedback and assistance. Keep up the good work.

Art

Link to comment
Share on other sites

if I were pushing joystick (either real, pseudo or faking a button!) buttons, the programming you've provided for buttons would do everything I want to do.

Yes, but some of that was to enable things to be done with buttons that otherwise could only be done with keystrokes -- the "repeat" facility in particular, which I think must be the one you are concerned with. I never needed to implement "repeat" for keyboards because they do anyway. Buttons don't.

the GoFlight modules (thank heavens I don't need the throttle quadrant - there appear to be some difficulties there)

I think they will be solvable. Something to do with jitter and multiple inputs wrecking my fast/slow timing.

Regards,

Pete

Link to comment
Share on other sites

Yes, but some of that was to enable things to be done with buttons that otherwise could only be done with keystrokes -- the "repeat" facility in particular, which I think must be the one you are concerned with. I never needed to implement "repeat" for keyboards because they do anyway. Buttons don't.

Well, the place where I was hung up was on starters. You can hold the mouse against the starter switch until the engine winds up and fuel flow begins. A simple "toggle" doesn't work - the key must be held down or repeated with some kind of command. I was hoping your programming would give me a way to do that on the fly - thereby allowing me to institute "changes" dependent on a specific aircraft.

My attempt to create a second (different) configuration file specifically for that four-engined monster was successful. Unfortunately, the attempt at a batch file wasn't! Since it doesn't occur very often, I guess it isn't too problematic to just process the file(s) normally, since the options available for the DC-3 work with just about any other twin-engined craft.

One last question - is the chip(s) that makes a joystick "do its thing" something easily purchased and wired? I cannabalized a couple of joysticks. One of them wasn't too trivial a task, but the other one was. What chip(s) is the "heart" of the joystick system? If that's an easy question to answer, please do. If it starts getting complex, either steer me in an appropriate direction, if possible, or just smile and I'll go away!

Art

Link to comment
Share on other sites

Well, the place where I was hung up was on starters. You can hold the mouse against the starter switch until the engine winds up and fuel flow begins. A simple "toggle" doesn't work - the key must be held down or repeated with some kind of command. I was hoping your programming would give me a way to do that on the fly

Yes, it does. I had to add special programming to make the repetitiion happen whilst a button is held down, but key presses repeat automatically when held down, so I don't need to do anything there.

Are you now saying that you cannot make the keypress repeat when held down? I thought this was a programmable function of a Hagstrom keyboard encoder? Or is this getting all confused again? :(

One last question - is the chip(s) that makes a joystick "do its thing" something easily purchased and wired? I cannabalized a couple of joysticks. One of them wasn't too trivial a task, but the other one was. What chip(s) is the "heart" of the joystick system?

I've no idea, sorry. I wouldn't have thought they'd all be the same in any case.

With the old Game Port type connection I think the AtoD conversion is in the Game Port itself, so all you need to do is connect a 100K pot across the appropriate connections. But the method it uses is crude and slow -- timing the discharge of a capacitor through the pot.

Modern "digital" joysticks, connecting via USB, may do the same internally, but at least that saves the processor in the PC doing it.

Many better quality ones probably use other methods -- proper voltage AtoD chips, or optical like the ball-free mouse.

I once had a FlightLink/EPIC throttle quadrant which had plastic discs marked with fine rulings connected on the lever axes, and these went through the gap in a standard optical chip. The driver presumably counted the number of markings going past. There was some way of detecting the direction too, but I can't remember how that worked now -- probably two separate optical beams in the gap.

Regards,

Pete

Link to comment
Share on other sites

Are you now saying that you cannot make the keypress repeat when held down? I thought this was a programmable function of a Hagstrom keyboard encoder? Or is this getting all confused again? :(

Yes and No! I built my switch panel to use with the DC-3 - twin engines obviously. The switches designated for the two starters have the "hold down" commands in the config file. Next to those switches are two other switches used to turn on the fuel boosters (one for each engine). When I fly the C-130, there aren't any fuel boosters, so I thought I would use these keys as starters also, but, and here's the rub, it takes a separate, new configuration to make those keys "held" as well. Otherwise, they will never get the engines started. C'est la vie. I was *hoping* to be able to use FSUIPC to act as sort of an "add-on" config and let me "hold" those keys when flying a specific aircraft. Obviously, that can't be done without some exhaustive programming (your or mine!). Loading a different config file isn't all that bad and that's what I did last night.

FSUIPC *was* able to solve part of the problem for me anyway. I just added a line to the code used for starters (and something similar for the generators) in the .ini file. Then, when I started engine number 1, the next line issued the same key structure, but an FS Control command to start engine number 2 at the same time. Obviously, then, the same thing for the engines on the right side. That worked, but I wanted to make it look really nifty and have a starter control and generator/alternator switch for *each* engine. (When we play at this we sometimes play hard huh?) What the hey. The different configuration file works like I/we hoped it would.

At least with our dialog, I learned a couple of new things. Thanks and have a good weekend.

Art

Link to comment
Share on other sites

One last question - is the chip(s) that makes a joystick "do its thing" something easily purchased and wired? I cannabalized a couple of joysticks. One of them wasn't too trivial a task, but the other one was. What chip(s) is the "heart" of the joystick system? If that's an easy question to answer, please do. If it starts getting complex, either steer me in an appropriate direction, if possible, or just smile and I'll go away!

Art

May I suggest you go to http://www.betainnovations.com and look at the section for the "Plasma MiniMe"? All the schematics, parts list, Hex code for the PIC etc, to build a control board for a 5-axis/12-button/1-HAT USB controller for less than $10.

Richard

Link to comment
Share on other sites

May I suggest you go to http://www.betainnovations.com and look at the section for the "Plasma MiniMe"? All the schematics, parts list, Hex code for the PIC etc, to build a control board for a 5-axis/12-button/1-HAT USB controller for less than $10.

Richard

Thanks Richard. I've bookmarked that reference and will check it out. I appreciate the info.

Art

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.