Howto:Reassign keyboard bindings

From FlightGear wiki
Revision as of 15:46, 4 April 2014 by Philosopher (talk | contribs) (Created page with "{{Stub}} A common request is how to change keys to do different commands. FlightGear makes this as easy as editing an XML file, and possibly adding a parameter to point FG to...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search
This article is a stub. You can help the wiki by expanding it.

A common request is how to change keys to do different commands. FlightGear makes this as easy as editing an XML file, and possibly adding a parameter to point FG to the new XML file.

In general, the list of keyboard commands is stored in the property tree and is loaded at startup or when the menu option "Debug -> Reload input" is selected. The main list of commands is available in [1], but each aircraft can add/change its own bindings through its -set.xml file, and additional config files can do the same.

Adding bindings

Finding keycodes

As mentioned in keyboard.xml, "regular keycodes go up to 255; special keys start at 256, and can be calculated by adding 256 to the GLUT key value in glut.h."

For printable/ASCII keys (e.g. any letter of the alphabet, number, or symbol found on a keyboard), this is simply the ASCII value of the key. xlate is a simple tool that can convert from a letter to appropriate number: enter the letter in [TEXT], click convert, and look at the [ASCII DEC / CHAR] box for the result. And alternative would be to use Nasal (in the Nasal Console or REPL), with a simple script like this that will "pop up" the result:

gui.popupTip(`a`); # replace with the key you want to test

No matter what method you use, for "a" (lowercase), you should get 97; "A" (uppercase) is 67; "0" would be 48.

For non-printable characters, the simplest option is to look for the specific key (or control key) in keyboard.xml. For example, Ctrl+N is found on line 154, which reads:

<key n="14">
  <name>Ctrl-N</name>
  ...
</key>

Thus the key is found at index 14.

If the key isn't listed in keyboard.xml, the last option is to look in glut.h, which is a pretty common file, and one online...