Board index FlightGear Support Hardware

Binding new functions to keys

Joysticks, pedals, monitors.

Binding new functions to keys

Postby c_meister » Wed Aug 09, 2017 1:59 am

Hello all,

first post and I hope the answer hasn't been posted somewhere already. Have been browsing the forums and searching the web for quite some hours without result.

I'm trying to build a simple home cockpit, and the next step is to make a set of switches for the battery, alternator, lights, magnetos, etc. The hardware I'm planning to use is a disassembled keyboard between the physical switches and the computer, so all I need is to connect the switches to the correct keys. On FSX forums I've found the plans to make it work electrically, but trying to find the key bindings to use on the instrument panel it seems that quite a number of functions seem to have no keyboard shortcut defined and as far as I know one has to flick the switches using the mouse in the virtual cockpit. I bet the properties exist and can be accessed by keyboard, but where are these listed? The internal properties list does seem to have pretty much everything listed, but which command do I use in keyboard.xml to say toggle the pitot heat? If at all possible?

I hope I made it more or less clear what the issue is here. Hope you can help.

Norm
c_meister
 
Posts: 3
Joined: Wed Aug 09, 2017 1:40 am

Re: Binding new functions to keys

Postby Thorsten » Wed Aug 09, 2017 6:04 am

but trying to find the key bindings to use on the instrument panel it seems that quite a number of functions seem to have no keyboard shortcut defined and as far as I know one has to flick the switches using the mouse in the virtual cockpit


Conceptually key events and simulation events are completely disconnected and while there are some defaults, it's up to the aircraft config to define the relationship, this isn't done FG-side.

Makes sense, because there's far more possible simulation events than keys - while a Space Shuttle has no need for a pitot heater, it does have need for attitude reference or BFS takeover pushbuttons - which other planes do not need.

Also, key bindings may not be properties at all, they may be Nasal functions.

So you need to study the particular plane you'd like to fly and change it's key bindings to what you need.
Thorsten
 
Posts: 12490
Joined: Mon Nov 02, 2009 9:33 am

Re: Binding new functions to keys

Postby c_meister » Wed Aug 09, 2017 11:31 am

Thank you, I think I've found where to look. As a first step to see whether I'm on the right track let's say I want to edit the default Cessna 172 and use the letter 'q' to toggle the Lighting Beacon On/Off. I think the \systems\als-lights.xml and c172p-keyboard.xml are the files I should be looking at.

I added the following guessing that 'q' isn't used for anything as I didn't find it in the keyboard binding lists and guessed what would have to be put in the <binding> section.

Code: Select all
   <key n="113">
        <name>q</name>
        <desc>Lighting Strobe On/Off</desc>
        <binding>
            <command>property-assign</command>
            <property>/sim/model/c172p/lighting/strobes/enabled</property>
        </binding>
    </key>


Apparently this doesn't work, so maybe someone can give a pointer about the logic of the code so I can get this to work. So do I have the keyboard binding 'point' at the <logic> somewhere? And how?

Is this bit in \systems\als-lights.xml what I should be looking at?

Code: Select all
 <logic>
        <name>Lighting Beacon On/Off</name>
        <input>
            <and>
                <less-than>
                    <property>/systems/electrical/outputs/beacon</property>
                    <value>31.5</value>
                </less-than>
                <greater-than>
                    <property>/systems/electrical/outputs/beacon</property>
                    <value>20.0</value>
                </greater-than>
            </and>
        </input>
        <output>
            <property>/sim/model/c172p/lighting/beacon/enabled</property>
        </output>
    </logic>


Thank again.

Norm
c_meister
 
Posts: 3
Joined: Wed Aug 09, 2017 1:40 am

Re: Binding new functions to keys

Postby Thorsten » Wed Aug 09, 2017 1:14 pm

Apparently this doesn't work,


You didn't specify the value to assign, that's all. I'm not sure there's documentation, but the existing examples should be self-explanatory.
Thorsten
 
Posts: 12490
Joined: Mon Nov 02, 2009 9:33 am

Re: Binding new functions to keys

Postby c_meister » Wed Aug 09, 2017 4:36 pm

Got it to work with the following:

Code: Select all
   <key n="113">
        <name>q</name>
        <desc>Lighting Strobe On/Off</desc>
        <binding>
          <command>property-toggle</command>
         <property>/controls/lighting/strobe</property>
        </binding>
    </key>


Thank you for the help!
c_meister
 
Posts: 3
Joined: Wed Aug 09, 2017 1:40 am

Re: Binding new functions to keys

Postby wlbragg » Wed Aug 09, 2017 4:52 pm

Just know all isn't straight forward, your key code is fine. The trick is finding the correct property to excite.

Your original choice is the electrical supply to the beacon system.

The on/off switch is controls/lighting/beacon

However the Beacon isn't straight forward as it is also controlled by an alias to get the flashing.
property alias="/params/lighting/beacon"

The alias is a reference to a new aircraft light
Code: Select all
var lighting_beacon_enabled = rplayer.getNode("sim/multiplay/generic/int[12]").getPath();
var lighting_beacon_state = rplayer.getNode("sim/model/c172p/lighting/beacon").getPath();
aircraft.light.new(lighting_beacon_state, [0.10, 0.90], lighting_beacon_enabled);
<params>
        <lighting>
            <beacon>sim/model/c172p/lighting/beacon/state</beacon>
Kansas and Ohio/Midwest scenery development.
KEQA, 3AU, KRCP Airport Layout
Intel i7/GeForce RTX 2070/Max-Q
User avatar
wlbragg
 
Posts: 7587
Joined: Sun Aug 26, 2012 12:31 am
Location: Kansas (Tornado Alley), USA
Callsign: WC2020
Version: next
OS: Win10/Linux/RTX 2070


Return to Hardware

Who is online

Users browsing this forum: No registered users and 8 guests