]> git.mxchange.org Git - flightgear.git/blob - docs-mini/README.Joystick
Reduce spurious output from joystick.cxx
[flightgear.git] / docs-mini / README.Joystick
1 Users Guide to Joystick Usage Under FlightGear Flight Simulator
2 version 0.3 10/06/2000 
3 Author John Check <j4strngs@rockfish.net>
4
5 This document is written with versions of FlightGear 0.7.5 and greater
6 in mind. It assumes a working joystick present on your system. While it
7 is written from the point of view of a Linux user, the cross platform
8 nature of FGFS should ensure the information presented is useful on other
9 platforms. I'd like to say thanks to all the developers who make FGFS happen
10 and forgive me for not giving credit with regard to the property
11 manager and js_demo. Corrections and additions are encouraged.
12 The most current version can be found at http://rockfish.net/shell/aboutjoy.txt
13
14 Some History:
15 Earlier versions of FGFS had assignments of joystick axis/buttons
16 hard coded. If you had a joystick that did not use the default channel
17 assignments, you had to edit the source code and recompile. 
18 Fortunately, around about v0.7.4/0.7.5 a "property manager" was
19 implemented, allowing, among other things, runtime access to some of the FGFS
20 internals, which facilitated being able to set the parameters for the
21 joystick at runtime.
22
23 About runtime options:
24 FGFS has always had a plethora of available runtime options. Starting
25 point, altitude, direction, time of day and other aspects of the
26 simulated environment were always well represented. However there
27 were also a number of options and features that were not well documented.
28 Among these was the ability to use a runtime configuration file (.fgfsrc)
29 to control the default operation. The .fgfsrc file is not created at runtime
30 and must be created manually. Fortunately, the format of the file is
31 straightforward. All one need do is place the commandline options one would
32 like in a plain ASCII text file in the users home directory. System wide
33 defaults can be place in $FG_ROOT/system.fgfsrc.
34
35 With the advent of the property manager it became possible to add a number
36 of additional runtime options to the .fgfsrc file including joystick channel
37 assignments. Basically, anything* that is reported by the property manager
38 can now be tweaked without having to recompile the binary.
39
40 *see mini-doc/properties.txt for exceptions
41
42 Determining your joystick output:
43
44 Included with FlightGear is a utility called js_demo. It will report
45 the number of joysticks attached to a system and their capabilites.
46 By observing the output of js_demo while working our joystick we can
47 determine what controls are where.
48 It should be noted that, at least on UNIX, numbering generally starts with
49 zero. In the following example the system has 1 joystick (js0) connected.
50 The output shown is from an analog Gravis BlackHawk with four buttons and
51 a throttle. 
52
53 Typical output of js_demo:
54
55 Joystick test program.
56 ~~~~~~~~~~~~~~~~~~~~~~
57 Joystick 1 not detected
58 Joystick 2 not detected
59 +---------------JS.0-----------------+
60 | Btns Ax:0 Ax:1 Ax:2                |
61 +------------------------------------+
62 | 0000 +0.0 +0.0 -1.0   .    .    .  |              
63
64 It appears that the number of detected buttons is represented by the number of
65 "0"s. Clicking the actual buttons will result in the rightmost 0 changing to
66 the button number output. i.e. pressing button one will change the display to
67 look like this: 0001. It should be noted that this is a hexadecimal (base16)
68 number +1. Hex numbers start at 0, so this number is incremented by one for
69 hopefully obvious reasons. 
70
71
72 Default Joystick properties:
73
74
75 Axis 0   = Aileron
76 Axis 1   = Elevator
77 Axis 2   = Rudder
78 Axis 3   = Throttle
79 Button 0 = All brakes
80 Button 1 = Left brake
81 Button 2 = Right brake
82 Button 3 = Elevator trim (up)
83 Button 4 = Elevator trim (down)
84 Button 5 = Flaps (down)
85 Button 6 = Flaps (up)
86
87
88 In addition to the channel assignments there are other properties
89 for tuning the joystick. These values work together in a particular order.
90 They should always be written as a 'float', or decimal number.
91
92 The full order of precedence for axis properties is
93
94 1. The raw axis value ...
95 2. is adjusted to dead-band, ...
96 3. then adjusted to offset, ...
97 4. then multiplied by factor, which ...
98 5. is assigned to the FlightGear control property.
99
100 Put another way....
101
102         cooked_value = (( raw_value > dead-band ) + offset) * factor
103
104
105 Axis properties:
106
107         dead-band
108
109 -1          0          1
110  .......................
111 -1         | |         1
112             ^
113         dead-band   
114
115
116 This is an area where signals are ignored. It is used to compensate
117 for noise or potentiometers of dubious quality by creating a threshold
118 below which any signal is ignored. 
119
120 The default of 0.1 for elevators and ailerons is very forgiving. A lower 
121 number results in a tighter feel. Throttle defaults to 0.0
122
123  
124         offset
125
126 -1  0                  1
127  .......................
128 -1  ^                  1
129  offset
130
131 Used to maximize a controls use of it's axis, as in the case of a
132 throttle where zero would be a minimum and not a center point like in the case
133 of a rudder. Typical value -1.0. 
134
135
136         factor
137
138 Controls sensitivity of an axis. If the factor is too low it results in
139 control not reaching its maximum possible limit. Negating the number will result in
140 the control moving counter to the default. The default value is 1.0, think unity gain. 
141
142 In my case, throttle behaviour was inverted from what I preferred. 
143 I set this value to -1.0 and everything was groovy.
144
145
146
147 Button properties
148
149         switch
150 A button designated a switch is either on or off. While the button is
151 held in the switch is engaged. Brakes are described as a switch and take
152 additional parameters [ step, repeatable ]
153
154         adjust
155 A button designated adjust is for controls that have a range
156 of settings, for example elevator trim and flaps. These are found
157 in pairs having opposing values for the parameter 'step'.
158 The 'repeatable' parameter should be appropriate to the type of control.
159
160         step
161 This defines how much adjustment is applied when the button is activated
162 Default values are 1.0 for brakes (full on), 0.001 / -0.001 for
163 elevator trim and -0.34 / 0.34 for flaps
164
165         repeatable
166 In this case repeatable means when the button is held down the value continues
167 to increment. repeatable is a true / false value. The default for brakes is
168 false. This is appropriate since by default brakes are a switch that are full
169 on. Elevator trim on the other hand defaults to true. Holding down the
170 button for elevator trim will cause a continuous adjustment until the button
171 is released. Being a fine adjustment this is appropriate behaviour. Flaps
172 on the otherhand default to false. Clicking the flaps button will cause the
173 flaps to be extended to the first detent, subsequent clicks will extend or
174 retract by one increment. Being a large adjustment with a major impact on a 
175 planes handling this is a good thing.
176
177 Syntax for properties in .fgfsrc
178
179 Here is a listing of the defaults as they would appear in .fgfsrc
180 You only need entries where the defaults aren't what you want.
181 In my case I had to make entries to put the throttle on axis2.
182
183     // Default axis 0 to aileron
184 --prop:/input/js0/axis0/control=/controls/aileron
185 --prop:/input/js0/axis0/dead-band=0.1
186  
187     // Default axis 1 to elevator
188 --prop:/input/js0/axis1/control=/controls/elevator"
189 --prop:/input/js0/axis1/dead-band=0.1
190 --prop:/input/js0/axis1/factor=-1.0
191  
192     // Default axis 2 to rudder
193 --prop:/input/js0/axis2/control=/controls/rudder
194 --prop:/input/js0/axis2/dead-band=0.1
195  
196     // Default axis 3 to throttle
197 --prop:/input/js0/axis3/control=/controls/throttle
198 --prop:/input/js0/axis3/dead-band=0.0
199 --prop:/input/js0/axis3/offset=-1.0
200 --prop:/input/js0/axis3/factor=-0.5
201  
202     // Default button 0 to all brakes
203 --prop:/input/js0/button0/action=switch
204 --prop:/input/js0/button0/control=/controls/brakes/all        
205 --prop:/input/js0/button0/step=1.0
206 --prop:/input/js0/button0/repeatable=false 
207
208     // Default button 1 to left brake.
209 --prop:/input/js0/button1/action=switch
210 --prop:/input/js0/button1/control=/controls/brakes/left
211 --prop:/input/js0/button1/step=1.0
212 --prop:/input/js0/button1/repeatable=false
213  
214     // Default button 2 to right brake.
215 --prop:/input/js0/button2/action=switch
216 --prop:/input/js0/button2/control=/controls/brakes/right
217 --prop:/input/js0/button2/step=1.0
218 --prop:/input/js0/button2/repeatable=false
219  
220     // Default buttons 3 and 4 to elevator trim
221 --prop:/input/js0/button3/action=adjust
222 --prop:/input/js0/button3/control=/controls/elevator-trim
223 --prop:/input/js0/button3/step=0.001
224 --prop:/input/js0/button3/repeatable=true
225
226 --prop:/input/js0/button4/action=adjust
227 --prop:/input/js0/button4/control=/controls/elevator-trim
228 --prop:/iput/js0/button4/step=0.001
229 --prop:/input/js0/button4/repeatable=true
230  
231     // Default buttons 5 and 6 to flaps
232 --prop:/input/js0/button5/action=adjust
233 --prop:/input/js0/button5/control=/controls/flaps
234 --prop:/input/js0/button5/step=-0.34
235 --prop:/input/js0/button5/repeatable=false
236
237 --prop:/input/js0/button6/action=adjust
238 --prop:/input/js0/button6/control=/controls/flaps"        
239 --prop:/input/js0/button6/step=0.34       
240 --prop:/input/js0/button6/repeatable=false
241
242
243
244
245
246