C++ Question Creating New Keystroke Shortcuts for Addons

soundmackdaddy

New member
Joined
Dec 9, 2008
Messages
15
Reaction score
0
Points
0
hey,

I have been entertaining the idea of building an orbiter simpit for some time and I has decided that one of the easiest ways of interfacing switches etc is through a keyboard encoder that responds to particular keyboard shortcuts.

While this would currently work fine for many common functions (eg: landing gear etc.), however I was wondering how this could be done for other addons, for all the switches in the DeltaGlider IV or the NASSP Apollo CM. I figured this could probably done by either directly modifying the C++ code of the vessel or by creating a plugin that could do the job, however I dont have that much programming experience (but willing to learn).

Is this possible? If so, how could this be done? - I have had a look at all the SDK and API reference stuff but I cant seem to work out the syntax for adding in keyboard shortcuts to the code and where it would be added.

Many thanks for your help,

Kristian
 
If you want to add keyboard shortcuts for a vessel I think it would be best done in the vessel code because I don't think it would be very easy (if at all possible) for a plugin to activate switch XYZ in a virtual cockpit or 2d panel, for example. In that case, you are out of luck for the DGIV but in luck with NASSP since it is open source. You'll want to look at the functions VESSEL2::clbkConsumeBufferedKey and VESSEL2::clbkConsumeDirectKey.
 
You can find more info in the Simpit sub-forum http://orbiter-forum.com/forumdisplay.php?f=67 or the Orbiterwiki http://www.orbiterwiki.org/wiki/Orbiter_cockpits

You can do a lot with a keyboard encoder, but I think it would be very difficult to do everything with the keyboard because between Orbiter and vessels there are more potential commands than keychords. With a macro program like Autohotkey you could assign key combinations to commands, including mouse commands - but what it was doing would be apparent on screen. For example to click a button on the lower panel that did not have a key assigned, you would have to program a macro to ctrl-down to view the lower panel, send a mouse click command to the correct point on the screen, and then send a ctrl-up to return to the main window.
 
hmmm yes I have had a look at AutoHotKey but unfortunately ran into a few problems. With NASSP for example there were two key problems. Firstly, whenever I press a specific programmed key combination in AHK there seems to be a slight time delay between pressing the key and orbiter actually registering the click and changing the switch state and this delay never seems to be a consistent time duration. However more importantly I havent been able to get AHK to work for the three-position switches found in the NASSP CM - there is no position on the panel that will just change the switch state to the middle position - the longer you hold the click down for, the switch moves from top-middle then from middle-bottom, and I cannot work out a time duration needed to click that will consistently only move the switch one 'step'. So unless there are advanced commands that can be used in AHK to solve these issues I had figured that (at least for NASSP - it would probably work fine for many other vessels like the DGIV) it did not fully work for these purposes.

In light of this I had thought that the next thing to try would be via the code, but I am open to any other easier (!) suggestions.

With regards to the programming, I have looked at the API reference and the NASSP code - would the clbkConsumeBuffered/Direct Key command just be inserted into some section of the code - is the location important? If so would you have any idea where, because as you can imagine there is a fair bit of code for something like NASSP... I would guess somewhere each inidividual switch is defined? Also just generally with this sort of thing - is it possible/easy to insert these commands in such a way that they can be simply reapplied to the other new code each time NASSP is updated or would they need to manually be copied or retyped?

Many thanks,

Kristian
 
With regards to the programming, I have looked at the API reference and the NASSP code - would the clbkConsumeBuffered/Direct Key command just be inserted into some section of the code - is the location important? If so would you have any idea where, because as you can imagine there is a fair bit of code for something like NASSP... I would guess somewhere each inidividual switch is defined?
I'm pretty sure that each class in the NASSP code that is derived from a VESSEL2 class would have those function defined already (or most of those classes, anyway), so start by looking for that. I've never delved into their code, so I can't help you much more than that.

Also just generally with this sort of thing - is it possible/easy to insert these commands in such a way that they can be simply reapplied to the other new code each time NASSP is updated or would they need to manually be copied or retyped?
Hmm, maybe you could come up with some sort of script to do it? Again, that would be strongly dependent on the structure and stability of the sources.

You might get more info if you ask at the Meadville Space Centre forums since that is where most of the Project Apollo guys haunt:
http://www.ibiblio.org/mscorbit/mscforum/
 
thanks very much for all your help, I will have a look at those things you mentioned and maybe have a chat with the NASSP guys about it in further detail.

Thanks again!

Kristian
 
Back
Top