Hi all,

I have done a new joystick definition for my hardware. This is the 
thrustmaster top gun afterburner USB (what a name!) throttle/stick 
combination.

I took the great Cyborg-Gold-3d-USB.xml configuration and adjusted it to the 
thrustmaster axis and button definitions, the global layout is the same.
The most notable customization is the throttle, which has two raster 
positions. One marked with 'idle' and one marked with 'afterburner'.
I have made the throttle values scale between 0 and 0.98 between the idle and 
afterburner raster. In a small area around the raster there is a deadband 
like zone. Above the abterburner raster, it scales the throttle up to the 
value of 1, which then will give afterburning. Aditionaly 
the /controls/engines/engine*/augumentation value is set to true in this 
afterburning area.

Attached is small diff to incorporate the joystick into the global 
configuration and the joystick configuration itself.

In the hope that it might be useful: could someone apply this to the cvs tree 
please?

    Greetings

        Mathias

-- 
Mathias FrÃhlich, email: [EMAIL PROTECTED]
? Input/Joysticks/ThrustMaster/Top-Gun-Afterburner.xml
Index: joysticks.xml
===================================================================
RCS file: /var/cvs/FlightGear-0.9/data/joysticks.xml,v
retrieving revision 1.25
diff -u -r1.25 joysticks.xml
--- a/joysticks.xml	5 Jan 2004 20:48:00 -0000	1.25
+++ b/joysticks.xml	4 Mar 2004 10:04:46 -0000
@@ -43,6 +43,7 @@
  <!-- ThrustMaster devices -->
  <js-named include="Input/Joysticks/ThrustMaster/FCS.xml"/>
  <js-named include="Input/Joysticks/ThrustMaster/Attack-Throttle.xml"/>
+ <js-named include="Input/Joysticks/ThrustMaster/Top-Gun-Afterburner.xml"/>
 
  <!-- Lew Engineering RCJOY device for various RC transmitters.  http://www.leweng.com -->
  <js-named include="Input/Joysticks/LewEngineering/RC-transmitter-hitecLaser4.xml"/>
<?xml version="1.0"?>
<!--
$Id$

Bindings for THRUSTMASTER Top Gun Afterburner stick/throttle combination.

This file is based on the Cyborg-Gold-3d-USB configuration file. So it provides
maximum compatibility.

_______________________________________ Layout _______________________________________


axis 0:                      aileron
axis 1:                      elevator
axis 2:                      rudder
axis 3:                      throttle


                             no modifier     F3              F4              F3+F4
                             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
button 0 (trigger):          brakes          parking brake   speed brake     thrust revers.
button 1 (top middle):       flaps up        gear up         previous view   *
button 2 (front right):      reset view dir  tail wheel lock cockpit view    reset all trim
button 3 (top right):        flaps down      gear down       next view       *
button 4 (thr. down/back):   brakes left     *               zoom out        *
button 5 (thr. middle/back): brakes right    *               zoom in         *
button 6 (thr. upper/back):  //////////////////////// modifier 0 /////////////////////////
button 7 (thr. front):       //////////////////////// modifier 1 /////////////////////////
hat left (axis5):            look left       leaner mixture  aileron trim    rudder trim
hat right (axis5):           look right      richer mixture  aileron trim    rudder trim
hat back (axis6):            look down       dec prop pitch  elevator trim   *
hat forward (axis6):         look up         inc prop pitch  elevator trim   *


F3 and F4 are used like "Shift", "Control", or "Alternate" on computer keyboards.
For example: press F3 and keep holding it down while pressing the fire
button/trigger -> toggle parking brake

Also this configurations will make use of the raster positions on the throttle.
The idle position and below is really zero thrust command.
Positions bewteen idle and afterburner will scale the thrust value between 0 and 0.98
and thus provides military power for jet engines. The afterburner raster will
really turn on afterburning.

Also to avoid additional deadband values in the linux kernel
to the deadband values configured here in flightgear.
You may need to issue the following command before starting flightgear:

jscal -s 7,1,0,-5,5,4194304,4194304,1,0,-5,5,4194304,4194304,1,0,-5,5,4194304,4194304,1,0,128,128,4194304,4194304,1,0,112,142,5534751,5534751,1,0,0,0,536870912,536870912,1,0,0,0,536870912,536870912 /dev/input/js0

This will also avoid the useless deadband area in the middle of the throttle position.
Also this will make the raster positions of the throttle match the programmed values here.

___________________________________ Customization ____________________________________



If you want to change some (or all) of the bindings, the recommended way is
to copy this file to your home directory, make your changes there, and include
it from your personal preferences.xml file. Use the tags <js-named n="100">
and </js-named> around the definitions, but within the <PropertyList> scope.
(You can use any number lower than 999.)

<PropertyList>
	<input>
		<joysticks include="your-modified-copy.xml"/>
	</input>
</PropertyList>


The property "/input/joysticks/js[0]/saitek-cyborg-3D-modifier" indicates
the "shift" level. F3 sets bit 0, F4 sets bit 1. The property is 'nil' or
zero if none of the shift buttons is pressed, 1 if F3 is pressed, 2 if F4
is pressed, and 3 if both F3 and F4 are pressed.

Note that you have to enclose nasal scripts in <script><![CDATA[...]]></script>
if they contain characters that interfere with the xml markup. This is the case
if you are, for exmaple, using < (lower than). Alternatively, you can 'escape'
the character with "&lt;".




____________________________________ References ______________________________________



Joysticks:      $FG_ROOT/Docs/README.Joystick.html
Properties:     see property browser (fgfs menu: "File"->"Browse internal properties")

Nasal:          http://www.plausible.org/nasal/
Nasal examples: $FG_ROOT/Nasal/


______________________________________________________________________________________

                                                     ~~ Melchior FRANZ <[EMAIL PROTECTED]>
        slightly modified for the thrustmaster joystick Mathias Froehlich <[EMAIL PROTECTED]>
-->

<PropertyList>
	<name>THRUSTMASTER Top Gun Afterburner</name>

	<axis n="0">
		<desc>Aileron</desc>
		<binding>
			<command>property-scale</command>
			<property>/controls/flight/aileron</property>
			<power type="double">2.0</power>
		</binding>
	</axis>

	<axis n="1">
		<desc>Elevator</desc>
		<binding>
			<command>property-scale</command>
			<property>/controls/flight/elevator</property>
			<factor type="double">-1.0</factor>
			<power type="double">2.0</power>
		</binding>
	</axis>

	<axis n="2">
		<desc>Rudder</desc>
		<binding>
			<command>property-scale</command>
			<property>/controls/flight/rudder</property>
			<offset type="double">0.0</offset>
			<factor type="double">1.0</factor>
			<power type="double">2.0</power>
		</binding>
	</axis>

	<axis n="3">
		<!--
		We have a throttle with two raster positions.

		The areas are:
		1 - 0.87: idle
		0.87 - 0.79: idle deadband
		0.79 - -0.55: normal thrust
		-0.55 - -0.73:  afterburner deadband
		-0.73 - -1: afterburner
		-->
		<desc>Throttle</desc>
		<dead-band type="double">0.0</dead-band>
		<binding>
			<command>nasal</command>
			<script>
				<![CDATA[
				if (1==1) {
					val = cmdarg().getNode("setting").getValue();
					abend = -1;
					abstart = -0.73;
					milend = -0.55;
					milstart = 0.79;
					if (val < abstart) {
						# afterburner
						a = 0.03/(abend-abstart);
						b = 1-a*abend;
						props.setAll("/controls/engines/engine", "augumentation", "true");
						props.setAll("/controls/engines/engine", "throttle", a*val+b);
					} else {
						# no afterburner
						props.setAll("/controls/engines/engine", "augumentation", "false");
						if (val < -0.55) {
							# afterburner deadband
							props.setAll("/controls/engines/engine", "throttle", 0.9699999999);
						} else {
							if (val < 0.79) {
								a = 0.96999999999/(milend-milstart);
								b = -a*milstart;
								props.setAll("/controls/engines/engine", "throttle", a*val+b);
							} else {
								props.setAll("/controls/engines/engine", "throttle", 0);
							}
						}
					}
				}
				]]>
			</script>
		</binding>
	</axis>

	<button n="0"><!-- trigger -->
		<desc>Brakes</desc>
		<repeatable type="bool">true</repeatable>
		<binding>
			<command>nasal</command>
			<script>
				mod = getprop("/input/joysticks/js[0]/thrustmaster-top-gun-afterburner-modifier");
				if (mod == nil or mod == 0) {
					interpolate("/controls/gear/brake-left", 1, 0.075);
					interpolate("/controls/gear/brake-right", 1, 0.075);
				} elsif (mod == 1) {
					setprop("/controls/gear/brake-left", 1);
					setprop("/controls/gear/brake-right", 1);
				} elsif (mod == 2) {
					#
				} elsif (mod == 3) {
					#
				}
			</script>
		</binding>
		<mod-up>
			<binding>
				<command>nasal</command>
				<script>
					mod = getprop("/input/joysticks/js[0]/thrustmaster-top-gun-afterburner-modifier");
					if (mod == nil or mod == 0) {
						interpolate("/controls/gear/brake-left", 0, 0.075);
						interpolate("/controls/gear/brake-right", 0, 0.075);
					} elsif (mod == 1) {
						brake = !getprop("/controls/gear/brake-parking");
						setprop("/controls/gear/brake-parking", brake);
						if (brake) {
							gui.popupTip("Parking Brake ON");
						} else {
							gui.popupTip("Parking Brake OFF");
						}
						setprop("/controls/gear/brake-left", 0);
						setprop("/controls/gear/brake-right", 0);
					} elsif (mod == 2) {
						speedbrake = !getprop("/controls/flight/speedbrake");
						setprop("/controls/flight/speedbrake", speedbrake);
					} elsif (mod == 3) {
						reverser = !getprop("/controls/engines/engine[0]/reverser");
						props.setAll("/controls/engines/engine", "reverser", reverser);
						if (reverser) {
							gui.popupTip("Thrust Reverser ON");
						} else {
							gui.popupTip("Thrust Reverser OFF");
						}
					}
				</script>
			</binding>
		</mod-up>
	</button>

	<button n="1"><!-- top middle -->
		<desc>Flaps/gear up; previous view</desc>
		<repeatable type="bool">false</repeatable>
		<binding>
			<command>nasal</command>
			<script>
				mod = getprop("/input/joysticks/js[0]/thrustmaster-top-gun-afterburner-modifier");
				if (mod == nil or mod == 0) {
					controls.stepFlaps(-1);
				} elsif (mod == 1) {
					setprop("/controls/gear/gear-down", 0);
				} elsif (mod == 2) {
					view.stepView(-1);
				} elsif (mod == 3) {
					#
				}
			</script>
		</binding>
	</button>

	<button n="2"><!-- front right -->
		<desc>Reset view; toggle tail-wheel lock; reset trim</desc>
		<repeatable type="bool">false</repeatable>
		<binding>
			<command>nasal</command>
			<script>
				mod = getprop("/input/joysticks/js[0]/thrustmaster-top-gun-afterburner-modifier");
				if (mod == nil or mod == 0) {
					view.resetView();
				} elsif (mod == 1) {
					twlock = !getprop("/controls/gear/tailwheel-lock");
					setprop("/controls/gear/tailwheel-lock", twlock);
					if (twlock) {
					rection Hat -->} else {
						gui.popupTip("Tail Wheel LOCKED");
					}
				} elsif (mod == 2) {
					setprop("/sim/current-view/view-number", 0);
					view.resetView();
				} elsif (mod == 3) {
					setprop("/controls/flight/elevator-trim", 0);
					setprop("/controls/flight/aileron-trim", 0);
					setprop("/controls/flight/rudder-trim", 0);
				}
			</script>
		</binding>
	</button>

	<button n="3"><!-- top right -->
		<desc>Flaps/gear down; next view</desc>
		<repeatable type="bool">false</repeatable>
		<binding>
			<command>nasal</command>
			<script>
				mod = getprop("/input/joysticks/js[0]/thrustmaster-top-gun-afterburner-modifier");
				if (mod == nil or mod == 0) {
					controls.stepFlaps(1);
				} elsif (mod == 1) {
					setprop("/controls/gear/gear-down", 1);
				} elsif (mod == 2) {
					view.stepView(1);
				} elsif (mod == 3) {
					#
				}
			</script>
		</binding>
	</button>
top 
	<button n="4"><!-- throttle down/back -->
		<desc>Brakes left</desc>
		<repeatable type="bool">true</repeatable>
		<binding>
			<command>nasal</command>
			<script>
				mod = getprop("/input/joysticks/js[0]/thrustmaster-top-gun-afterburner-modifier");
				if (mod == nil or mod == 0) {
					interpolate("/controls/gear/brake-left", 1, 0.075);
				} elsif (mod == 1) {
					#
				} elsif (mod == 2) {
					view.increase();
				} elsif (mod == 3) {
					#
				}
			</script>
		</binding>
		<mod-up>
			<binding>
				<command>nasal</command>
				<script>
					mod = getprop("/input/joysticks/js[0]/thrustmaster-top-gun-afterburner-modifier");
					if (mod == nil or mod == 0) {
						interpolate("/controls/gear/brake-left", 0, 0.075);
					} elsif (mod == 1) {
						#
					} elsif (mod == 2) {
						#
					} elsif (mod == 3) {
						#
					}
				</script>
			</binding>
		</mod-up>
	</button>

	<button n="5"><!-- throttle middle/back -->
		<desc>Brakes right</desc>
		<repeatable type="bool">true</repeatable>
		<binding>
			<command>nasal</command>
			<script>
				mod = getprop("/input/joysticks/js[0]/thrustmaster-top-gun-afterburner-modifier");
				if (mod == nil or mod == 0) {
					interpolate("/controls/gear/brake-right", 1, 0.075);
				} elsif (mod == 1) {
					#
				} elsif (mod == 2) {
					view.decrease();
				} elsif (mod == 3) {
					#
				}
			</script>
		</binding>
		<mod-up>
			<binding>
				<command>nasal</command>
				<script>
					mod = getprop("/input/joysticks/js[0]/thrustmaster-top-gun-afterburner-modifier");
					if (mod == nil or mod == 0) {
						interpolate("/controls/gear/brake-right", 0, 0.075);
					} elsif (mod == 1) {
						#
					} elsif (mod == 2) {
						#
					} elsif (mod == 3) {
						#
					}
				</script>
			</binding>
		</mod-up>
	</button>

	<button n="6"><!-- throttle upper/back -->
		<desc>Modifier Bit 0</desc>
		<repeatable type="bool">false</repeatable>
		<binding>
			<command>nasal</command>
			<script>
				name = "/input/joysticks/js[0]/thrustmaster-top-gun-afterburner-modifier";
				mod = getprop(name);
				if (mod == nil) {
					setprop(name, 1);
				} elsif (mod == 0 or mod == 2) {
					setprop(name, mod + 1);
				}
			</script>
		</binding>
		<mod-up>
			<binding>
				<command>nasal</command>
				<script>
					name = "/input/joysticks/js[0]/thrustmaster-top-gun-afterburner-modifier";
					mod = getprop(name);
					if (mod == nil) {
						setprop(name, 0);
					} elsif (mod == 1 or mod == 3) {
						setprop(name, mod - 1);
					}
				</script>
			</binding>
		</mod-up>
	</button>

	<button n="7"><!-- throttle front -->
		<desc>Modifier Bit 1</desc>
		<repeatable type="bool">false</repeatable>
		<binding>
			<command>nasal</command>
			<script>
				name = "/input/joysticks/js[0]/thrustmaster-top-gun-afterburner-modifier";
				mod = getprop(name);
				if (mod == nil) {
					setprop(name, 2);
				} elsif (mod == 0 or mod == 1) {
					setprop(name, mod + 2);
				}
			</script>
		</binding>
		<mod-up>
			<binding>
				<command>nasal</command>
				<script>
					name = "/input/joysticks/js[0]/thrustmaster-top-gun-afterburner-modifier";
					mod = getprop(name);
					if (mod == nil) {
						setprop(name, 0);
					} elsif (mod == 2 or mod == 3) {
						setprop(name, mod - 2);
					}
				</script>
			</binding>
		</mod-up>
	</button>

	<axis n="5"><!-- View Direction Hat -->
		<desc>View direction; mixture; aileron trim; rudder trim</desc>
		<low>
			<repeatable>true</repeatable>
			<binding>
				<command>nasal</command>
				<script>
					<![CDATA[
					mod = getprop("/input/joysticks/js[0]/thrustmaster-top-gun-afterburner-modifier");
					if (mod == nil or mod == 0) {
						v = getprop("/sim/current-view/view-number");
						if (v == 0 or v == 4) {
							view.panViewDir(1);
						} else {
							view.panViewDir(-1);
						}
					} elsif (mod == 1) {
						controls.adjMixture(-2);
					} elsif (mod == 2) {
						controls.aileronTrim(-0.75);
					} elsif (mod == 3) {
						controls.rudderTrim(0.75);
					}
					]]>
				</script>
			</binding>
		</low>
		<high>
			<repeatable>true</repeatable>
			<binding>
				<command>nasal</command>
				<script>
					<![CDATA[
					mod = getprop("/input/joysticks/js[0]/thrustmaster-top-gun-afterburner-modifier");
					if (mod == nil or mod == 0) {
						v = getprop("/sim/current-view/view-number");
						if (v == 0 or v == 4) {
							view.panViewDir(-1);
						} else {
							view.panViewDir(1);
						}
					} elsif (mod == 1) {
						controls.adjMixture(2);
					} elsif (mod == 2) {
						controls.aileronTrim(0.75);
					} elsif (mod == 3) {
						controls.rudderTrim(-0.75);
					}
					]]></script>
			</binding>
		</high>
	</axis>

	<axis n="6">
		<desc>View direction; prop pitch; elevator trim</desc>
		<low>
			<repeatable>true</repeatable>
			<binding>
				<command>nasal</command>
				<script>
					<![CDATA[
					mod = getprop("/input/joysticks/js[0]/thrustmaster-top-gun-afterburner-modifier");
					if (mod == nil or mod == 0) {
						view.panViewPitch(1);
					} elsif (mod == 1) {
						controls.adjPropeller(1);
					} elsif (mod == 2) {
						controls.elevatorTrim(0.75);
					} elsif (mod == 3) {
						#
					}
					]]>
				</script>
			</binding>
		</low>
		<high>
			<repeatable>true</repeatable>
			<binding>
				<command>nasal</command>
				<script>
					<![CDATA[
					mod = getprop("/input/joysticks/js[0]/thrustmaster-top-gun-afterburner-modifier");
					if (mod == nil or mod == 0) {
						view.panViewPitch(-1);
					} elsif (mod == 1) {
						controls.adjPropeller(-1);
					} elsif (mod == 2) {
						controls.elevatorTrim(-0.75);
					} elsif (mod == 3) {
						#
					}
					]]>
				</script>
			</binding>
		</high>
	</axis>

</PropertyList>
_______________________________________________
Flightgear-devel mailing list
[EMAIL PROTECTED]
http://mail.flightgear.org/mailman/listinfo/flightgear-devel

Reply via email to