Input device: Difference between revisions

Jump to navigation Jump to search
Make the "beginner" section more geared towards a quick setup of common input devices.
(Short intro on "buying a joystick or yoke?")
(Make the "beginner" section more geared towards a quick setup of common input devices.)
Line 1: Line 1:
Could you imagine a pilot in his or her [[:Category:Cessna|Cessna]] controlling the machine with a keyboard alone? For getting the proper feeling of flight you will need a '''joystick/yoke''' plus [[rudder]] pedals, right? However, the combination of numerous types of joysticks, flightsticks, yokes, pedals and several target operating systems, makes joystick support a nontrivial task in [[FlightGear]].
Could you imagine a pilot in his or her [[:Category:Cessna|Cessna]] controlling the machine with a keyboard alone? For getting the proper feeling of flight you will need a '''joystick/yoke''' plus [[rudder]] pedals, right?  


FlightGear has integrated joystick support, which automatically detects any joystick, yoke, or pedals attached. Just try it! If this does work for you, lean back and be happy! You can see what FlightGear has detected your joystick as in the Help > Joystick Information dialog from the [[menu]].  
FlightGear has integrated joystick support, which automatically detects any joystick, yoke, or pedals attached. Just try it! If this does work for you, lean back and be happy! You can see what FlightGear has detected your joystick as in the Help > Joystick Information dialog from the [[menu]].  


Unfortunately, for the above mentioned versatility, chances are your joystick does not work out of the box. Basically, there are two alternative approaches to get it going, with the first one being preferred.
Unfortunately, for the above mentioned versatility, chances are your joystick does not work out of the box. This article explains you how to make FlightGear recognise your device


== Joystick or yoke? ==
== Joystick or yoke? ==
Line 52: Line 52:


== Built-in joystick support ==
== Built-in joystick support ==
In order for joystick auto-detection to work, a joystick bindings xml file must exist for each joystick. This file describes what axes and buttons are to be used to control which functions in FlightGear. The associations between functions and axes or buttons are called "bindings".


=== General remarks ===
FlightGear includes a large number of such bindings files for a variety of manufacturers. Chances are high that your joystick will be recognised straight away, so let's try that first. You can confirm whether it was recognised by looking in the <tt>Help > Joystick Information</tt> dialog. "Used for" should contain a name/description of your joystick. It will contain "default" when FlightGear did not recognise your joystick.
In order for joystick auto-detection to work, a joystick bindings xml file must exist for each joystick. This file describes what axes and buttons are to be used to control which functions in FlightGear. The associations between functions and axes or buttons are called “bindings”. This bindings file can have any name as long as a corresponding entry exists in the joysticks description file <tt>[[$FG_ROOT]]/joysticks.xml</tt>, which tells FlightGear where to look for all the bindings files. We will look at examples later.  


FlightGear includes several such bindings files for several joystick manufacturers in folders named for each manufacturer. For example, if you have a CH Products joystick, look in the folder <tt>[[$FG_ROOT]]/Input/Joysticks/CH</tt> for a file that might work for your joystick. If such a file exists and your joystick is working with other applications, then it should work with FlightGear the first time you run it. The latest config files are always to be found at https://gitorious.org/fg/fgdata/trees/master/Input/Joysticks.
Most of the time when your joystick is not recognised, it is because of a missing name definition in the respective bindings file. Because FlightGear is used on all kind of operating systems, names vary a lot. You can find the files under <tt>[[$FG_ROOT]]/Input/Joysticks/</tt> (despite the name, yokes and pedals are also found here!). For example, if you have a CH Products joystick, look in the folder <tt>[[$FG_ROOT]]/Input/Joysticks/CH</tt> for a file that might work for your joystick. When such a file exists, do the following:
# Launch FlightGear with the joystick connected.
# Look under Help > Joystick Information and check the name behind "Joystick #0:".
# Open your joystick's bindings file in a XML editor and add the following code to the file, below the already-present <code><name></code> tags.
#:<pre><name>The EXACT name you found under step 2; including spaces, capitals etc.</name></pre>
# Please report this name [http://www.flightgear.org/forums/viewforum.php?f=24 at our forum], so it can be added to the official file (and next releases).


If such a file does not exist, you will have to create such a file. We will discuss that in [[Joystick#Writing or editing joystick binding xml files|a later section]], by cutting and pasting bindings from the examples that are included with FlightGear.
Please note that the latest config files are always to be found at https://gitorious.org/fg/fgdata/trees/master/Input/Joysticks. This link may contain additional binding files that were not included in the latest stable release.


If there is no file for your joystick, you will have to create such a file. We will discuss that in [[Joystick#Writing or editing joystick binding xml files|a later section]], by cutting and pasting bindings from the examples that are included with FlightGear.
=== Multiple devices on Windows ===
In case you have two USB devices (for instance a yoke plus pedals) to a Windows computer, there may be cases, where the same driver name is reported twice. In this case, you can get at least the yoke to work by assigning it number 0 (out of 0 and 1), by adding a line to <tt>[[$FG_ROOT]]/joystick.xml</tt> like:
<js n="0" include="Input/Joysticks/Saitek/ST290-Pro.xml"/>
if you also have pedals (or another joystick), just add more lines, similar to:
<js n="1" include="Input/Joysticks/Saitek/Pro-Flight-Rudder-Pedals.xml"/>
To make sure that the first input device is indeed the yoke, rotate the yoke ([[aileron]] control) and observe the Help > Joystick Information dialog. If the aileron value does not change, you have to make the yoke the preferred device first. For doing so, enter the Windows "Control panel", open "Game controllers" and select the "Advanced" button. Here you can select the yoke as the "Preferred" device. Afterwards you can check that assignment by restarting FlightGear. The yoke should now control the aileron.
== Adding support for your joystick ==
=== Verifying your joystick is working ===
=== Verifying your joystick is working ===
==== Linux ====
==== Linux ====
Line 225: Line 241:


You can tell how FlightGear has interpretted your joystick setup by selecting <tt>Help > Joystick Information</tt> from the menu.
You can tell how FlightGear has interpretted your joystick setup by selecting <tt>Help > Joystick Information</tt> from the menu.
=== Some hints for Windows users ===
Basically, the procedures described above should work for Windows as well. If your joystick/yoke/pedals work out of the box or if you get it to work using the methods above, fine. Unfortunately there may be a few problems.
The first one concerns users of non-US Windows versions. As stated above, you can get the name of the joystick from the program js demo. If you have a non-US version of Windows and the joystick .xml files named above do not contain that special name, just add it on top of the appropriate file in the style of:
<name>Microsoft-PC-Joysticktreiber</name>
No new entry in the base joysticks.xml file is required.
Unfortunately, there is one more loophole with Windows joystick support. In case you have two USB devices attached (for instance a yoke plus pedals), there may be cases, where the same driver name is reported twice. In this case, you can get at least the yoke to work by assigning it number 0 (out of 0 and 1), add a line to <tt>[[$FG_ROOT]]/joystick.xml</tt> like:
<js n="0" include="Input/Joysticks/Saitek/ST290-Pro.xml"/>
if you also have pedals (or another joystick), just add more lines, similar to:
<js n="1" include="Input/Joysticks/Saitek/Pro-Flight-Rudder-Pedals.xml"/>
For this purpose, rotate the yoke ([[aileron]] control) and observe the output of js demo. If figures in the first group of colons (for device 0) change, assignment is correct. If figures in the second group of colons (for device 1) change, you have to make the yoke the preferred device first. For doing so, enter the Windows “Control panel”, open “Game controllers” and select the “Advanced” button. Here you can select the yoke as the “Preferred” device. Afterward you can check that assignment by running js demo again. The yoke should now control the first group of figures.


== Joystick support via .fgfsrc entries ==
== Joystick support via .fgfsrc entries ==

Navigation menu