Board index FlightGear Support Hardware

Joystick xml codes Library project - open for contributions  Topic is solved

Joysticks, pedals, monitors.

Re: Joystick xml codes Library project - open for contributi

Postby FCar » Sun May 29, 2016 12:28 pm

Saitek Switch Panel Event XML file:

Code: Select all
<PropertyList>

  <name>Saitek Pro Flight Switch Panel</name>
  <name>HOLTEK Saitek Pro Flight Switch Panel</name>
  <debug-events type="bool">true</debug-events>

  <event>
    <name>button-0</name>
    <desc>Battery master</desc>
    <binding>
      <command>property-assign</command>
      <property>/controls/switches/master-bat</property>
      <value>true</value>
    </binding>
    <mod-up>
      <binding>
        <command>property-assign</command>
        <property>/controls/switches/master-bat</property>
        <value>false</value>
      </binding>
    </mod-up>
  </event>

  <event>
    <name>button-1</name>
    <desc>Alternator master</desc>
     <binding>
      <command>property-assign</command>
      <property>/controls/switches/master-alt</property>
      <value>true</value>
    </binding>
    <mod-up>
      <binding>
        <command>property-assign</command>
        <property>/controls/switches/master-alt</property>
        <value>false</value>
      </binding>
    </mod-up>
  </event>

  <event>
    <name>button-2</name>
    <desc>Avionics master</desc>
     <binding>
      <command>property-assign</command>
      <property>/controls/switches/master-avionics</property>
      <value>true</value>
    </binding>
    <mod-up>
      <binding>
        <command>property-assign</command>
        <property>/controls/switches/master-avionics</property>
        <value>false</value>
      </binding>
    </mod-up>
  </event>

  <event>
    <name>button-5</name>
    <desc>Pitot heat</desc>
     <binding>
      <command>property-assign</command>
      <property>/controls/anti-ice/pitot-heat</property>
      <value>true</value>
    </binding>
    <mod-up>
      <binding>
        <command>property-assign</command>
        <property>/controls/anti-ice/pitot-heat</property>
        <value>false</value>
      </binding>
    </mod-up>
  </event>

  <event>
    <name>button-7</name>
    <desc>Instruments light</desc>
     <binding>
      <command>property-assign</command>
      <property>/controls/lighting/instruments-norm</property>
      <value>1.0</value>
    </binding>
    <mod-up>
      <binding>
        <command>property-assign</command>
        <property>/controls/lighting/instruments-norm</property>
        <value>0.0</value>
      </binding>
   </mod-up>
  </event>

  <event>
    <name>button-8</name>
    <desc>Beacon</desc>
     <binding>
      <command>property-assign</command>
      <property>/controls/lighting/beacon</property>
      <value>true</value>
    </binding>
    <mod-up>
      <binding>
        <command>property-assign</command>
        <property>/controls/lighting/beacon</property>
        <value>false</value>
      </binding>
   </mod-up>
  </event>

  <event>
    <name>button-9</name>
    <desc>Navigation lights</desc>
     <binding>
      <command>property-assign</command>
      <property>/controls/lighting/nav-lights</property>
      <value>true</value>
    </binding>
    <mod-up>
      <binding>
        <command>property-assign</command>
        <property>/controls/lighting/nav-lights</property>
        <value>false</value>
      </binding>
   </mod-up>
  </event>

  <event>
    <name>button-266</name>
    <desc>Strobe</desc>
     <binding>
      <command>property-assign</command>
      <property>/controls/lighting/strobe</property>
      <value>true</value>
    </binding>
    <mod-up>
      <binding>
        <command>property-assign</command>
        <property>/controls/lighting/strobe</property>
        <value>false</value>
      </binding>
   </mod-up>
  </event>

  <event>
    <name>button-267</name>
    <desc>Taxi light</desc>
     <binding>
      <command>property-assign</command>
      <property>/controls/lighting/taxi-light</property>
      <value>true</value>
    </binding>
    <mod-up>
      <binding>
        <command>property-assign</command>
        <property>/controls/lighting/taxi-light</property>
        <value>false</value>
      </binding>
   </mod-up>
  </event>

  <event>
    <name>button-268</name>
    <desc>Landing lights</desc>
     <binding>
      <command>property-assign</command>
      <property>/controls/lighting/landing-lights</property>
      <value>true</value>
    </binding>
    <mod-up>
      <binding>
        <command>property-assign</command>
        <property>/controls/lighting/landing-lights</property>
        <value>false</value>
      </binding>
   </mod-up>
  </event>

  <event>
    <name>button-side</name>
    <desc>Gear</desc>
    <binding>
      <command>nasal</command>
      <script>controls.gearDown(1)</script>
    </binding>
    <mod-up>
      <binding>
        <command>nasal</command>
        <script>controls.gearDown(0)</script>
      </binding>
    </mod-up>
  </event>

  <event>
    <name>button-269</name>
    <desc>Magnetos off</desc>
     <binding>
      <command>property-assign</command>
      <property>/controls/switches/magnetos</property>
      <value>0</value>
    </binding>
  </event>

  <event>
    <name>button-270</name>
    <desc>Magnetos right</desc>
     <binding>
      <command>property-assign</command>
      <property>/controls/switches/magnetos</property>
      <value>1</value>
    </binding>
  </event>

  <event>
    <name>button-271</name>
    <desc>Magnetos right</desc>
    <binding>
      <command>property-assign</command>
      <property>/controls/switches/magnetos</property>
      <value>2</value>
    </binding>
  </event>

  <event>
    <name>button-left</name>
    <desc>Magnetos both</desc>
     <binding>
      <command>property-assign</command>
      <property>/controls/switches/magnetos</property>
      <value>3</value>
    </binding>
  </event>

  <event>
    <name>button-right</name>
    <desc>Starter</desc>
     <binding>
      <command>property-assign</command>
      <property>/controls/switches/starter</property>
      <value>true</value>
    </binding>
    <mod-up>
      <binding>
        <command>property-assign</command>
        <property>/controls/switches/starter</property>
        <value>false</value>
      </binding>
    </mod-up>
   </event>


</PropertyList>
FCar
 
Posts: 2
Joined: Sun May 29, 2016 11:24 am

Re: Joystick xml codes Library project - open for contributi

Postby FCar » Sun Jul 17, 2016 9:28 am

In case you cannot recognize the panel at flightgear startup, please check the permissions on the device. Depending on your linux distribution, you may need to add your user to a specific group. In Ubuntu this group is input.
FCar
 
Posts: 2
Joined: Sun May 29, 2016 11:24 am

Re: Joystick xml codes Library project - open for contributi

Postby DF_Hammack » Sat Aug 13, 2016 12:57 pm

-- Saitek Cyborg 3-D Rumble Force --

This thread needs to be turned into a sticky. I JUST found it after nearly abandoning FlightGear as unusable. I was helped by a reader who does not post and wishes to remain anonymous, but he saw my plight and PM'ed me. He got me started down the road to creating my joystick configuration. I was not happy with FlightGear, because it just did not respond in a realistic manner. Honestly, the standard joystick code needs to be re-written to tame sticks to the newer, faster computers, but the reality is this has been a problem from the start. I first tried FlightGear back in 2000, and for this reason I never paid serious attention to FG. Now, with my joystick tamed down, it flies better than X-Plane. Plus, being able to tailor the joystick (to each plane, if you feel like it) makes Flight gear infinitely more configurable than X-Plane!

All of that said, I will share my Joystick file here. It is for the Saitek Cyborg 3D Rumble Force. It is a work in progress, but at this point it controls aileron and elevator trim from the Hat switch, rudder trim from buttons 2 & 5, HUD control on button 3, gear toggle is on button 4 (gear won't retract if there is weight on them), with flaps on 6 & 7, and gear up & down on 8 & 9 (this is a hold over - these two buttons will be re-purposed). The Trigger is a shifter. With the trigger depressed, the Hat controls Look About, button 3 toggles HUD color, and button 4 pauses the sim. I have plans for shifted functions for buttons 6 thru 9. My stick is noisy so there is a wide dead band, axis control (except for the Throttle) is logarithmic for more realism, and sensitivity is tamed to a manageable, more realistic level. The Twist axis is not active (this does not realistically simulate rudder control, auto-coordination is better).
Code: Select all
<?xml version="1.0"?>

<PropertyList>

<name type="string">Saitek Cyborg 3D Rumble Force</name>

<!-- Mod 1 - Script defining Multifunctionality -->
<data>
  <modeTrig type="bool">false</modeTrig>
</data>
  <nasal>
   <script>
            <![CDATA[
            var self = cmdarg().getParent();
            var data = self.getNode("data");
            var modeTrig = data.getNode("modeTrig");
            var trace = func(str) {
            # Uncomment the line below to trace button presses.
            # print("Cyborg xml Model: " ~ model ~ str);
          }
          #
         ]]>
   </script>
  </nasal>
<!-- End Mod 1-->


<axis>
   <!-- Axis 0. Roll left/right -->
    <dead-band type="double">0.15</dead-band>
    <desc type="string">Aileron</desc>
    <binding>
      <command type="string">property-scale</command>
      <property type="string">/controls/flight/aileron</property>
      <factor type="double">0.55</factor>
      <offset type="double">0</offset>
      <power type="int">3</power>
    </binding>
  </axis>

  <axis n="1">
     <!-- Analog axis 1. Pitch back/forward -->
    <dead-band type="double">0.15</dead-band>
    <desc type="string">Elevator</desc>
    <binding>
      <command type="string">property-scale</command>
      <property type="string">/controls/flight/elevator</property>
      <factor type="double">-0.55</factor>
      <offset type="double">0</offset>
      <power type="int">3</power>
    </binding>
  </axis>

  <axis n="2">
       <!--Analog axis 2. Throttle -->
    <desc type="string">Throttle</desc>
    <binding>
      <command type="string">nasal</command>
      <script type="string">controls.throttleAxis();</script>
    </binding>
  </axis>

<!-- Mod 1 - Multifuctionality with the Trigger as the Shift -->
   <!-- Trigger Button -->
   <button n="0">
      <name>Trigger</name>
      <desc>Trigger mode '+Trg';  +Shift: trigger</desc>
      <binding>
         <command>nasal</command>
         <script>
            trace("Trig Bttn bit 0 press");
            modeTrig.setIntValue(1);
         </script>
      </binding>
      <mod-up>
         <binding>
            <command>nasal</command>
            <script>
              trace("Trig Bttn bit 0 release");
               modeTrig.setIntValue(0);
               controls.trigger(0);
            </script>
         </binding>
      </mod-up>
   </button>

   <!-- Axis 4. Hat left/right - Aileron Trim; +Trig, Lateral View-->
   <axis n="4">
      <desc>Aileron Trim; +Trg: Pan View</desc>
      <low>
         <repeatable type="bool">true</repeatable>
      <interval-sec type="double">0.1</interval-sec>
         <binding>
        <command>nasal</command>
           <script>
         <![CDATA[
            if (! modeTrig.getBoolValue()) {
              setprop("controls/flight/aileron-trim",
                (getprop("controls/flight/aileron-trim") -0.0015));
            } else {
              setprop("/sim/current-view/heading-offset-deg",
                (getprop("/sim/current-view/heading-offset-deg") + 4.000));
            } 
          ]]>
           </script>
         </binding>
      </low>
      <high>
         <repeatable type="bool">true</repeatable>
      <interval-sec type="double">0.1</interval-sec>
         <binding>
        <command>nasal</command>
           <script>
          <![CDATA[
            if (! modeTrig.getBoolValue()) {
              setprop("controls/flight/aileron-trim",
                (getprop("controls/flight/aileron-trim") +0.0015));
            } else {
              setprop("/sim/current-view/heading-offset-deg",
                (getprop("/sim/current-view/heading-offset-deg") - 4.000));
            } 
          ]]>
           </script>
         </binding>
      </high>
   </axis>

   <!-- Axis 5. Hat up/down - Elevator Trim; +Trig, Vertical View-->
   <axis n="5">
      <desc>Elevator Trim; +Trg: Tilt view</desc>
      <low>
         <repeatable type="bool">true</repeatable>
      <interval-sec type="double">0.1</interval-sec>
         <binding>
        <command>nasal</command>
           <script>
          <![CDATA[
            if (! modeTrig.getBoolValue()) {
              setprop("controls/flight/elevator-trim",
                (getprop("controls/flight/elevator-trim") +0.002));
            } else {
              setprop("/sim/current-view/pitch-offset-deg",
                (getprop("/sim/current-view/pitch-offset-deg") - 1.500));
            } 
          ]]>
           </script>
         </binding>
      </low>
      <high>
         <repeatable type="bool">true</repeatable>
      <interval-sec type="double">0.1</interval-sec>
         <binding>
        <command>nasal</command>
           <script>
          <![CDATA[
            if (! modeTrig.getBoolValue()) {
              setprop("controls/flight/elevator-trim",
                (getprop("controls/flight/elevator-trim") -0.002));
            } else {
              setprop("/sim/current-view/pitch-offset-deg",
               (getprop("/sim/current-view/pitch-offset-deg") + 1.500));
            } 
          ]]>
           </script>
         </binding>
      </high>
   </axis>
<!-- End Mod 1-->

  <button n="1">
    <desc type="string">Rudder Trim Left</desc>
    <binding>
      <command type="string">nasal</command>
      <script type="string">controls.rudderTrim(-1);</script>
    </binding>
    <repeatable type="double">1</repeatable>
  </button>

<!-- Mod 3 - Landing Gear Toggle; +Trigger, Pauses Sim -->

  <button n="3">
  <name>Button #4</name>
    <desc>Togg Landing Gear; +Trg: Pause </desc>
    <repeatable>false</repeatable>
    <binding>
      <command>nasal</command>
      <script>
      if (modeTrig.getBoolValue()) {
            trace("Trig Button #4 bit 1 press");
        if (getprop("sim/freeze/master") == 0 ) {
          setprop("sim/freeze/master", 1);
        } else {
          setprop("sim/freeze/master", 0);
        }   
        if (getprop("sim/freeze/clock") == 0 ) {
          setprop("sim/freeze/clock", 1);
        } else {
          setprop("sim/freeze/clock", 0);
        }   
         } else {
            trace("     Button #4 bit 1 press");
        controls.gearToggle()
      } 
      </script> 
    </binding>
  </button> 
<!-- End Mod 3 -->
 
<!-- Mod 2 - Assign HUD control to Joystick; +Trigger, Toggles HUD color -->
   <button n="2">
      <name>Button #3</name>
      <desc>HUD Toggle; +Trg HUD Type</desc>
      <binding>
         <command>nasal</command>
         <script>
            trace("Button #3 Bit 2 press ");
        if (modeTrig.getBoolValue()) {
          aircraft.HUD.cycle_color();
          } else {
              aircraft.HUD.cycle_type();
        }
         </script>
         </binding>
   </button>
<!-- End Mod 2 -->

  <button n="4">
    <desc type="string">Rudder Trim Right</desc>
    <binding>
      <command type="string">nasal</command>
      <script type="string">controls.rudderTrim(1);</script>
    </binding>
    <repeatable type="double">1</repeatable>
  </button>

  <button n="5">
    <desc type="string">Flaps Up</desc>
    <repeatable type="string">false</repeatable>
    <binding>
      <command type="string">nasal</command>
      <script type="string">controls.flapsDown(-1);</script>
    </binding>
    <mod-up>
      <binding>
        <command type="string">nasal</command>
        <script type="string">controls.flapsDown(0);</script>
      </binding>
    </mod-up>
  </button>

  <button n="6">
    <desc type="string">Flaps Down</desc>
    <repeatable type="string">false</repeatable>
    <binding>
      <command type="string">nasal</command>
      <script type="string">controls.flapsDown(1);</script>
    </binding>
    <mod-up>
      <binding>
        <command type="string">nasal</command>
        <script type="string">controls.flapsDown(0);</script>
      </binding>
    </mod-up>
  </button>

  <button n="7">
    <desc type="string">Gear Down</desc>
    <repeatable type="string">false</repeatable>
    <binding>
      <command type="string">nasal</command>
      <script type="string">controls.gearDown(1);</script>
    </binding>
    <mod-up>
      <binding>
        <command type="string">nasal</command>
        <script type="string">controls.gearDown(0);</script>
      </binding>
    </mod-up>
  </button>

  <button n="8">
    <desc type="string">Gear Up</desc>
    <repeatable type="string">false</repeatable>
    <binding>
      <command type="string">nasal</command>
      <script type="string">controls.gearDown(-1);</script>
    </binding>
    <mod-up>
      <binding>
        <command type="string">nasal</command>
        <script type="string">controls.gearDown(0);</script>
      </binding>
    </mod-up>
  </button>

</PropertyList>

As I said, this is a work in progress. When I get this file doing what I really want it to do, I will post it again. Then I will start to work re-mapping the keyboard as a joystick complement, not a primary flight control. I hope you enjoy this, and find it useful :)
DF_Hammack
 
Posts: 34
Joined: Fri Aug 05, 2016 11:57 pm
Location: Camden, SC, USA
Callsign: SilverSplash
Version: 2017.2.1
OS: Xubuntu 17.10

Re: Joystick xml codes Library project - open for contributi

Postby Isaak » Fri Aug 26, 2016 8:02 am

FCar wrote in Sun May 29, 2016 12:28 pm:Saitek Switch Panel Event XML file:

Code: Select all
<PropertyList>

  <name>Saitek Pro Flight Switch Panel</name>
  <name>HOLTEK Saitek Pro Flight Switch Panel</name>
  <debug-events type="bool">true</debug-events>

  <event>
    <name>button-0</name>
    <desc>Battery master</desc>
    <binding>
      <command>property-assign</command>
      <property>/controls/switches/master-bat</property>
      <value>true</value>
    </binding>
    <mod-up>
      <binding>
        <command>property-assign</command>
        <property>/controls/switches/master-bat</property>
        <value>false</value>
      </binding>
    </mod-up>
  </event>

  <event>
    <name>button-1</name>
    <desc>Alternator master</desc>
     <binding>
      <command>property-assign</command>
      <property>/controls/switches/master-alt</property>
      <value>true</value>
    </binding>
    <mod-up>
      <binding>
        <command>property-assign</command>
        <property>/controls/switches/master-alt</property>
        <value>false</value>
      </binding>
    </mod-up>
  </event>

  <event>
    <name>button-2</name>
    <desc>Avionics master</desc>
     <binding>
      <command>property-assign</command>
      <property>/controls/switches/master-avionics</property>
      <value>true</value>
    </binding>
    <mod-up>
      <binding>
        <command>property-assign</command>
        <property>/controls/switches/master-avionics</property>
        <value>false</value>
      </binding>
    </mod-up>
  </event>

  <event>
    <name>button-5</name>
    <desc>Pitot heat</desc>
     <binding>
      <command>property-assign</command>
      <property>/controls/anti-ice/pitot-heat</property>
      <value>true</value>
    </binding>
    <mod-up>
      <binding>
        <command>property-assign</command>
        <property>/controls/anti-ice/pitot-heat</property>
        <value>false</value>
      </binding>
    </mod-up>
  </event>

  <event>
    <name>button-7</name>
    <desc>Instruments light</desc>
     <binding>
      <command>property-assign</command>
      <property>/controls/lighting/instruments-norm</property>
      <value>1.0</value>
    </binding>
    <mod-up>
      <binding>
        <command>property-assign</command>
        <property>/controls/lighting/instruments-norm</property>
        <value>0.0</value>
      </binding>
   </mod-up>
  </event>

  <event>
    <name>button-8</name>
    <desc>Beacon</desc>
     <binding>
      <command>property-assign</command>
      <property>/controls/lighting/beacon</property>
      <value>true</value>
    </binding>
    <mod-up>
      <binding>
        <command>property-assign</command>
        <property>/controls/lighting/beacon</property>
        <value>false</value>
      </binding>
   </mod-up>
  </event>

  <event>
    <name>button-9</name>
    <desc>Navigation lights</desc>
     <binding>
      <command>property-assign</command>
      <property>/controls/lighting/nav-lights</property>
      <value>true</value>
    </binding>
    <mod-up>
      <binding>
        <command>property-assign</command>
        <property>/controls/lighting/nav-lights</property>
        <value>false</value>
      </binding>
   </mod-up>
  </event>

  <event>
    <name>button-266</name>
    <desc>Strobe</desc>
     <binding>
      <command>property-assign</command>
      <property>/controls/lighting/strobe</property>
      <value>true</value>
    </binding>
    <mod-up>
      <binding>
        <command>property-assign</command>
        <property>/controls/lighting/strobe</property>
        <value>false</value>
      </binding>
   </mod-up>
  </event>

  <event>
    <name>button-267</name>
    <desc>Taxi light</desc>
     <binding>
      <command>property-assign</command>
      <property>/controls/lighting/taxi-light</property>
      <value>true</value>
    </binding>
    <mod-up>
      <binding>
        <command>property-assign</command>
        <property>/controls/lighting/taxi-light</property>
        <value>false</value>
      </binding>
   </mod-up>
  </event>

  <event>
    <name>button-268</name>
    <desc>Landing lights</desc>
     <binding>
      <command>property-assign</command>
      <property>/controls/lighting/landing-lights</property>
      <value>true</value>
    </binding>
    <mod-up>
      <binding>
        <command>property-assign</command>
        <property>/controls/lighting/landing-lights</property>
        <value>false</value>
      </binding>
   </mod-up>
  </event>

  <event>
    <name>button-side</name>
    <desc>Gear</desc>
    <binding>
      <command>nasal</command>
      <script>controls.gearDown(1)</script>
    </binding>
    <mod-up>
      <binding>
        <command>nasal</command>
        <script>controls.gearDown(0)</script>
      </binding>
    </mod-up>
  </event>

  <event>
    <name>button-269</name>
    <desc>Magnetos off</desc>
     <binding>
      <command>property-assign</command>
      <property>/controls/switches/magnetos</property>
      <value>0</value>
    </binding>
  </event>

  <event>
    <name>button-270</name>
    <desc>Magnetos right</desc>
     <binding>
      <command>property-assign</command>
      <property>/controls/switches/magnetos</property>
      <value>1</value>
    </binding>
  </event>

  <event>
    <name>button-271</name>
    <desc>Magnetos right</desc>
    <binding>
      <command>property-assign</command>
      <property>/controls/switches/magnetos</property>
      <value>2</value>
    </binding>
  </event>

  <event>
    <name>button-left</name>
    <desc>Magnetos both</desc>
     <binding>
      <command>property-assign</command>
      <property>/controls/switches/magnetos</property>
      <value>3</value>
    </binding>
  </event>

  <event>
    <name>button-right</name>
    <desc>Starter</desc>
     <binding>
      <command>property-assign</command>
      <property>/controls/switches/starter</property>
      <value>true</value>
    </binding>
    <mod-up>
      <binding>
        <command>property-assign</command>
        <property>/controls/switches/starter</property>
        <value>false</value>
      </binding>
    </mod-up>
   </event>


</PropertyList>


Hi FCar,

I tried your config file, as I was very pleased to finally see some progress with the switch panel, but FlightGear still won't recognise the switch panel. I fear that your explanation (assigning a user to it) is a bit vague for me too. I work on windows, which I hope is not the problem for it. Have you any idea what I can do? I have my switch panel lying dead for about two years, so making it finally do something would be very nice.

Thanks in advance!
Want to support medical research with your pc? Start Folding at Home and join team FlightGear!
Isaak
 
Posts: 767
Joined: Sat Jun 04, 2011 3:52 pm
Location: Hamme, Belgium
Pronouns: he, him
Callsign: OO-ISA
Version: next
OS: Windows 10

Re: Joystick xml codes Library project - open for contributi

Postby cain071546 » Mon Aug 29, 2016 4:44 pm

I have a weird question.

I own a Saitek Cyborg Evo.
It has 5 buttons and a hat switch.

the center of the 3 buttons resets the original view position no matter what view i am using, or where i have looked (changed view direction) or zoomed.

is there a keyboard shortcut for this?

it is not ctrl + x or y

thanx.
two wrongs never made a right but two wrights made a airplane
cain071546
 
Posts: 111
Joined: Wed Sep 29, 2010 10:55 pm
Location: Washington USA
Callsign: cain
IRC name: cain
Version: 3.2
OS: Linux

Re: Joystick xml codes Library project - open for contributi

Postby EFConrad » Fri Nov 25, 2016 4:15 pm

Thrustmaster T.Flight Rudder Pedals (TFRP) XML

Here's a working joystick XML for the relatively new Thrustmaster rudder pedals:

File should be named "T-Rudder.xml" and dropped into /Input/Joysticks/ThrustMaster

Chances are you already launched FlightGear and discovered that while FlightGear discovers the pedals, the joystick configuration menu can't get the brake axes set up correctly. Be sure to delete the (incorrect) user configuration -- in Windows, the default location will be in ../Users/<your-user-name>/AppData/Roaming/flightgear.org/Input/Joysticks
Delete any "T-Rudder.xml" file found there so that FlightGear will locate and use the correct XML file based on the device name.

I recommend editing the XML file if you want to tweak the pedals' response. The native reversed axes of the brake function doesn't seem to play well with the joystick settings editor -- at least not in Windows. For other OSes, your mileage may very. :D

Code: Select all
<?xml version="1.0"?>

<!--
************************************************************************
* Setup for Thrustmaster T-Flight rudder pedals.
*
* These are USB rudder pedals with toe brakes.  Bindings are as
* follows:
*
* Axis 0 (toe, right pedal): right differential brake
* Axis 1 (toe, left pedal): left differential brake
* Axis 2 (combined sliding pedal action): rudder (and nosewheel)
*
* Settings are similar to the pedals found in the Logitecgh G940 set:
* Axes are numbered right-to-left for brakes.
* Offset and Factor values are negative.
************************************************************************
$Id$
-->

<PropertyList>

 <name>T-Rudder</name>

 <axis n="1">
  <desc>Brake left</desc>
  <binding>
   <command>property-scale</command>
   <property>/controls/gear/brake-left</property>
   <offset>-1.0</offset>
   <factor>-0.5</factor>
  </binding>
 </axis>

 <axis n="0">
  <desc>Brake right</desc>
  <binding>
   <command>property-scale</command>
   <property>/controls/gear/brake-right</property>
   <offset>-1.0</offset>
   <factor>-0.5</factor>
  </binding>
 </axis>

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

</PropertyList>


** Tested on version 2016.4.1 with the default Cessna 172P **
EFConrad
 
Posts: 1
Joined: Fri Nov 25, 2016 3:38 pm
Location: New England
Version: 2016.4.1
OS: Windows 10

Re: Joystick xml codes Library project - open for contributi

Postby N-SCOT » Sun Jan 08, 2017 6:42 pm

A while ago I posted trying to find a code / script for my (non twist) joystick. The goal was stated (wrongly :oops: ) to get something going for nose wheel on ground / rudder in air. What I actually wanted was nose wheel on ground aileron in air.

Anyways, to cut to the chase, the code I was looking for was from Sesbastain Marque. For any interested, it's reposted below.

Code: Select all
<axis n="0">
 <desc>Rudder on ground, aileron in flight</desc>
 <!-- Implemented on-ground taxi patch by Sebastain Marque -->
 <binding>
 <condition>
 <property>/gear/gear/wow</property>
 </condition>
 <command>property-scale</command>
 <property>/controls/flight/rudder</property>
 <squared type="bool">true</squared>
 </binding>
 <desc>Aileron</desc>
 <dead-band type="double">0.02</dead-band>
 <binding>
 <condition>
 <not>
 <property>/gear/gear/wow</property>
 </not>
 </condition>
 <command>property-scale</command>
 <property>/controls/flight/aileron</property>
 <offset type="double">0.0</offset>
 <factor type="double">1.0</factor>
 <tolerance type="double">0.0</tolerance>
 <squared type="bool">true</squared>
 <power type="double">2.0</power>
 </binding>
</axis>


This is definite useful for an old school joystick like mine with no twist axis - I have a CH Combatstick 568. I like it as it's extremely tough and the potentiometers and gimbals inside don't crap out. Mine is 7 years old and still great.

As a result of my searches (caused by my loss of joystick file back then) I made a joystick config file for the model 568. If anyone's interested, it's below. If anyone else has CH products that they have config files for, please do share too.

Code: Select all
<?xml version="1.0"?>

<PropertyList>
  <name type="string">CH COMBATSTICK USB</name>
<axis n="0">
 <desc>Rudder on ground, aileron in flight</desc>
 <!-- Implemented on-ground taxi patch by Sebastain Marque -->
 <binding>
 <condition>
 <property>/gear/gear/wow</property>
 </condition>
 <command>property-scale</command>
 <property>/controls/flight/rudder</property>
 <squared type="bool">true</squared>
 </binding>
 <desc>Aileron</desc>
 <dead-band type="double">0.02</dead-band>
 <binding>
 <condition>
 <not>
 <property>/gear/gear/wow</property>
 </not>
 </condition>
 <command>property-scale</command>
 <property>/controls/flight/aileron</property>
 <offset type="double">0.0</offset>
 <factor type="double">1.0</factor>
 <tolerance type="double">0.0</tolerance>
 <squared type="bool">true</squared>
 <power type="double">2.0</power>
 </binding>
</axis>
  <axis n="1">
    <desc type="string">Elevator</desc>
    <binding>
      <command type="string">property-scale</command>
      <property type="string">/controls/flight/elevator</property>
      <factor type="double">-1</factor>
      <offset type="double">0</offset>
    </binding>
  </axis>
  <axis n="2">
    <desc type="string">Throttle</desc>
    <binding>
      <command type="string">nasal</command>
      <script type="string">controls.throttleAxis();</script>
    </binding>
  </axis>
  <axis n="3">
    <desc type="string">View (horizontal)</desc>
    <low>
      <binding>
        <command type="string">nasal</command>
        <script type="string">setprop("/sim/current-view/goal-heading-offset-deg", getprop("/sim/current-view/goal-heading-offset-deg") + 30);</script>
      </binding>
    </low>
    <high>
      <binding>
        <command type="string">nasal</command>
        <script type="string">setprop("/sim/current-view/goal-heading-offset-deg", getprop("/sim/current-view/goal-heading-offset-deg") - 30);</script>
      </binding>
    </high>
  </axis>
  <axis n="4">
    <desc type="string">View (vertical)</desc>
    <low>
      <binding>
        <command type="string">nasal</command>
        <script type="string">setprop("/sim/current-view/goal-pitch-offset-deg", getprop("/sim/current-view/goal-pitch-offset-deg") - 20);</script>
      </binding>
    </low>
    <high>
      <binding>
        <command type="string">nasal</command>
        <script type="string">setprop("/sim/current-view/goal-pitch-offset-deg", getprop("/sim/current-view/goal-pitch-offset-deg") + 20);</script>
      </binding>
    </high>
  </axis>
  <button>
    <desc type="string">Trigger</desc>
    <repeatable type="string">false</repeatable>
    <binding>
      <command type="string">nasal</command>
      <script type="string">controls.trigger(1);</script>
    </binding>
    <mod-up>
      <binding>
        <command type="string">nasal</command>
        <script type="string">controls.trigger(0);</script>
      </binding>
    </mod-up>
  </button>
  <button n="1">
    <desc type="string">Brakes</desc>
    <repeatable type="string">false</repeatable>
    <binding>
      <command type="string">nasal</command>
      <script type="string">controls.applyBrakes(1);</script>
    </binding>
    <mod-up>
      <binding>
        <command type="string">nasal</command>
        <script type="string">controls.applyBrakes(0);</script>
      </binding>
    </mod-up>
  </button>
  <button n="2">
    <desc type="string">Gear Up</desc>
    <repeatable type="string">false</repeatable>
    <binding>
      <command type="string">nasal</command>
      <script type="string">controls.gearDown(-1);</script>
    </binding>
    <mod-up>
      <binding>
        <command type="string">nasal</command>
        <script type="string">controls.gearDown(0);</script>
      </binding>
    </mod-up>
  </button>
  <button n="4">
    <desc type="string">Propeller Fine</desc>
    <binding>
      <command type="string">nasal</command>
      <script type="string">controls.adjPropeller(1);</script>
    </binding>
    <repeatable type="double">1</repeatable>
  </button>
  <button n="5">
    <desc type="string">Mixture Rich</desc>
    <binding>
      <command type="string">nasal</command>
      <script type="string">controls.adjMixture(1);</script>
    </binding>
    <repeatable type="double">1</repeatable>
  </button>
  <button n="6">
    <desc type="string">Propeller Coarse</desc>
    <binding>
      <command type="string">nasal</command>
      <script type="string">controls.adjPropeller(-1);</script>
    </binding>
    <repeatable type="double">1</repeatable>
  </button>
  <button n="7">
    <desc type="string">Mixture Lean</desc>
    <binding>
      <command type="string">nasal</command>
      <script type="string">controls.adjMixture(-1);</script>
    </binding>
    <repeatable type="double">1</repeatable>
  </button>
</PropertyList>


Cheers, G
Gary Brown, aka N-SCOT
Favorite Aircraft: Military
Favorite FG activity: Livery generation
N-SCOT
 
Posts: 178
Joined: Sun Apr 19, 2009 3:17 pm
Location: Gainesville, Florida. Home of the "Fighting' Gators"!
Callsign: N-SCOT
Version: 2020.1.2
OS: OSX High Sierra

Re: Joystick xml codes Library project - open for contributi

Postby pommesschranke » Fri Jun 23, 2017 5:39 pm

Saitek Saitek Pro Flight Yoke:
I use default config exept
Code: Select all
 <factor type="double">0.5</factor>

for aileron & elevator.

Thrustmaster T-Rudder
Code: Select all
<PropertyList>
  <name type="string">Thrustmaster T-Rudder</name>
  <axis>
    <desc type="string">Brake Right</desc>
    <binding>
      <command type="string">property-scale</command>
      <property type="string">/controls/gear/brake-right</property>
      <factor type="double">-1.0</factor>
      <offset type="double">0</offset>
    </binding>
  </axis>
  <axis n="1">
    <desc type="string">Brake Left</desc>
    <binding>
      <command type="string">property-scale</command>
      <property type="string">/controls/gear/brake-left</property>
      <factor type="double">-1.0</factor>
      <offset type="double">0</offset>
    </binding>
  </axis>
  <axis n="2">
    <desc type="string">Rudder</desc>
    <binding>
      <command type="string">property-scale</command>
      <property type="string">/controls/flight/rudder</property>
      <factor type="double">0.5</factor>
      <offset type="double">0</offset>
    </binding>
  </axis>
  <button>
    <desc type="string">Brakes</desc>
    <repeatable type="string">false</repeatable>
    <binding>
      <command type="string">nasal</command>
      <script type="string">controls.applyBrakes(1);</script>
    </binding>
    <mod-up>
      <binding>
        <command type="string">nasal</command>
        <script type="string">controls.applyBrakes(0);</script>
      </binding>
    </mod-up>
  </button>
 
</PropertyList>
pommesschranke
 
Posts: 1117
Joined: Sat Apr 27, 2013 8:58 pm
Location: EDLM & LJCE
Callsign: d-laser
IRC name: laserman
Version: git
OS: Linux Kubuntu 22.04

Re: Joystick xml codes Library project - open for contributi

Postby cogliostro » Tue Nov 21, 2017 4:36 am

Anyone know how to map the Carburetor Heater to a button? It doesn't show in the list of functions to map in the Joystick Configuration.
cogliostro
 
Posts: 1
Joined: Tue Nov 21, 2017 4:32 am

Re: Joystick xml codes Library project - open for contributi

Postby Johan G » Sun Nov 26, 2017 10:50 pm

You will probably have to add that manually (by editing your joysticks configuration file). And it will probably only work for some aircraft.
Low-level flying — It's all fun and games till someone looses an engine. (Paraphrased from a YouTube video)
Improving the Dassault Mirage F1 (Wiki, Forum, GitLab. Work in slow progress)
Some YouTube videos
Johan G
Moderator
 
Posts: 6625
Joined: Fri Aug 06, 2010 6:33 pm
Location: Sweden
Callsign: SE-JG
IRC name: Johan_G
Version: 2020.3.4
OS: Windows 10, 64 bit

Re: Joystick xml codes Library project - open for contributi

Postby simulant » Sat Mar 30, 2019 11:32 pm

FCar wrote in Sun May 29, 2016 12:28 pm:Saitek Switch Panel Event XML file:

Code: Select all
<PropertyList>

  <name>Saitek Pro Flight Switch Panel</name>
  <name>HOLTEK Saitek Pro Flight Switch Panel</name>
  <debug-events type="bool">true</debug-events>

  <event>
    <name>button-0</name>


I want to make saitek radio and multipanel work. They are also HID devives.

1. Should they show up in the list of joysticks in FlightGear? Is the switch panel there?

2. Will an appropiate .xml file make it work or is something else needed?

3. How do I find out the name of the events?

Best regards,
simulant.
simulant
 
Posts: 10
Joined: Mon Mar 25, 2019 5:52 pm

Re: Joystick xml codes Library project - open for contributi

Postby StuartC » Sun Mar 31, 2019 9:38 am

I did a configuration a Helicopter setup for the Heli Kit usit

this:-
Image

its the entry level of specific helicopter setups. FG has issues with some of it, but the following configuration download will get most of it working:-
http://www.fguk.me/hangar/download/10-o ... figuration
StuartC
 
Posts: 3168
Joined: Fri Jun 18, 2010 9:18 pm
Location: Arse end of the Universe
Callsign: WF01
Version: 2019.1
OS: W10 64 bit

Re: Joystick xml codes Library project - open for contributi

Postby msalama » Sat Jun 29, 2019 10:25 am

This is my quick and dirty ghetto setup for a T-Hotas, a Speedlink Black Widow and a Saitek Pro Rudder pedal set. It's a triple-control setup, since that makes it possible to use the T-H throttle for brakes and I get a bunch of extra buttons too.

TFlight-Hotas.xml:

Code: Select all
<?xml version="1.0"?>

<PropertyList>
  <name type="string">T.Flight Hotas X</name>
  <nasal>
      <script>
         <![CDATA[
         setprop("/input/joysticks/js[0]/t-flight-hotas-x-modifier1", 0);
         setprop("/input/joysticks/js[0]/t-flight-hotas-x-modifier2", 0);
         ]]>
      </script>
    <module type="string">__js1</module>
  </nasal>
  <axis n="0">
    <desc type="string">Aileron</desc>
    <binding>
      <command type="string">property-scale</command>
      <property type="string">/controls/flight/aileron</property>
     <dead-band type="double">0.00</dead-band>
      <factor type="double">1.0</factor>
      <power type="double">3.0</power>
     <offset type="double">0</offset>
    </binding>
  </axis>
  <axis n="1">
    <desc type="string">Elevator</desc>
    <binding>
      <command type="string">property-scale</command>
      <property type="string">/controls/flight/elevator</property>
     <dead-band type="double">0.00</dead-band>
      <factor type="double">-1.0</factor>
      <power type="double">3.0</power>
     <offset type="double">0</offset>
    </binding>
  </axis>
  <axis n="2">
     <desc type="string">Brakes</desc>
     <binding>
      <command type="string">property-scale</command>
      <property type="string">/controls/gear/brake-left</property>
      <factor type="double">0.5</factor>
      <offset type="double">1</offset>
    </binding>
     <binding>
      <command type="string">property-scale</command>
      <property type="string">/controls/gear/brake-right</property>
      <factor type="double">0.5</factor>
      <offset type="double">1</offset>
    </binding>
  </axis>
  <axis n="4">
     <desc>Move viewpoint back/forth</desc>
     <dead-band type="double">0.05</dead-band>
     <binding>
        <command>property-scale</command>
        <property>/sim/current-view/z-offset-m</property>
        <factor type="double">0.233</factor>
        <offset type="double">5.4</offset>
     </binding>
  </axis>
  <axis n="6">
    <desc type="string">Aileron / Rudder Trim inc.</desc>
    <low>
      <binding>
        <command type="string">nasal</command>
        <script type="string">
         mod1 = getprop("/input/joysticks/js[0]/t-flight-hotas-x-modifier1");
         if(mod1==0) {
            controls.aileronTrim(-1);
         }
         elsif(mod1==1) {
            controls.rudderTrim(-1);
         }
      </script>
      </binding>
      <repeatable type="bool">true</repeatable>
    </low>
    <high>
      <binding>
        <command type="string">nasal</command>
        <script type="string">
         mod1 = getprop("/input/joysticks/js[0]/t-flight-hotas-x-modifier1");
         if(mod1==0) {
            controls.aileronTrim(1);
         }
         elsif(mod1==1) {
            controls.rudderTrim(1);
         }
      </script>
      </binding>
      <repeatable type="bool">true</repeatable>
    </high>
  </axis>
  <axis n="7">
    <desc type="string">Elevator Trim inc.</desc>
    <low>
      <binding>
        <command type="string">nasal</command>
        <script type="string">controls.elevatorTrim(-1);</script>
      </binding>
      <repeatable type="bool">true</repeatable>
    </low>
    <high>
      <binding>
        <command type="string">nasal</command>
        <script type="string">controls.elevatorTrim(1);</script>
      </binding>
      <repeatable type="bool">true</repeatable>
    </high>
  </axis>
 <button n="0">
    <desc>Toggle landing lights</desc>
    <binding>
      <command>property-toggle</command>
      <property>/controls/lighting/landing-lights</property>
    </binding>
 </button>
 <button n="1">
    <desc>Toggle taxi lights</desc>
    <binding>
      <command>property-toggle</command>
      <property>/controls/lighting/taxi-light</property>
    </binding>
 </button>
  <button n="4">
    <desc>Toggle beacon lights</desc>
    <binding>
      <command>property-toggle</command>
      <property>/controls/lighting/beacon</property>
    </binding>
 </button>
  <button n="5">
    <desc>Toggle strobe lights</desc>
    <binding>
      <command>property-toggle</command>
      <property>/controls/lighting/strobe</property>
    </binding>
 </button>
  <button n="6">
    <desc>Toggle navigation lights</desc>
    <binding>
      <command>property-toggle</command>
      <property>/controls/lighting/nav-lights</property>
    </binding>
 </button>
  <button n="2">
    <desc type="string">Propeller Fine / Mixture Rich</desc>
    <repeatable type="bool">true</repeatable>
    <binding>
      <command type="string">nasal</command>
      <script type="string">
        mod1 = getprop("/input/joysticks/js[0]/t-flight-hotas-x-modifier1");
       if(mod1==0) {
         controls.adjPropeller(1);
      }
      elsif(mod1==1) {
           controls.adjMixture(10);
      }
     </script>
    </binding>
  </button>
  <button n="3">
    <desc type="string">Propeller Coarse / Mixture Lean</desc>
    <repeatable type="bool">true</repeatable>
    <binding>
      <command type="string">nasal</command>
      <script type="string">
       mod1 = getprop("/input/joysticks/js[0]/t-flight-hotas-x-modifier1");
       if(mod1==0) {    
         controls.adjPropeller(-1);
      }
      elsif(mod1==1) {
            controls.adjMixture(-10);
      }
     </script>
    </binding>
  </button>
  <button n="7">
    <desc type="string">FGCom PTT</desc>
    <repeatable type="string">false</repeatable>
    <binding>
      <command type="string">nasal</command>
      <script type="string">controls.ptt(1);</script>
    </binding>
    <mod-up>
      <binding>
        <command type="string">nasal</command>
        <script type="string">controls.ptt(0);</script>
      </binding>
    </mod-up>
  </button>
  <button n="10">
    <desc type="string">Spoilers Deploy</desc>
    <repeatable type="string">false</repeatable>
    <binding>
      <command type="string">nasal</command>
      <script type="string">controls.stepSpoilers(1);</script>
    </binding>
    <mod-up>
      <binding>
        <command type="string">nasal</command>
        <script type="string">controls.stepSpoilers(0);</script>
      </binding>
    </mod-up>
  </button>
  <button n="11">
    <desc type="string">Spoilers Retract</desc>
    <repeatable type="string">false</repeatable>
    <binding>
      <command type="string">nasal</command>
      <script type="string">controls.stepSpoilers(-1);</script>
    </binding>
    <mod-up>
      <binding>
        <command type="string">nasal</command>
        <script type="string">controls.stepSpoilers(0);</script>
      </binding>
    </mod-up>
  </button>
   <!-- Throttle Button labeled R2(9) -->
   <button n="8">
      <desc>Button R2(9): Modifier 1</desc>
      <repeatable type="bool">false</repeatable>
      <binding>
         <command>nasal</command>
         <script>
            setprop("/input/joysticks/js[0]/t-flight-hotas-x-modifier1", 1);
         </script>
      </binding>
      <mod-up>
         <binding>
            <command>nasal</command>
            <script>
               setprop("/input/joysticks/js[0]/t-flight-hotas-x-modifier1", 0);
            </script>
         </binding>
      </mod-up>
   </button>
   <!-- Throttle Button labeled L2(10) -->
   <button n="9">
      <desc>Button L2(10): Modifier2</desc>
      <repeatable type="bool">false</repeatable>
      <binding>
         <command>nasal</command>
         <script>
            setprop("/input/joysticks/js[0]/t-flight-hotas-x-modifier2", 1);
         </script>
      </binding>
      <mod-up>
         <binding>
            <command>nasal</command>
            <script>
               setprop("/input/joysticks/js[0]/t-flight-hotas-x-modifier2", 0);
            </script>
         </binding>
      </mod-up>
   </button>
</PropertyList>


SpeedLink-Black-Widow.xml:

Code: Select all
<?xml version="1.0"?>

<PropertyList>
  <name type="string">SpeedLink Black Widow</name>
  <axis n="2">
    <desc type="string">Throttle (all)</desc>
    <binding>
      <command type="string">nasal</command>
      <script type="string">controls.throttleAxis();</script>
    </binding>
  </axis>
  <axis n="3">
     <desc>Move viewpoint up/down</desc>
     <dead-band type="double">0.05</dead-band>
     <binding>
        <command>property-scale</command>
        <property>/sim/current-view/y-offset-m</property>
        <factor type="double">0.233</factor>
        <offset type="double">2.766</offset>
     </binding>
  </axis>
  <axis n="6">
    <desc type="string">View (horizontal)</desc>
    <low>
      <binding>
        <command type="string">nasal</command>
        <script type="string">setprop("/sim/current-view/goal-heading-offset-deg", getprop("/sim/current-view/goal-heading-offset-deg") + 2);</script>
      </binding>
      <repeatable type="bool">true</repeatable>
    </low>
    <high>
      <binding>
        <command type="string">nasal</command>
        <script type="string">setprop("/sim/current-view/goal-heading-offset-deg", getprop("/sim/current-view/goal-heading-offset-deg") - 2);</script>
      </binding>
      <repeatable type="bool">true</repeatable>
    </high>
  </axis>
  <axis n="7">
    <desc type="string">View (vertical)</desc>
    <low>
      <binding>
        <command type="string">nasal</command>
        <script type="string">setprop("/sim/current-view/goal-pitch-offset-deg", getprop("/sim/current-view/goal-pitch-offset-deg") - 1);</script>
      </binding>
      <repeatable type="bool">true</repeatable>
    </low>
    <high>
      <binding>
        <command type="string">nasal</command>
        <script type="string">setprop("/sim/current-view/goal-pitch-offset-deg", getprop("/sim/current-view/goal-pitch-offset-deg") + 1);</script>
      </binding>
      <repeatable type="bool">true</repeatable>
    </high>
  </axis>
  <button n="0">
    <desc>Toggle pitot heater</desc>
    <binding>
      <command>property-toggle</command>
      <property>/controls/anti-ice/pitot-heat</property>
    </binding> 
  </button>
  <button n="3">
    <desc>Toggle carburetor heater</desc>
    <binding>
      <command>property-toggle</command>
      <property>/controls/engines/current-engine/carb-heat</property>
    </binding> 
  </button>
  <button n="1">
    <desc type="string">FGCom PTT</desc>
    <repeatable type="string">false</repeatable>
    <binding>
      <command type="string">nasal</command>
      <script type="string">controls.ptt(1);</script>
    </binding>
    <mod-up>
      <binding>
        <command type="string">nasal</command>
        <script type="string">controls.ptt(0);</script>
      </binding>
    </mod-up>
  </button>
  <button n="2">
    <desc type="string">Custom</desc>
    <repeatable type="bool">true</repeatable>
    <binding>
      <command type="string">nasal</command>
      <script type="string">
            setprop("/sim/current-view/view-number", 0);
            view.resetView();
         </script>
      <module type="string">__js2</module>
      <offset type="double">1</offset>
    </binding>
    <mod-up>
      <binding n="0" type="string">
      </binding>
      <binding n="0">
        <offset type="double">1</offset>
      </binding>
    </mod-up>
  </button>
  <button n="4">
    <desc type="string">Gear Down</desc>
    <binding>
      <command type="string">nasal</command>
      <script type="string">controls.gearDown(1);</script>
    </binding>
    <repeatable type="double">0</repeatable>
  </button>
  <button n="5">
    <desc type="string">Gear Up</desc>
    <binding>
      <command type="string">nasal</command>
      <script type="string">controls.gearDown(-1);</script>
    </binding>
    <repeatable type="double">0</repeatable>
  </button>
  <button n="6">
    <desc type="string">Flaps Down</desc>
    <binding>
      <command type="string">nasal</command>
      <script type="string">controls.flapsDown(1);</script>
    </binding>
    <repeatable type="double">0</repeatable>
  </button>
  <button n="7">
    <desc type="string">Flaps Up</desc>
    <binding>
      <command type="string">nasal</command>
      <script type="string">controls.flapsDown(-1);</script>
    </binding>
    <repeatable type="double">0</repeatable>
  </button>
</PropertyList>


Saitek-Pro-Flight-Rudder-Pedals.xml:

Code: Select all
<?xml version="1.0"?>

<PropertyList>
  <name type="string">Saitek Pro Flight Rudder Pedals</name>
  <axis>
    <desc type="string">Brake Left</desc>
    <binding>
      <command type="string">property-scale</command>
      <property type="string">/controls/gear/brake-left</property>
      <factor type="double">0.5</factor>
      <offset type="double">1</offset>
    </binding>
  </axis>
  <axis n="1">
    <desc type="string">Brake Right</desc>
    <binding>
      <command type="string">property-scale</command>
      <property type="string">/controls/gear/brake-right</property>
      <factor type="double">0.5</factor>
      <offset type="double">1</offset>
    </binding>
  </axis>
  <axis n="3">
    <desc type="string">Rudder</desc>
    <binding>
      <command type="string">property-scale</command>
      <property type="string">/controls/flight/rudder</property>
     <dead-band type="double">0.00</dead-band>
      <factor type="double">1.0</factor>
      <power type="double">3.0</power>
     <offset type="double">0</offset>
    </binding>
  </axis>
</PropertyList>
msalama
 
Posts: 52
Joined: Tue Jun 18, 2019 5:44 am

Re: Joystick xml codes Library project - open for contributi

Postby leechpool » Tue Sep 03, 2019 3:46 pm

I found a way to do variable rate of change when a button is held down, by using a property variable to record how many iterations the button code had gone through when repeating. I'm sure this has been done many times before, but I couldn't find much when I was trying to do it....
COUNT keeps track of the number of times the button repeat iteration has looped. The COUNT < 40 controls the point at which the rate of change occurs and the +0.2 and +0.8 control the initial and second rate of change.

Code: Select all
<button n="13">
<desc>adjust view side to side</desc>
  <repeatable type="bool">true</repeatable>
  <binding>
   <command>nasal</command>
           <script>
   <![CDATA[
      H = getprop("/sim/current-view/goal-heading-offset-deg");
      COUNT = getprop("/input/joysticks/js/button_13");
      if (COUNT < 40) {H = H + 0.2;}
      else {H = H + 0.8;}
      setprop("/sim/current-view/goal-heading-offset-deg", H );
      setprop("/input/joysticks/js/button_13", COUNT + 1);
   ]]>
     </script>
  </binding>

   <mod-up>
      <binding>
         <command>nasal</command>
         <script>
            setprop("/input/joysticks/js/button_13", 0);
         </script>
      </binding>
   </mod-up>
</button>



Another slightly more complicated example I created to adjust the autopilot target heading....
COUNT again keeps track of the number of times the button repeat iteration has looped. During the slow change phase (COUNT < 60), I use the expression int( (int((COUNT / 10))) / (COUNT / 10) ) to return zero unless COUNT is a multiple of 10, so it only increments the property every 10 cycles.
The mod-up "reset" sets COUNT to 10 so that there is no pause when you initially press the button before the first increment occurs.
During the fast change phase the popup tip only displays the two most significant bearing digits (##0), so the rapid change is easier to follow, but the actual bearing is still going up 1 at a time in the background. I found this enables me to still time the stop quite near the desired heading to within about 10 or less degrees, then a few single clicks refines the setting.

Code: Select all
<button n="9">
<desc>change AP target bearing</desc>
  <repeatable type="bool">true</repeatable>
  <binding>
   <command>nasal</command>
           <script>
   <![CDATA[
      H = getprop("/autopilot/settings/heading-bug-deg");
      COUNT = getprop("/input/joysticks/js/button_8");
      if (COUNT < 60) {
      H = H + int( (int((COUNT / 10))) / (COUNT / 10) );
      gui.popupTip(sprintf("AP Target Heading: %.0f", H));
      }
      else
      {
      H = H + 1;
      gui.popupTip(sprintf("AP Target Heading: %.0f", 10*int(H/10)));
      }

      if (H < 0) {H = H + 360}
      if (H > 360) {H = H - 360}
      setprop("/autopilot/settings/heading-bug-deg", H );

      setprop("/input/joysticks/js/button_8", COUNT + 1);
   ]]>
     </script>
  </binding>

   <mod-up>
      <binding>
         <command>nasal</command>
         <script>

            setprop("/input/joysticks/js/button_8", 10);
       gui.popupTip(sprintf("AP Target Heading: %.0f", H));
         </script>
      </binding>
   </mod-up>
</button>


Hope this might help someone getting to grips with joystick xml.
:D
leechpool
 
Posts: 21
Joined: Thu Aug 01, 2019 9:17 am

Re: Joystick xml codes Library project - open for contributi

Postby Kafovofa » Sun Sep 22, 2019 10:37 pm

This maps both rudder and brakes to the trigger buttons on my Logitech F310 controller. maxBrkf and brkStr_deadzone are the most important variables for the left and right brake setup. Maximum brake force and rudder (the variable rpos) in game are 1. Brakes will not begin to be applied until the trigger is depressed to the point specified by brkStr_deadzone (a value between 0 and 1). The maximum brake force when input from the controller can be capped with maxBrkf (any value between 0 and 1). The linear function expressed as "((((math.mod(1, (1 - brkStr_deadzone))) * absRpos + (1 - math.mod(1, 1-brkStr_deadzone))) * 100) - 99 )" that defines brkf is the brakeforce that is fed to the gear, it always starts with an output of 0 and scales up to 1. The next line multiplies this output by maxBrkf to scale the result to the maximum brakeforce specified/desired instead of 1. Any cleanup is appreciated. Currently it works well with most taildraggers.

Code: Select all
 
 <axis n="2">
    <desc type="string">Rudder</desc>
    <binding>
      <command type="string">property-scale</command>
      <property type="string">/controls/flight/rudder</property>
      <factor type="double">-1</factor>
      <offset type="double">0</offset>
    </binding>
   <binding>
          <command>nasal</command>
          <script>
        <!--<![CDATA[-->
         var rpos = getprop("/controls/flight/rudder"); <!--rudder position-->
         var absRpos = math.abs(rpos);
         var maxBrkf = 0.5;
         var gsp = getprop("/velocities/groundspeed-kt"); <!--ground spoeed in kt-->
         var brkStr_deadzone = 0.7; <!--deadzone before brake steering occurs-->
         var gsp_debugtip = 0; <!--debug tooltips-->
         var rpos_debugtip = 0;
         var brkf_debugtip = 0;
         if(rpos_debugtip == 1){ <!--debugtip-->
            gui.popupTip(sprintf("rpos: %.2f", rpos));
         }
         if (absRpos > brkStr_deadzone ){
            if(gsp > 34.0){            <!--speedlimit for brake steering-->
               setprop("/controls/gear/brake-right", 0);
               setprop("/controls/gear/brake-left", 0);
               if(gsp_debugtip == 1){ <!--debugtip-->
                  gui.popupTip(sprintf("gsp over 36: %.2f", getprop("/velocities/groundspeed-kt"), "kts"));
               }
               
            }else{                     <!--brake steering-->
               if(gsp > 0.1){
                  if(gsp_debugtip == 1){ <!--debugtip-->
                     gui.popupTip(sprintf("ground speed under 36: %.2f", getprop("/velocities/groundspeed-kt"), "kts"));
                  }
               
                  var brkf = ((((math.mod(1, (1 - brkStr_deadzone))) * absRpos + (1 - math.mod(1, 1-brkStr_deadzone))) * 100) - 99 );  <!--scales brake forces between the deadzone and maximum rudder-->
                  brkf = math.abs(brkf * maxBrkf); <!-- allows maximum brakeforce to be controlled by percentage-->
                  if(brkf_debugtip == 1){ <!--debugtip-->
                     gui.popupTip(sprintf("brkf: %.2f", brkf));
                  }
                  if(maxBrkf > brkf){ <!--just to make sure nothing exceeds the maximum-->
                     if(rpos > 0){
                        setprop("/controls/gear/brake-right", brkf);
                        <!--gui.popupTip(sprintf("Right Brake: %3.0f", brkf * 100));-->
                     }else{
                        <!--gui.popupTip(sprintf("Left Brake: %3.0f", brkf * 100));-->
                        setprop("/controls/gear/brake-left", brkf);
                     }
                  }else{
                     if(rpos > 0){
                        setprop("/controls/gear/brake-right", 0);
                        <!--gui.popupTip(sprintf("Right Brake: %3.0f", 0));-->
                     }else{
                        setprop("/controls/gear/brake-left", 0);
                        <!--gui.popupTip(sprintf("Left Brake: %3.0f", 0));-->
                     }
                  }
               }
            }
         }else{ <!--releases brakes when rudder is in the deadzone-->
            setprop("/controls/gear/brake-left", 0);
            setprop("/controls/gear/brake-right", 0);
         }
            <!--]]>-->
          </script>
       
    </binding>
  </axis>
-Kafovofa
User avatar
Kafovofa
 
Posts: 40
Joined: Tue Jul 02, 2019 3:47 am
Location: Manchester, NH
Callsign: D-MVXB
Version: Stable
OS: Windows 10

PreviousNext

Return to Hardware

Who is online

Users browsing this forum: No registered users and 3 guests