Board index FlightGear Development

Amending to key bindings  Topic is solved

FlightGear is opensource, so you can be the developer. In the need for help on anything? We are here to help you.
Forum rules
Core development is discussed on the official FlightGear-Devel development mailing list.

Bugs can be reported in the bug tracker.

Amending to key bindings

Postby PH-JAKE » Thu May 14, 2020 3:58 pm

Reading up on bindings (key bindings to be specific) there's made reference to adding or reassigning key bindings. If I read this correctly this means:

  • Adding - introducing a new key binding for a key for which a binding did not exist before.
  • Reassigning - replacing a previously introduced key binding, e.g., from keyboard.xml.

But what if I wanted to amend a key binding, so to keep what is in keyboard.xml for these specific keys and add an additional binding to it, from another config file for instance. How do you do that?
PH-JAKE
 
Posts: 156
Joined: Wed Mar 12, 2014 12:53 am
Callsign: PH-JAKE
Version: 2020.3.18
OS: Debian trixie

Re: Amending to key bindings

Postby Necolatis » Thu May 14, 2020 4:19 pm

Just add the binding. Its can have multiple bindings.
"Airplane travel is nature's way of making you look like your passport photo."
— Al Gore
User avatar
Necolatis
 
Posts: 2232
Joined: Mon Oct 29, 2012 1:40 am
Location: EKOD
Callsign: Leto
IRC name: Neco
Version: 2020.3.19
OS: Windows 10

Re: Amending to key bindings

Postby PH-JAKE » Thu May 14, 2020 10:26 pm

Necolatis wrote in Thu May 14, 2020 4:19 pm:Just add the binding. Its can have multiple bindings.


So you're saying that if an additional config file has a key binding for a key with a binding in keyboard.xml, this config file key binding is added to the binding from keyboard.xml.

I'll give that a try, although I don't understand than why it's called "Reassign keyboard bindings", which suggests that the binding is replaced.
PH-JAKE
 
Posts: 156
Joined: Wed Mar 12, 2014 12:53 am
Callsign: PH-JAKE
Version: 2020.3.18
OS: Debian trixie

Re: Amending to key bindings  

Postby Necolatis » Thu May 14, 2020 10:56 pm

You gotta be mindful of the numbering.

Binding 1 will have n="0" , so if you add more bindings in same file they will have n="1" etc etc
But if you add binding in another file they will replace, unless you manually specify n="x"

Here is an exmaple of a binding I did not want to overwrite the walkers binding 0 and 1:

Code: Select all
<binding n="2">
                    <command>nasal</command>
                    <condition>
                            <and>
                            <not-equals>
                                <property>sim/current-view/name</property>
                                <value>Walk View</value>
                            </not-equals>
                            <not-equals>
                                <property>sim/current-view/name</property>
                                <value>Walker Orbit View</value>
                            </not-equals>
                            </and>
                     </condition>
                    <script>pylons.fcs.cycleLoadedWeapon();</script>
                </binding>
"Airplane travel is nature's way of making you look like your passport photo."
— Al Gore
User avatar
Necolatis
 
Posts: 2232
Joined: Mon Oct 29, 2012 1:40 am
Location: EKOD
Callsign: Leto
IRC name: Neco
Version: 2020.3.19
OS: Windows 10

Re: Amending to key bindings

Postby PH-JAKE » Fri May 15, 2020 5:57 pm

Necolatis wrote in Thu May 14, 2020 10:56 pm:You gotta be mindful of the numbering.

Binding 1 will have n="0" , so if you add more bindings in same file they will have n="1" etc etc
But if you add binding in another file they will replace, unless you manually specify n="x"
...


Ah, that makes sense, and that is what I was missing from the Wiki pages.

I applied your knowledge when I took out my additional bindings into a separate XML file, returning the installed keyboard.xml file to its original state, and now it works. And since this also provides ordering in the bindings, I can now take advantage of that fact and maybe reduce my nasal code even more.

It would have been nice if there was an 'auto increment' mechanism to get the next free binding number, so that you would never step on someone else's binding. But I digress.

You have been very helpful,
Thanks.
PH-JAKE
 
Posts: 156
Joined: Wed Mar 12, 2014 12:53 am
Callsign: PH-JAKE
Version: 2020.3.18
OS: Debian trixie


Return to Development

Who is online

Users browsing this forum: No registered users and 6 guests