Debian Codegraph @

Docs/README.Joystick.html

raw symbols SCIP
1 <HTML>
2 <HEAD>
3 <TITLE>Users Guide to FGInput - Joystick And Keyboard Bindings For FlightGear</TITLE>
4 </HEAD>
5
6 <body>
7
8 <H1>Users Guide to FGInput - Joystick And Keyboard Bindings For FlightGear</H1>
9 Or The document formerly know as
10 <H2>The Users Guide to Joystick Usage Under FlightGear Flight Simulator"</H2>
11
12 <cite>
13 version 0.9.8.1 13/10/2005
14 Author John Check
15 </cite>
16
17 <ol>
18 <li><A HREF="#history">Some History</A>
19 <li><A HREF="#first_things">First Things First</A>
20 <li><A HREF="#xml">About XML</A>
21 <li><A HREF="#output">Determining Your Joystick Output</A>
22 <li><A HREF="#default">Default Joystick Properties</A>
23 <li><A HREF="#okay">Okay, Now What?</A>
24 <li><A HREF="#modifiers">Modifiers For Raw Joystick Values</A>
25 <li><A HREF="#command_manager">The Command Manager</A>
26 <li><A HREF="#bindings">Bindings</A>
27 <li><A HREF="#axes">Joystick Axes</A>
28 <li><A HREF="#buttons">Button Properties</A>
29 <li><A HREF="#coolie_hat">Digital Coolie Hats</A>
30 <li><A HREF="#keyboard">Keyboard Bindings</A>
31 </ol>
32
33 <p>
34 This document is written with versions of FlightGear 0.7.7 and greater
35 in mind. It assumes a working joystick present on your system. It
36 is written from the perspective a Linux user, but the information presented
37 is valid on other platforms.
38 </p>
39 <p>
40 Thanks to David Megginson, who aside from actually implementing FGFS XML
41 features, lets me rip off his descriptions of how stuff works so I can look
42 smart.
43 </p>
44
45
46 <HR WIDTH="20%">
47 <H2><A NAME="history">Some History:</A></H2>
48 <HR WIDTH="20%">
49 <p>
50 Earlier versions of FGFS had assignments of joystick axis/buttons
51 and key bindings hard coded. If you had a joystick that did not use
52 the default channel assignments, or wanted different key bindings,
53 you had to edit the source code and recompile.
54 </p>
55 <p>
56 Fortunately, around about v0.7.5 a "property manager" was implemented,
57 which facilitated being able to set the parameters for the joystick at runtime.
58 Version 0.7.7 saw an expanded role for the property manager and the
59 addition of a "command manager" that allows for binding of events to commands.
60 The code that does this is known as FGInput and is used to configure
61 keyboard command bindings as well as joysticks.
62 </p>
63 <p>Version 0.7.9 added a compiled decision tree allowing for conditionals
64 to be used.
65 <HR WIDTH="20%">
66 <H2><A NAME="first_things">First Things First:</A></H2>
67 <HR WIDTH="20%">
68
69 <p>
70 I will cover joysticks first and save the keyboard stuff for later.
71 FGInput treats things in a generic enough way that the line between
72 joystick buttons and keyboard events starts to blur.
73 </p>
74 <p>
75 Storing alternate keyboard or joystick bindings can be done in a variety of ways. The order of precedence for options is thus:
76 </p>
77
78 <pre>
79 Source Location Format Scope
80 ------ -------- ------ -----
81 command line STDIN see examples session
82 .fgfsrc ~/ command line options single user
83 system.fgfsrc $FG_ROOT command line options system wide
84 joystick.xml $FG_ROOT XML property list system wide
85 keyboard.xml $FG_ROOT XML property list system wide
86 </pre>
87 <br>
88
89
90 <HR WIDTH="20%">
91 <H2><A NAME="xml">About XML:</A></H2>
92 <HR WIDTH="20%">
93
94 <p>
95 In case you were wondering, XML stands for eXtensible Markup Language.
96 It looks a lot like HTML, except you get to define your own tags. Well,
97 in the case of FGFS we defined the tags you need to configure things.
98 It is well suited for describing hierarchically organized structures, such as
99 the property tree FGFS uses to expose the it's innards to external applications.
100 Your XML configuration files for FGFS must start and end with the following
101 pair of tags.
102 </p>
103
104 <pre>
105 &lt;PropertyList&gt;
106 &lt;!-- this is a comment, See I told you it was like HTML --&gt;
107 &lt;/PropertyList&gt;
108 </pre>
109 <br>
110
111 <HR WIDTH="20%">
112 <H2><A NAME="output">Determining your joystick output:</A></H2>
113 <HR WIDTH="20%">
114
115 <p>
116 FlightGear ships with a utility called js_demo. It will report
117 the number of joysticks attached to a system and their capabilities.
118 By observing the output of js_demo while working your joystick you can
119 determine what controls are where.
120 It should be noted that, at least on UNIX, numbering generally starts with
121 zero. In the following example the system has 1 joystick (js0) connected.
122 The output shown is from an analog Gravis BlackHawk with four buttons and
123 a throttle.
124 </p>
125
126 <pre>
127 Typical output of js_demo:
128
129 Joystick test program.
130 ~~~~~~~~~~~~~~~~~~~~~~
131 Joystick 1 not detected &lt;!-- remember we start at 0 --&gt;
132 Joystick 2 not detected
133 +--------------JS.0--------------+
134 | Btns Ax:0 Ax:1 Ax:2 |
135 +--------------------------------+
136 | 0000 +0.0 +0.0 -1.0 |
137 </pre>
138 <br>
139 <P>
140 The buttons are handled internally as a binary number in which bit 0 (the
141 least significant bit) represents button 0, bit 1 represents button 1, etc.,
142 but this number is displayed on the screen in hexadecimal notation, so:
143 </p>
144 <pre>
145 0001 => button 0 pressed
146 0002 => button 1 pressed
147 0004 => button 2 pressed
148 0008 => button 3 pressed
149 0010 => button 4 pressed
150 0020 => button 5 pressed
151 0040 => button 6 pressed
152 ... etc. up to ...
153 8000 => button 15 pressed
154 ... and ...
155 0014 => buttons 2 and 4 pressed simultaneously
156 ... etc.
157 </PRE>
158 <br>
159 <HR WIDTH="20%">
160 <H2><A NAME="default">Default Joystick Properties:</A></H2>
161 <HR WIDTH="20%">
162 <pre>
163 Axis 0 = Aileron
164 Axis 1 = Elevator
165 Axis 2 = Rudder
166 Axis 3 = Throttle
167 Button 0 = All brakes
168 Button 1 = Elevator trim (up)
169 Button 2 = Elevator trim (down)
170 </pre>
171 <br>
172
173 <HR WIDTH="20%">
174 <H2><A NAME="okay">Okay, Now what?</A></H2>
175 <HR WIDTH="20%">
176 <p>
177 Now that you know what the output of the devices connected to the joystick
178 port (or USB port joystick devices) is, you probably want to dive straight
179 in and to start connecting to FGInput. If you are familiar with configuring
180 the joystick on versions of FGFS prior to 0.7.7 you can skip down to the
181 section <A HREF="#command_manager">"The Command Manager"</A>.
182 </P>
183 <P>
184 If you are a new FGFS user, you should at least skim the next bit since it
185 explains some concepts you may or may not know. It also covers some legacy
186 joystick options which have not been implemented yet in the context of the
187 command manager.
188 </p>
189
190 <HR WIDTH="20%">
191 <H2><A NAME="modifiers">Modifiers For Raw Joystick Values</A></H2>
192 <HR WIDTH="20%">
193
194 <p>
195 These concepts are expressed by supplying arguments to the joystick bindings.
196 The raw values coming from the joystick axes may not be suitable to use directly.
197 For that matter not all joysticks are created equal so understanding the basic
198 concepts should save you some time when experimenting to get the best performance.
199 </P>
200 <P>
201 The full order of precedence for axis properties is
202 </P>
203 <P>
204 1. The raw axis value ...<BR>
205 2. is filtered by dead-band, ... (deadband is implemented outside the command manager.)<BR>
206 3. then adjusted to offset, ...<BR>
207 4. then multiplied by factor, ...<BR>
208 5. the resulting value is assigned to the FlightGear control property.<BR>
209 <BR>
210 Put another way....<BR>
211 <BR>
212 cooked_value = (( raw_value > dead-band ) + offset) * factor<BR>
213 <BR>
214
215 <pre>
216 Axis properties:
217
218 dead-band
219
220 -1 0 1
221 ...............
222 -1 | | 1
223 ^
224 dead-band
225 </pre>
226 <br>
227
228 <P>
229 This is an area where signals are ignored. It is used to compensate
230 for noise, or potentiometers of dubious quality by creating a threshold
231 below which any signal is suppressed. dead-band is relative to zero.
232 </P>
233 <P>
234 The default of 0.1 for elevators and ailerons is very forgiving. A lower
235 number results in a tighter feel. In some cases such as throttle you may
236 wish to not set a deadband. Use a value of 0.0 in this case.
237 </P>
238
239 <pre>
240 offset
241 -1 0 1
242 .............
243 -1 ^ 1
244 offset
245 </pre>
246 <br>
247 <P>
248 Used to maximize a controls use of it's axis, as in the case of a
249 throttle where zero would be a minimum and not a center point like in the case
250 of a rudder. Typical value -1.0.
251 </P>
252 <br>
253 <pre>tolerance</pre>
254 <br>
255 <P>
256 Used to compensate for jittery potentiometer output, tolerance is in essence
257 a gate. Amounts of movement below the threshold are ignored. Unlike dead-band,
258 tolerance is relative to where ever the axis is at rest.
259 </p>
260 <br>
261 <pre>factor</pre>
262 <br>
263 <P>
264 Controls proportional movement of an axis. If the factor is too low it results in control not reaching its maximum possible limit. Negating the number will result in the control moving counter to the default. The default value is 1.0, think unity gain.
265 </P>
266 <P>
267 In my case, throttle behavior was inverted from what I preferred.
268 I set this value to -1.0 and everything was groovy.
269 </p>
270 <HR WIDTH="20%">
271 <H2><A NAME="command_manager">The Command Manager:</A></H2>
272 <HR WIDTH="20%">
273
274 <p>
275 Previous versions of FGFS allowed joystick output to be bound directly
276 to the property manager. This has changed for FGFS v0.7.7 and now events
277 are bound to commands. Commands *must* be specified for a binding to have
278 an effect. The current list of commands is broken down here into two
279 categories, mainly for my convenience.
280 </P>
281 <pre>
282 Visual And File Related:
283 command options used for
284 ------- ------- --------
285 null none clearing a previous binding
286 exit none Exiting FGFS
287 load file name* Load a saved flight
288 save file name* Save current flight
289 load-panel path ** Change/reload panel
290 load-preferences path ** Load preferences ***
291 screen-capture none Save a screenshot to ./fgfs-screen.ppm
292 view-cycle none Change the direction of the pilots view
293
294
295 *Saved/loaded relative to current working directory.<br>
296 **The path includes the filename you wish to load and is relative to $FG_ROOT,
297 which is the location of the installed base package. The default for load-panel
298 is the value of /sim/panel/path (from preferences.xml) or if that is unset
299 Panel/Default/default.xml. The default for load preferences is preferences.xml.
300
301 ***This might make a good first binding to experiment with, since it's not currently
302 bound to anything. Reloading preferences will allow you to test settings
303 without having to sit through a restart of FGFS for every edit. You can
304 always (re)move it later.
305
306 Flight Control:
307
308 command options effect
309 ------- ------- ------
310 property-toggle property toggle the property full on
311 property-assign "" "", value targets a property for action
312 property-adjust "" "", step Increment size for changes
313 property-swap "" ""[0], "" ""[1] Set values in a switch
314 property-scale "" "", offset, factor Processes the raw joystick value
315 </pre>
316 <br>
317
318 <HR WIDTH="20%">
319 <H2><A NAME="bindings">Bindings:</A></H2>
320 <HR WIDTH="20%">
321 <p>
322
323 A command may have more than one binding. By default, the examples below
324 use just /binding or &lt;binding&gt;, but /binding[0] or &lt;binding n="0"&gt; is implied.
325 When bindings are specified in XML the indices are created automagically. If
326 you wish to avoid XML you must supply the index number for multiple bindings
327 in your command line formatted options.
328 </P>
329
330 <HR WIDTH="20%">
331 <H2><A NAME="axes">Joystick Axes:</A></H2>
332 <HR WIDTH="20%">
333
334 <p>
335 Here's a sample Joystick axis declaration in XML:
336 </p>
337
338 <PRE>
339 &lt;axis n="0"&gt; &lt;!-- target an axis --&gt;
340 &lt;desc&gt;Aileron&lt;/desc&gt; &lt;!-- descriptive name (optional) --&gt;
341 &lt;binding&gt; &lt;!-- open a container for the binding --&gt;
342 &lt;command&gt;property-scale&lt;/command&gt; &lt;!-- pick a command --&gt;
343 &lt;property&gt;/controls/flight/aileron&lt;/property&gt; &lt;!-- target a property --&gt;
344 &lt;/binding&gt; &lt;!-- closing tag for binding --&gt;
345 &lt;/axis&gt; &lt;!-- closing tag for axis --&gt;
346 </PRE>
347 <br>
348 <P>
349 Remember how I said the property tree was a hierarchy? Thoughtful readers
350 will notice how the nested tags keep things organized.
351 This binding appears in the context /input/joysticks/js/, so the
352 command-line option equivalent of this declaration (leaving out the
353 'desc', which isn't strictly necessary), is
354 </P>
355 <PRE>
356 --prop:/input/joysticks/js[0]/axis[0]/binding/command=property-scale
357 --prop:/input/joysticks/js[0]/axis[0]/binding/property=/controls/flight/aileron
358 </PRE>
359 <br>
360 <P>
361 Do you see how the command line versions uses a path to represent the hierarchy?
362 Cool! You should read README.xmlpanel next, working with FGFS XML configuration
363 system is easy and it's fun for the whole family! ( not sold in stores. excludes
364 tax and title. void where prohibited by law.)
365 </P>
366 <P>
367 Ok, back to business. The 'property-scale' command also recognizes 'offset' and
368 'factor' arguments. The "type" arguments shown in the following example are
369 specifying a double precision floating point number. A double has more discrete
370 steps and gives a smoother action than a plain float.
371 </P>
372 <PRE>
373
374 &lt;axis n="2"&gt;
375 &lt;desc&gt;Throttle&lt;/desc&gt;
376 &lt;!-- See important note about dead-band below --&gt;
377 &lt;binding&gt;
378 &lt;command&gt;property-scale&lt;/command&gt;
379 &lt;property&gt;/controls/engines/engine[0]/throttle&lt;/property&gt;
380 &lt;offset type="double"&gt;-1.0&lt;/offset&gt;
381 &lt;factor type="double"&gt;-0.5&lt;/factor&gt;
382 &lt;/binding&gt;
383 &lt;/axis&gt;</tt>
384
385 or
386
387 --prop:/input/joysticks/js[0]/axis[2]/binding/command=property-scale
388 --prop:/input/joysticks/js[0]/axis[2]/binding/property=/controls/engines/engine[0]/throttle
389 --prop:/input/joysticks/js[0]/axis[2]/binding/offset=-1.0
390 --prop:/input/joysticks/js[0]/axis[2]/binding/factor=-0.5
391 </PRE>
392 <br>
393 <p>
394 *Important Note About dead-band*<br>
395 --------------------------------
396 </P>
397
398 <P>
399 You may recall from the section about raw axis value modifiers that dead-band
400 is implemented outside the command manager. This means that if you want to apply
401 a dead-band, the tag *must* precede the binding tag. If you are using the command
402 line format you must omit the 'binding' part like so:
403 </P>
404
405 <PRE>
406 --prop:/input/joysticks/js[0]/axis[2]/dead-band=0.005
407 </PRE>
408
409 <br>
410 <HR WIDTH="20%">
411 <H2><A NAME="buttons">Joystick Button Properties:</A></H2>
412 <HR WIDTH="20%">
413
414 <p>
415 Buttons, being boolean by nature, can use a little help. By this I mean that there are times when you need momentary action, times where you need a repeating action and sometimes you just want a plain old toggle. In order to facilitate this need we have some tags that modify the actions of buttons.
416 </P>
417
418 <PRE>
419
420 &lt;repeatable&gt;
421 &lt;!-- Will be either true or false. If it is true, holding down a button (or key) will cause
422 repeated events, say, for moving the trim; if false (the default), pressing a key will cause only a single event. --&gt;
423
424 &lt;step&gt;
425 &lt;!-- The property-adjust command takes a 'step' argument specifying the amount of the adjustment
426 for each event. In the following example, the elevator trim moves 0.1% for each event (without automatic
427 repetition, you'd have a pretty sore finger). --&gt;
428
429 &lt;value&gt;
430 &lt;!-- Use value on non-repeatables to supply the value for each consecutive press--&gt;
431 &lt;mod-up&gt;
432 &lt;!-- This stands for "modifier up", my favorite I think. This is used to set up a binding for
433 when you *release* a key. As you'll see, it comes in handy --&gt;
434 </PRE>
435 <br>
436 <P>
437 Here's a sample joystick button declaration in XML:
438 </P>
439
440 <PRE>
441 &lt;button n="1"&gt; &lt;!-- target a button --&gt;
442 &lt;desc&gt;Elevator trim up&lt;/desc&gt; &lt;!-- optional description --&gt;
443 &lt;repeatable&gt;true&lt;/repeatable&gt; &lt;!-- Ok, repeatable is outside the command manager too --&gt;
444 &lt;binding&gt; &lt;!-- Open the "binding" node of the tree--&gt;
445 &lt;command&gt;property-adjust&lt;/command&gt; &lt;!-- pick a command type to bind --&gt;
446 &lt;property&gt;/controls/flight/elevator-trim&lt;/property&gt; &lt;!-- target a property --&gt;
447 &lt;step type="double"&gt;0.001&lt;/step&gt;
448 &lt;/binding&gt;
449 &lt;/button&gt;
450 </PRE>
451 <br>
452 <P>
453 In command-line option syntax, this would appear as
454 </P>
455
456 <PRE>
457 --prop:/input/joysticks/js[0]/button[1]/repeatable=true &lt;-- See? no 'binding' --&gt;
458 --prop:/input/joysticks/js[0]/button[1]/binding/command=property-adjust
459 --prop:/input/joysticks/js[0]/button[1]/binding/property=/controls/flight/elevator-trim
460 --prop:/input/joysticks/js[0]/button[1]/binding/step=0.001
461 </PRE>
462 <br>
463 <P>
464 Here's a slightly fancier declaration, that applies the left (differential) brakes
465 when button 4 is pressed, and releases them automatically when the user releases the
466 button:
467 </P>
468
469 <PRE>
470 &lt;button n="4"&gt;
471 &lt;desc&gt;Left brake&lt;/desc&gt;
472 &lt;binding&gt;
473 &lt;command&gt;property-assign&lt;/command&gt;
474 &lt;property&gt;/controls/gear/brake-left&lt;/property&gt;
475 &lt;value type="double"&gt;1.0&lt;/value&gt; &lt;!-- brakes are a toggle so 1.0 represents on --&gt;
476 &lt;/binding&gt;
477 &lt;mod-up&gt; &lt;!-- it's not a parking brake so we need to release it --&gt;
478 &lt;binding&gt;
479 &lt;command&gt;property-assign&lt;/command&gt;
480 &lt;property&gt;/controls/gear/brake-left&lt;/property&gt;
481 &lt;value type="double"&gt;0.0&lt;/value&gt; &lt;!-- 1.0 is on so 0.0 is off, right? --&gt;
482 &lt;/binding&gt;
483 &lt;/mod-up&gt;
484 &lt;/button&gt;
485 </PRE>
486 <br>
487 <p>
488 The first binding is straight-forward: when the button is pressed, the
489 'property-assign' command assigns the value 1.0 (i.e. full) to the left brake
490 property. The second binding, however, is nested inside a 'mod-up' element,
491 it will be fired when the user *releases* the button, and will use the
492 'property-assign' command to assign the value 0.0 (i.e. none) to the left brake
493 property. Repetition is left at the default value of false, so that the same
494 value will not be assigned over and over again.
495 </P>
496 <P>
497 Here's the command-line equivalent:
498 </p>
499 <PRE>
500 --prop:/input/joysticks/js[0]/button[4]/binding/command=property-assign
501 --prop:/input/joysticks/js[0]/button[4]/binding/property=/controls/gear/brake-left
502 --prop:/input/joysticks/js[0]/button[4]/binding/value=1.0
503 --prop:/input/joysticks/js[0]/button[4]/mod-up/binding/command=property-assign
504 --prop:/input/joysticks/js[0]/button[4]/mod-up/binding/property=/controls/gear/brake-left
505 --prop:/input/joysticks/js[0]/button[4]/mod-up/binding/value=0.0
506 </PRE>
507 <br>
508 <P>
509 Remember that more than one binding can be included in each context. Here's a
510 very hairy example from the default bindings that fires all three brakes when
511 button 0 is pressed, and releases all three when button 0 is released:
512 </P>
513
514 <PRE>
515 &lt;button n="0"&gt;
516 &lt;desc&gt;Brakes&lt;/desc&gt;
517 &lt;binding&gt;
518 &lt;command&gt;property-assign&lt;/command&gt;
519 &lt;property&gt;/controls/gear/brake-left&lt;/property&gt;
520 &lt;value type="double"&gt;1.0&lt;/value&gt;
521 &lt;/binding&gt;
522 &lt;binding&gt;
523 &lt;command&gt;property-assign&lt;/command&gt;
524 &lt;property&gt;/controls/gear/brake-right&lt;/property&gt;
525 &lt;value type="double"&gt;1.0&lt;/value&gt;
526 &lt;/binding&gt;
527 &lt;mod-up&gt;
528 &lt;binding&gt;
529 &lt;command&gt;property-assign&lt;/command&gt;
530 &lt;property&gt;/controls/gear/brake-left&lt;/property&gt;
531 &lt;value type="double"&gt;0.0&lt;/value&gt;
532 &lt;/binding&gt;
533 &lt;binding&gt;
534 &lt;command&gt;property-assign&lt;/command&gt;
535 &lt;property&gt;/controls/gear/brake-right&lt;/property&gt;
536 &lt;value type="double"&gt;0.0&lt;/value&gt;
537 &lt;/binding&gt;
538 &lt;/mod-up&gt;
539 &lt;/button&gt;
540 </PRE>
541 <br>
542 <p>
543 For people who take pleasure in avoiding XML, here's the command-line
544 equivalent (note the subscripts to distinguish multiple bindings; the
545 XML will handle this automatically):
546 </P>
547 <PRE>
548 --prop:/input/joysticks/js[0]/button[0]/binding[0]/command=property-assign
549 --prop:/input/joysticks/js[0]/button[0]/binding[0]/property=/controls/gear/brake-left
550 --prop:/input/joysticks/js[0]/button[0]/binding[0]/value=1.0
551 --prop:/input/joysticks/js[0]/button[0]/binding[1]/command=property-assign
552 --prop:/input/joysticks/js[0]/button[0]/binding[1]/property=/controls/gear/brake-right
553 --prop:/input/joysticks/js[0]/button[0]/binding[2]/value=1.0
554 --prop:/input/joysticks/js[0]/button[0]/mod-up/binding[0]/command=property-assign
555 --prop:/input/joysticks/js[0]/button[0]/mod-up/binding[0]/property=brakes[0]
556 --prop:/input/joysticks/js[0]/button[0]/mod-up/binding[0]/value=0.0
557 --prop:/input/joysticks/js[0]/button[0]/mod-up/binding[1]/command=property-assign
558 --prop:/input/joysticks/js[0]/button[0]/mod-up/binding[1]/property=brakes[1]
559 --prop:/input/joysticks/js[0]/button[0]/mod-up/binding[1]/value=0.0
560 </PRE>
561 <br>
562 <P>
563 This is a good time to remind you that command line formatted options are used
564 in your .fgfsrc file. You can put them in $FG_ROOT/system.fgfsrc to make them
565 global.
566 </P>
567 <HR WIDTH="20%">
568 <H2><A NAME="coolie_hat">Digital Coolie Hats:</A></H2>
569 <HR WIDTH="20%">
570 <p>
571 Many common joysticks come with digital coolie hats. These are detected as
572 axes rather than as buttons, although they are in fact just four (or eight)
573 simple switches. FGFS provides 2 virtual buttons to every axis which are
574 triggered whenever the axis reaches one of the end positions. These virtual
575 buttons can be addressed via two sub-properties "low" and "high" and accept any
576 of the common button properties.
577 </P>
578 <P>
579 For example, if you just want to control view direction, you can map two of the
580 axes to /sim/view/axes/long and /sim/view/axes/lat:
581 </P>
582 <PRE>
583 --prop:/input/joysticks/js/axis[5]/binding/command=property-scale
584 --prop:/input/joysticks/js/axis[5]/binding/property=/sim/view/axes/lat
585
586 --prop:/input/joysticks/js/axis[6]/binding/command=property-scale
587 --prop:/input/joysticks/js/axis[6]/binding/property=/sim/view/axes/long
588 </PRE>
589 <br>
590 <p>
591 If you want to use them as buttons (say, to scroll the panel
592 vertically or horizontally), you can use the high/low bindings.
593 Here's an example of how to use an axis to adjust the elevator trim:
594 </P>
595 <PRE>
596 --prop:/input/joysticks/js/axis[1]/low/repeatable=true
597 --prop:/input/joysticks/js/axis[1]/low/binding/command=property-adjust
598 --prop:/input/joysticks/js/axis[1]/low/binding/property=/controls/flight/elevator-trim
599 --prop:/input/joysticks/js/axis[1]/low/binding/step=0.001
600
601 --prop:/input/joysticks/js/axis[1]/high/repeatable=true
602 --prop:/input/joysticks/js/axis[1]/high/binding/command=property-adjust
603 --prop:/input/joysticks/js/axis[1]/high/binding/property=/controls/flight/elevator-trim
604 --prop:/input/joysticks/js/axis[1]/high/binding/step=-0.001
605 </PRE>
606 <br>
607 <p>
608 If you want you can specify a time interval for processing digital hat repeats. For example
609 if you want an interval of 0.05 seconds, which will effect up to 20 repeats per second, then add
610 the following to the property:
611 </p>
612 <PRE>
613 --prop:/input/joysticks/js/axis[1]/interval-sec=0.05
614 </PRE>
615 <br>
616 <p>
617 If you want specify a delay time before interval repeats action. For example
618 if you want an interval of 0.05 seconds after 1 second the axis has been pressed, then add
619 the following to the property:
620 </p>
621 <PRE>
622 --prop:/input/joysticks/js/axis[1]/delay-sec=1
623 --prop:/input/joysticks/js/axis[1]/interval-sec=0.05
624 </PRE>
625 <p>
626 Similarly, release-delay-sec is how long to wait after releasing the button.
627 </p>
628 <br>
629 <P>
630 You could also bind some axes to brakes, so that you can use positions
631 between between 0.0 (no brakes) and 1.0 (full brakes).
632 </P>
633
634 <HR WIDTH="20%">
635 <H2><A NAME="keyboard">Keyboard Bindings:</A></H2>
636 <HR WIDTH="20%">
637 <p>
638 Keyboard bindings are almost exactly identical to joystick-button
639 bindings, as in the following example (the context is
640 /input/keyboard):
641 </P>
642 <PRE>
643 &lt;key n="1"&gt;
644 &lt;name&gt;Ctrl-A&lt;/name&gt;
645 &lt;desc&gt;Toggle autopilot altitude lock.&lt;/desc&gt;
646 &lt;binding&gt;
647 &lt;command&gt;property-toggle&lt;/command&gt;
648 &lt;property&gt;/autopilot/locks/altitude&lt;/property&gt;
649 &lt;/binding&gt;
650 &lt;/key&gt;
651 </PRE>
652 <br>
653 <P>
654 There are a few gotcha's though. First, the index of the key
655 specifies the key code that you're binding; in the above example, '1'
656 corresponds to Ctrl-A (as mentioned in the friendly comment). Regular
657 key codes go up to 255; codes from 256 up represent special keys like
658 function and arrow keys (you can get the value from include/GL/glut.h,
659 but adding 256 to the special key code). Here is the command-line
660 equivalent of the above, leaving out the documentation properties:
661 </P>
662 <PRE>
663 --prop:/input/keyboard/key[1]/binding/command=property-toggle
664 --prop:/input/keyboard/key[1]/binding/property=/autopilot/locks/altitude
665 </PRE>
666 <br>
667 <p>
668 (The 'property-toggle' command switches a boolean value between true and
669 false, so it needs no arguments except for the property name.) DON'T
670 LEAVE OUT THE INDEX!!!
671 </P>
672 <P>
673 The second gotcha is that keys can take more modifiers than joystick
674 buttons. In addition to mod-up (representing the key release), a key
675 may use any combination of nested 'mod-alt', 'mod-ctrl', and
676 'mod-shift' modifiers, as in the following example:
677 </P>
678 <PRE>
679 &lt;key n="49"&gt;
680 &lt;name&gt;1&lt;/name&gt;
681 &lt;mod-shift&gt;
682 &lt;desc&gt;Look back left&lt;/desc&gt;
683 &lt;binding&gt;
684 &lt;command&gt;property-assign&lt;/command&gt;
685 &lt;property&gt;/sim/view/goal-offset&lt;/property&gt;
686 &lt;value type="double"&gt;135&lt;/value&gt;
687 &lt;/binding&gt;
688 &lt;/mod-shift&gt;
689 &lt;/key&gt;
690 </PRE>
691 <br>
692 <P>
693 In this example, the '1' key combined with shift causes the view to
694 switch to back left. Note that this will work only with the keypad 1,
695 since pressing shift+1 on the regular keyboard will give a '!'
696 character instead.
697 </P>
698 <P>
699 The input module tries to be smart about supplying control and shift
700 modifiers automatically where they make sense -- note that it wasn't
701 necessary to use a nested 'mod-ctrl' element for the ctrl-A binding
702 earlier, since a keycode less that 32 implies a control character
703 anyway.
704 </P>
705 <P>
706 With the new input module, the key-up events can also be detected for
707 the keyboard, so it's possible to have touch-sensitive brakes (etc.)
708 just as with the joystick:
709 </P>
710 <PRE>
711 &lt;key n="44"&gt;
712 &lt;name&gt;,&lt;/name&gt;
713 &lt;desc&gt;Left brake&lt;/desc&gt;
714 &lt;binding&gt;
715 &lt;command&gt;property-assign&lt;/command&gt;
716 &lt;property&gt;/controls/gear/brake-left&lt;/property&gt;
717 &lt;value type="double"&gt;1.0&lt;/value&gt;
718 &lt;/binding&gt;
719 &lt;mod-up&gt;
720 &lt;binding&gt;
721 &lt;command&gt;property-assign&lt;/command&gt;
722 &lt;property&gt;/controls/gear/brake-left&lt;/property&gt;
723 &lt;value type="double"&gt;0.0&lt;/value&gt;
724 &lt;/binding&gt;
725 &lt;/mod-up&gt;
726 &lt;/key&gt;
727 </PRE>
728 <br>
729 <P>
730 Now here is a different way to bind a brake. In this example, there is
731 no &lt;mod-up&gt; tag, so it *does* work like a parking brake.
732 </P>
733
734 <PRE>
735 &lt;key n="66"&gt;
736 &lt;name&gt;B&lt;/name&gt;
737 &lt;desc&gt;Toggle parking brake on or off&lt;/desc&gt;
738 &lt;binding&gt;
739 &lt;command&gt;property-toggle&lt;/command&gt;
740 &lt;property&gt;/controls/gear/brake-parking&lt;/property&gt;
741 &lt;/binding&gt;
742 &lt;/key&gt;
743 </PRE>
744
745 </BODY>
746 </HTML>