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 SurferTim » Sat Nov 16, 2019 12:02 am

Joystick file for Bodner BU0836. It has the 8 axis and 12 digital entries. Only a few assigned as examples.
In /Input/Joysticks , I created a folder named "Bodnar". In that folder goes this file named BU0836.xml
Code: Select all
<?xml version="1.0"?>

<PropertyList>
  <name type="string">Leo Bodnar Electronics BU0836 Interface</name>
  <axis>
    <desc type="string">Aileron</desc>
    <binding>
      <command type="string">property-scale</command>
      <property type="string">/controls/flight/aileron</property>
      <factor type="double">1</factor>
      <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>
      <factor type="double">1</factor>
      <offset type="double">0</offset>
    </binding>
  </axis>
  <axis n="2">
    <desc type="string">Axis 2</desc>
    <binding>
      <command type="string">property-scale</command>
      <property type="string"></property>
      <setting type="double">0</setting>
    </binding>
    <low>
      <binding>
      </binding>
    </low>
  </axis>
  <axis n="3">
    <desc type="string">Axis 3</desc>
    <binding>
      <command type="string">property-scale</command>
      <property type="string"></property>
      <setting type="double">0</setting>
    </binding>
    <low>
      <binding>
      </binding>
    </low>
  </axis>
  <axis n="4">
    <desc type="string">Axis 4</desc>
    <binding>
      <command type="string">property-scale</command>
      <property type="string"></property>
    </binding>
    <low>
      <binding>
      </binding>
    </low>
  </axis>
  <axis n="5">
    <desc type="string">Axis 5</desc>
    <binding>
      <command type="string">property-scale</command>
      <property type="string"></property>
    </binding>
    <low>
      <binding>
      </binding>
    </low>
  </axis>
  <axis n="6">
    <desc type="string">Axis 6</desc>
    <binding>
      <command type="string">property-scale</command>
      <property type="string"></property>
    </binding>
    <low>
      <binding>
      </binding>
    </low>
  </axis>
  <axis n="7">
    <desc type="string">Axis 7</desc>
    <binding>
      <command type="string">property-scale</command>
      <property type="string"></property>
    </binding>
    <low>
      <binding>
      </binding>
    </low>
  </axis>
  <button>
    <desc type="string">View Cycle Forwards</desc>
    <binding>
      <command type="string">nasal</command>
      <script type="string">view.stepView(1);</script>
    </binding>
    <repeatable type="double">0</repeatable>
  </button>
  <button n="1">
    <desc type="string">Custom</desc>
    <binding>
      <command type="string">nasal</command>
      <script type="string">setprop("/controls/lighting/flight-comp", 1);</script>
    </binding>
    <mod-up>
      <binding>
        <command type="string">nasal</command>
        <script type="string">setprop("/controls/lighting/flight-comp", 0);</script>
      </binding>
    </mod-up>
  </button>
  <button n="2">
    <desc type="string">Custom</desc>
    <binding>
      <command type="string">property-toggle</command>
      <property type="string">/controls/lighting/flight-comp</property>
    </binding>
    <mod-up>
      <binding>
      </binding>
    </mod-up>
  </button>
  <button n="3">
    <desc type="string">Custom</desc>
    <binding>
      <command type="string">nasal</command>
      <script type="string"></script>
      <module type="string">__js2</module>
    </binding>
    <mod-up>
      <binding>
      </binding>
    </mod-up>
  </button>
  <button n="4">
    <desc type="string">Custom</desc>
    <binding>
      <command type="string">nasal</command>
      <script type="string"></script>
      <module type="string">__js2</module>
    </binding>
    <mod-up>
      <binding>
      </binding>
    </mod-up>
  </button>
  <button n="5">
    <desc type="string">Custom</desc>
    <binding>
      <command type="string">nasal</command>
      <script type="string"></script>
      <module type="string">__js2</module>
    </binding>
    <mod-up>
      <binding>
      </binding>
    </mod-up>
  </button>
  <button n="6">
    <desc type="string">Custom</desc>
    <binding>
      <command type="string">nasal</command>
      <script type="string"></script>
      <module type="string">__js2</module>
    </binding>
    <mod-up>
      <binding>
      </binding>
    </mod-up>
  </button>
  <button n="7">
    <desc type="string">Custom</desc>
    <binding>
      <command type="string">nasal</command>
      <script type="string"></script>
      <module type="string">__js2</module>
    </binding>
    <mod-up>
      <binding>
      </binding>
    </mod-up>
  </button>
  <button n="8">
    <desc type="string">Custom</desc>
    <binding>
      <command type="string">nasal</command>
      <script type="string"></script>
      <module type="string">__js2</module>
    </binding>
    <mod-up>
      <binding>
      </binding>
    </mod-up>
  </button>
  <button n="9">
    <desc type="string">Custom</desc>
    <binding>
      <command type="string">nasal</command>
      <script type="string"></script>
      <module type="string">__js2</module>
    </binding>
    <mod-up>
      <binding>
      </binding>
    </mod-up>
  </button>
  <button n="10">
    <desc type="string">Custom</desc>
    <binding>
      <command type="string">nasal</command>
      <script type="string"></script>
      <module type="string">__js2</module>
    </binding>
    <mod-up>
      <binding>
      </binding>
    </mod-up>
  </button>
  <button n="11">
    <desc type="string">Custom</desc>
    <binding>
      <command type="string">nasal</command>
      <script type="string"></script>
      <module type="string">__js2</module>
    </binding>
    <mod-up>
      <binding>
      </binding>
    </mod-up>
  </button>
</PropertyList>
Fly low, fly slow, land on a dime. Twin Otter DHC6-300+ https://github.com/SurferTim/dhc6p
PirateAir videos at https://www.youtube.com/user/SurferTim850
User avatar
SurferTim
 
Posts: 1066
Joined: Sun Dec 09, 2018 5:49 pm
Location: Miramar Beach, FL
Callsign: Pirate
Version: 2020.3.3
OS: Ubuntu 18.04

Re: Joystick xml codes Library project - open for contributi

Postby mercster » Sat Mar 07, 2020 1:23 pm

Hey folks, try as I might... can't find a TWCS-Throttle.xml. Can someone share or point me in the right direction? I'm using Linux, and I can edit the file if need be, but I'm too new to write it from scratch... need a skeleton or something. The throttle has some basic functionality, but I'd like to get it set up better (mostly the paddles for rudder control... seems some people use them for brakes, but you can't press both at the same time?) also wanna do the hats. Thank you. I'm going to cross post in the main hardware forum for more visibility.

EDIT: @dg-505 provided me his file, thank you very much! I post it here for future reference:

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

<PropertyList>
  <name type="string">Thrustmaster TWCS Throttle</name>
  <axis>
    <desc type="string">Nose wheel</desc>
    <binding>
      <command type="string">property-scale</command>
      <property type="string">controls/gear/tiller</property>
      <setting type="double">0</setting>
    </binding>
    <binding n="1">
      <command type="string">property-scale</command>
      <property type="string">controls/gear/tiller-cmd-norm</property>
      <setting type="double">0</setting>
    </binding>
  </axis>
  <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="5">
    <desc type="string">View Horizontal Axis</desc>
    <binding>
      <command type="string">property-scale</command>
      <property type="string">/sim/current-view/goal-heading-offset-deg</property>
      <factor type="double">-60</factor>
      <offset type="double">0</offset>
    </binding>
  </axis>
  <axis n="7">
    <desc type="string">Flaps</desc>
    <binding>
      <command type="string">property-scale</command>
      <property type="string">/controls/flight/flaplever</property>
      <factor type="double">0.5</factor>
      <offset type="double">1</offset>
    </binding>
    <binding>
                <condition>
                    <property>controls/flight/flaps-serviceable</property>
                </condition>
                <command>nasal</command>
                <script>gui.popupTip(sprintf("Flaps: %3.1f deg", 37.5*getprop("/controls/flight/flaps")));</script>
            </binding>
            <binding>
                <condition>
                    <not>
                        <property>controls/flight/flaps-serviceable</property>
                    </not>
                </condition>
                <command>nasal</command>
                <script>gui.popupTip("Flap operation requires hydraulic pressure!");</script>
            </binding>
  </axis>
  <button>
    <desc type="string">Custom</desc>
    <binding>
      <command type="string">pause</command>
      <offset type="double">1</offset>
    </binding>
  </button>
  <button n="1">
    <desc type="string">Custom</desc>
    <binding>
      <command type="string">nasal</command>
      <script type="string">controls.applyBrakes(1, -1)</script>
      <module type="string">__js1</module>
      <offset type="double">1</offset>
    </binding>
    <mod-up>
      <binding>
        <command type="string">nasal</command>
        <script type="string">controls.applyBrakes(0, -1)</script>
        <module type="string">__js1</module>
        <offset type="double">1</offset>
      </binding>
    </mod-up>
  </button>
  <button n="2">
    <desc type="string">Custom</desc>
    <binding>
      <command type="string">nasal</command>
      <script type="string">controls.applyBrakes(1, 1)</script>
      <module type="string">__js1</module>
      <offset type="double">1</offset>
    </binding>
    <mod-up>
      <binding>
        <command type="string">nasal</command>
        <script type="string">controls.applyBrakes(0, 1)</script>
        <module type="string">__js1</module>
        <offset type="double">1</offset>
      </binding>
    </mod-up>
  </button>
  <button n="3">
    <desc type="string">View Increase</desc>
    <binding>
      <command type="string">nasal</command>
      <script type="string">view.increase(0.75);</script>
    </binding>
    <repeatable type="double">1</repeatable>
  </button>
  <button n="4">
    <desc type="string">View Decrease</desc>
    <binding>
      <command type="string">nasal</command>
      <script type="string">view.decrease(0.75);</script>
    </binding>
    <repeatable type="double">1</repeatable>
  </button>
</PropertyList>
mercster
 
Posts: 37
Joined: Sat Mar 07, 2020 1:12 pm

Re: Joystick xml codes Library project - open for contributi

Postby Johan G » Sun Mar 15, 2020 2:21 pm

mercster wrote in Sat Mar 07, 2020 1:23 pm:I post it here for future reference

Thank you! :)
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)
Johan G
Moderator
 
Posts: 6366
Joined: Fri Aug 06, 2010 5: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 asqn34 » Wed May 06, 2020 9:56 pm

Hi all,

gui.popupTip for the flaps. Working with my Saitel Cyborg X and FG 2019.1.1.
I wanted the flap info displayed on the screen to be the exact match of the flap control in the cabine rather than the info from flaps_path in the plane.nas
I am mainly flying the Citation X so you could change the text in bracket to suit your need and add more flap position if needed.
Remove the mod-up binding if not needed.
Enjoy

Code: Select all
<button n="1">
    <desc>2 Flaps down, Cycle View</desc>
    <repeatable>false</repeatable>
    <binding>
      <command>nasal</command>
      <script>
                mod = getprop("/input/joysticks/js[0]/Saitek-Cyborg-X-modifier");            
                if (mod == nil or mod == 0)   {
                controls.flapsDown(1);
            var flaps_select = getprop ("controls/flight/flaps-select");         
                if ( flaps_select == 4 ) {
                gui.popupTip("Flaps FULL");
            } if ( flaps_select == 3 ) {
               gui.popupTip("Flaps 15");
            } if  (flaps_select == 2 ) {
               gui.popupTip("Flaps 5");
            } if (flaps_select == 1 ) {
                    gui.popupTip("Flaps SLAT");
                }
            controls.flapsDown(0);
                } elsif (mod == 1) {
            #
            }
</script>
    </binding>
    <mod-up>
      <binding>
        <command>nasal</command>
        <script>
            if (mod == nil or mod == 0) {
               #
               } elsif (mod == 1) {
                  i = view.stepView(1);
               }
   </script>
      </binding>
    </mod-up>
  </button>

<button n="2">
    <desc>3 Flaps up, Center View</desc>
    <repeatable>false</repeatable>
    <binding>
      <command>nasal</command>
      <script>
       mod = getprop("/input/joysticks/js[0]/Saitek-Cyborg-X-modifier");            
                if (mod == nil or mod == 0)   {               
                controls.flapsDown(-1);
            var flaps_select = getprop ("controls/flight/flaps-select");         
                if ( flaps_select == 0 ) {
                gui.popupTip("Flaps UP");
            } if ( flaps_select == 3 ) {
               gui.popupTip("Flaps 15");
            } if  (flaps_select == 2 ) {
               gui.popupTip("Flaps 5");
            } if (flaps_select == 1 ) {
                    gui.popupTip("Flaps SLAT");
                }
            controls.flapsDown(0);
                } elsif (mod == 1) {
            #
            }
</script>
    </binding>
    <mod-up>
      <binding>
        <command>nasal</command>
        <script>   
      if (mod == nil or mod == 0) {
               #
               } elsif (mod == 1) {
                  i = view.resetView(0);
               }
</script>
      </binding>
    </mod-up>
  </button>


asqn34
 
Posts: 5
Joined: Wed Jun 09, 2010 6:52 pm
Callsign: CL1906
OS: Linuxmint 19.3

Re: Joystick xml codes Library project - open for contributi

Postby StuartC » Mon Jul 20, 2020 9:23 pm

Want to use this to fly in Flight Gear ? Now you can.

Image


DOWNLOAD:-

http://www.fguk.me/hangar/download/10-o ... ration-xml



For those serious about choppers, they need serious controls.

The ProFlightPuma is a popular choice for many, and all too often I hear " My puma does not work correctly with Flight Gear".

Well, its actually does. Every Axis and every button combination has been manually discovered and mapped in this ready to use XML file.

HOW TO INSTALL:-

Unzip and copy the file Pro-Flight-Trainercom.xml to one of the following locations :-



WINDOWS USERS:- C:Users(your user name )AppDataRoamingflightgear.orgInputJoysticks

LINUX USERS:- /home/[USERNAME]/.fgfs/Input/Joysticks

MAC users:- ~/Library/Application Support/FlightGear/Input/Joysticks

The Puma should now be available from the pull down Joystics menu in the Joystick configuration screen.



Please read the included PDF file as it has a chart of all the functions of the control set and what they are mapped to in this XML file.
StuartC
 
Posts: 2967
Joined: Fri Jun 18, 2010 8: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 Richard » Tue Jul 21, 2020 8:44 am

StuartC wrote in Mon Jul 20, 2020 9:23 pm:Want to use this to fly in Flight Gear ? Now you can.
Please read the included PDF file as it has a chart of all the functions of the control set and what they are mapped to in this XML file.


Stuart - do you think we should include this in the next version of FlightGear directly?
Richard
 
Posts: 801
Joined: Sun Nov 02, 2014 10:17 pm
Version: Git
OS: Win10

Re: Joystick xml codes Library project - open for contributi

Postby StuartC » Tue Jul 21, 2020 9:18 am

If you like, yes.
You can only change the button and axis setting via xml though. the Joystick configurator will load the XML but you cant alter anything from it.
StuartC
 
Posts: 2967
Joined: Fri Jun 18, 2010 8: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 tom_nl » Tue Aug 04, 2020 3:16 pm

My contribution - xml file for saitek yoke set up for the Cessna 172. Flaps controlled in steps by the right lever. The three way switch behind the right handle acts as a shift to change the throttle quadrant button function depending on position.

This is for OS X- I believe the button assignment numbers in windows and linux are different.

Tom

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

<!-- Saitek Pro Flight Yoke control assignment

Yoke - elevator and aileron
Left lever - throttle
Middle Lever - mixture
Right Lever - flaps (in steps)
Hat - look around

Buttons:
E (behind left - button 0) - reset view forwards
D (top right - button 1) - change view forwards, with shift change view backwards
A1 (button 2) - altimeter pressure up
A2 (button 3) - altimeter pressure down
B1 (button 4) - elevator trim down
B2 (button 5)  - elevator trim up
C1 (button 6) - rudder trim left
C2 (button 7) - rudder trim right
MODE switch (buttons 8,9,10) - shift modes 1, 2 and 3
Function (button 11) - unassigned
start-stop (button 12) - unassigned
Reset (button 13) - unassigned

quadrant buttons
button      mode 1            mode 2         mode 3   
T1 (14)      Master Alternator   Pitot Heat      Increase Magnetos
T2 (15)      Engine Primer      Nav Lights      Decrease Magnetos
T3 (16)      Battery Master      Taxi Lights      Starter
T4 (17)      Parking Brake      Beacon         Unassigned (Beacon)
T5 (18)      Avionics         Landing Lights   altimeter pressure up
T6 (19)      Carb Heat         Strobes         altimeter pressure down

Lever pulled back buttons
Left Lever (20) - unassigned
Centre Lever (21) - unassigned
Right Lever (22) - unassigned

-->

<PropertyList>
  <name type="string">Saitek Pro Flight Yoke</name>
  <axis>
    <desc type="string">Aileron</desc>
    <binding>
      <command type="string">property-scale</command>
      <property type="string">/controls/flight/aileron</property>
      <factor type="double">1</factor>
      <offset type="double">0</offset>
      <power type="double">1</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>
      <power type="double">1</power>
    </binding>
  </axis>
  <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 type="string">Mixture All Engines</desc>
    <binding>
      <command type="string">property-scale</command>
      <property type="string">/controls/engines/mixture-all</property>
      <factor type="double">1</factor>
      <offset type="double">0</offset>
      <power type="double">1</power>
    </binding>
  </axis>
 
 
 <axis n="4">
        <name>Flaps</name>
      <desc type="string">Flaps</desc>
      <binding>
               <command>nasal</command>
               <script>
               <![CDATA[
 var flapset = getprop("/devices/status/joysticks/joystick[1]/axis[4]");
       var flapinput = 1;
                if(flapset > 0.8) {
                flapinput = 1;
                } elsif (flapset > 0) {
                flapinput = 0.666;
                } elsif (flapset > -0.8) {
                flapinput = 0.333;
                }
            else {
                flapinput = 0;
                }
                  setprop("/controls/flight/flaps", flapinput);
                ]]>
               </script>
      </binding>
      </axis>
 
 
  <axis n="5">
    <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="6">
    <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>
    <desc type="string">Front VIew</desc>
    <binding>
      <command type="string">nasal</command>
      <script type="string">
setprop("/sim/current-view/goal-pitch-offset-deg", getprop("/sim/view/config/default-pitch-deg"));
setprop("/sim/current-view/goal-heading-offset-deg", getprop("/sim/view/config/default-heading-deg"));
setprop("/sim/current-view/field-of-view", getprop("/sim/view/config/default-field-of-view-deg"));
setprop("/sim/current-view/x-offset-m", getprop("/sim/view/config/x-offset-m"));
setprop("/sim/current-view/y-offset-m", getprop("/sim/view/config/y-offset-m"));
setprop("/sim/current-view/z-offset-m", getprop("/sim/view/config/z-offset-m"));
setprop("/sim/current-view/view-number","0");</script>
      <module type="string">__js1</module>
    </binding>
  </button>
 
 
 <!--  <button n="1"> --> <!-- left front button -->
    <button n="1">
        <desc>Cycle View</desc>
        <repeatable>false</repeatable>
        <binding>
             <condition>
 <property>/devices/status/joysticks/joystick[1]/button[8]</property>
 </condition>
            <command>nasal</command>
            <script>view.stepView(1)</script>
        </binding>
                <binding>
             <condition>
 <property>/devices/status/joysticks/joystick[1]/button[9]</property>
 </condition>
            <command>nasal</command>
            <script>view.stepView(-1)</script>
        </binding>
                        <binding>
             <condition>
 <property>/devices/status/joysticks/joystick[1]/button[10]</property>
 </condition>
            <command>nasal</command>
            <script>view.stepView(-1)</script>
        </binding>
    </button>
 
  <button n="2"> <!-- A1  button -->
    <desc type="string">altimeter pressure up</desc>
        <repeatable type="string">true</repeatable>
      <binding>
   <command>property-adjust</command>
   <property>/instrumentation/altimeter/setting-inhg</property>
   <step type="double">+0.001</step>
  </binding>
         </button>
 
    <button n="3"> <!-- A2  button -->
    <desc type="string">altimeter pressure  down</desc>
         <repeatable type="string">true</repeatable>
      <binding>
   <command>property-adjust</command>
   <property>/instrumentation/altimeter/setting-inhg</property>
   <step type="double">-0.001</step>
  </binding>
         </button>   
 
  <button n="4"> <!-- B1 button -->
    <desc type="string">Elevator Trim Down</desc>
    <binding>
      <command type="string">nasal</command>
      <script type="string">controls.elevatorTrim(1);</script>
    </binding>
    <repeatable type="double">1</repeatable>
  </button>
 
  <button n="5"> <!-- B2 button -->
    <desc type="string">Elevator Trim Up</desc>
    <binding>
      <command type="string">nasal</command>
      <script type="string">controls.elevatorTrim(-1);</script>
    </binding>
    <repeatable type="double">1</repeatable>
  </button>
 
  <button n="6"> <!-- C1 button -->
    <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>
 
  <button n="7"> <!-- C2 button -->
    <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>
 
 <!-- quadrant buttons -->
  <!-- T1 -->
<!--    <button n="14">
    <desc type="string">Master Alternator Switch or pitot heat (shifted)</desc>
    <repeatable type="string">false</repeatable>
<binding>
<command type="string">nasal</command>
<script>
var mode = 1;
if (getprop("/devices/status/joysticks/joystick[1]/button[8]") == 1) {
mode = 1;
}
else {mode=2;}
    if(mode==1)
       {
        if(getprop("/controls/switches/master-alt") == 0)
          {
          setprop("/controls/switches/master-alt",1) ;
          }
       else {
          setprop("/controls/switches/master-alt",0);
          }
       }
    if(mode==2) {
        if(getprop("/controls/anti-ice/pitot-heat") == 0)
          {
          setprop("/controls/anti-ice/pitot-heat",1) ;
          }
       else {
          setprop("/controls/anti-ice/pitot-heat",0);
          }
       }
 
</script>
</binding>
  </button>  -->
 
<button n="14"> <!-- T1 -->
    <desc type="string">Master Alternator Switch (mode 1), pitot heat (mode 2), magnetos up (mode3)</desc>
    <repeatable type="string">false</repeatable>
    <binding>
     <condition>
 <property>/devices/status/joysticks/joystick[1]/button[8]</property>
 </condition>
      <command type="string">property-toggle</command>
      <property type="string">/controls/switches/master-alt</property>
    </binding>
   
             <binding>
        <condition>
 <property>/devices/status/joysticks/joystick[1]/button[9]</property>
 </condition>
      <command type="string">property-toggle</command>
      <property type="string">/controls/anti-ice/pitot-heat</property>
        </binding>
       
                <binding>
        <condition>
 <property>/devices/status/joysticks/joystick[1]/button[10]</property>
 </condition>
      <command>nasal</command>
      <script>controls.stepMagnetos(1)</script>
    </binding>
 <!--     <mod-up>
   <binding>
    <command>nasal</command>
    <script>controls.stepMagnetos(0)</script>
   </binding>
  </mod-up> -->

  </button> 
 
 
  <button n="15"> <!-- Button T2 -->
    <desc type="string">engine primer (mode 1), nav lights (mode 2), magnetos down (mode 3)</desc>
        <repeatable type="string">false</repeatable>
      <binding>
                     <condition>
 <property>/devices/status/joysticks/joystick[1]/button[8]</property>
 </condition>
      <command type="string">property-toggle</command>
  <property type="string">/controls/engines/engine/primer-lever</property>

  </binding>
        <binding>
                       <condition>
 <property>/devices/status/joysticks/joystick[1]/button[8]</property>
 </condition>
   <command>property-adjust</command>
   <property>/controls/engines/engine/primer</property>
   <step type="double">+0.5/</step>
  </binding>

             <binding>
        <condition>
 <property>/devices/status/joysticks/joystick[1]/button[9]</property>
 </condition>
      <command type="string">property-toggle</command>
      <property type="string">/controls/lighting/nav-lights</property>
        </binding>
       
                <binding>
        <condition>
 <property>/devices/status/joysticks/joystick[1]/button[10]</property>
 </condition>
   <command>nasal</command>
   <script>controls.stepMagnetos(-1)</script>
  </binding>
<!--  <mod-up>
   <binding>
    <command>nasal</command>
    <script>controls.stepMagnetos(0)</script>
   </binding>
  </mod-up> -->

         </button>
 
 
    <button n="16"> <!-- T3 button-->
    <desc type="string">Battery Switch (mode 1), taxi lights (mode 2), starter (mode 3)</desc>
    <repeatable type="string">false</repeatable>
   
    <binding>
     <condition>
 <property>/devices/status/joysticks/joystick[1]/button[8]</property>
 </condition>
      <command type="string">property-toggle</command>
      <property type="string">/controls/switches/master-bat</property>
    </binding>
   
             <binding>
        <condition>
 <property>/devices/status/joysticks/joystick[1]/button[9]</property>
 </condition>
      <command type="string">property-toggle</command>
      <property type="string">/controls/lighting/taxi-light</property>
        </binding>
       
                <binding>
        <condition>
 <property>/devices/status/joysticks/joystick[1]/button[10]</property>
 </condition>

      <command type="string">property-assign</command>
      <property type="string">/controls/engines/engine/starter</property>
      <value type="bool">true</value>
    </binding>
   
         <binding>
                 <condition>
 <property>/devices/status/joysticks/joystick[1]/button[10]</property>
 </condition>
      <command type="string">property-assign</command>
      <property type="string">/controls/switches/starter</property>
      <value type="bool">true</value>
    </binding>
   
        <mod-up>
      <binding>
              <condition>
 <property>/devices/status/joysticks/joystick[1]/button[10]</property>
 </condition>
        <command type="string">property-assign</command>
        <property type="string">/controls/engines/engine/starter</property>
        <value type="bool">false</value>
      </binding>
     
      <binding>
              <condition>
 <property>/devices/status/joysticks/joystick[1]/button[10]</property>
 </condition>
        <command type="string">property-assign</command>
        <property type="string">/controls/switches/starter</property>
        <value type="bool">false</value>
      </binding>
    </mod-up>
 
 
   
  </button>
 
 
 

     <button n="17"> <!-- T4 button-->
       <desc>Parking Brake (mode 1) or beacon (mode 2 and 3)</desc>
       <binding>
               <condition>
 <property>/devices/status/joysticks/joystick[1]/button[8]</property>
 </condition>
          <command>nasal</command>
          <script>
             brake = !getprop("/controls/gear/brake-parking");
             if (brake) {
                gui.popupTip("Parking Brake ON");
             } else {
                gui.popupTip("Parking Brake OFF");
             }
             controls.applyParkingBrake(1)
          </script>
       </binding>
                     <binding>
        <condition>
 <property>/devices/status/joysticks/joystick[1]/button[9]</property>
 </condition>
      <command type="string">property-toggle</command>
      <property type="string">/controls/lighting/beacon</property>
        </binding>
       
                <binding>
        <condition>
 <property>/devices/status/joysticks/joystick[1]/button[10]</property>
 </condition>
      <command type="string">property-toggle</command>
      <property type="string">/controls/lighting/beacon</property>
    </binding>
    </button>
 
    <button n="18"> <!-- T5 button-->
    <desc type="string">Avionics Switch (mode 1) or landing lights (mode 2 and 3)</desc>
    <repeatable type="string">false</repeatable>
    <binding>
        <condition>
 <property>/devices/status/joysticks/joystick[1]/button[8]</property>
 </condition>
      <command type="string">property-toggle</command>
      <property type="string">/controls/switches/master-avionics</property>
    </binding>
               <binding>
        <condition>
 <property>/devices/status/joysticks/joystick[1]/button[9]</property>
 </condition>
      <command type="string">property-toggle</command>
      <property type="string">/controls/lighting/landing-lights</property>
        </binding>
       
                <binding>
        <condition>
 <property>/devices/status/joysticks/joystick[1]/button[10]</property>
 </condition>
      <command type="string">property-toggle</command>
      <property type="string">/controls/lighting/landing-lights</property>
    </binding>
  </button>


 
 
 
  <button n="19"> <!-- T6 Button -->
    <desc type="string">carb heat (mode 1) or strobes (mode 2 and 3)</desc>

      <binding>
             <condition>
 <property>/devices/status/joysticks/joystick[1]/button[8]</property>
 </condition>
      <command type="string">property-toggle</command>
  <property type="string">/controls/engines/current-engine/carb-heat</property>
  </binding>

     
      <binding>
        <condition>
 <property>/devices/status/joysticks/joystick[1]/button[9]</property>
 </condition>
      <command type="string">property-toggle</command>
      <property type="string">/controls/lighting/strobe</property>
        </binding>
       
                <binding>
           
        <condition>
 <property>/devices/status/joysticks/joystick[1]/button[10]</property>
 </condition>
      <command type="string">property-toggle</command>
      <property type="string">/controls/lighting/strobe</property>
    </binding>
  </button>
 

 
   <!-- magnetos-->    
 <!--
        <button n="8">
    <desc type="string">magneto off</desc>
    <repeatable type="string">false</repeatable>
    <binding>
      <command type="string">property-assign</command>
      <property type="string">/controls/engines/engine/magnetos</property>
      <value type="double">0</value>
    </binding>
     <binding>
      <command type="string">property-assign</command>
      <property type="string">/controls/switches/magnetos</property>
      <value type="double">0</value>
    </binding>
   
    </button>
        <button n="9">
    <desc type="string">magneto both</desc>
    <repeatable type="string">false</repeatable>
    <binding>
      <command type="string">property-assign</command>
      <property type="string">/controls/engines/engine/magnetos</property>
      <value type="double">3</value>
    </binding>
         <binding>
      <command type="string">property-assign</command>
      <property type="string">/controls/switches/magnetos</property>
      <value type="double">3</value>
    </binding>
    </button>
        <button n="10">
    <desc type="string">engine start</desc>
    <repeatable type="string">true</repeatable>
      <binding>
      <command type="string">property-assign</command>
      <property type="string">/controls/engines/engine/magnetos</property>
      <value type="double">3</value>
    </binding>
    <binding>
      <command type="string">property-assign</command>
      <property type="string">/controls/engines/engine/starter</property>
      <value type="bool">true</value>
    </binding>
         <binding>
      <command type="string">property-assign</command>
      <property type="string">/controls/switches/starter</property>
      <value type="bool">true</value>
    </binding>
        <mod-up>
      <binding>
        <command type="string">property-assign</command>
        <property type="string">/controls/engines/engine/starter</property>
        <value type="bool">false</value>
      </binding>
      <binding>
        <command type="string">property-assign</command>
        <property type="string">/controls/switches/starter</property>
        <value type="bool">false</value>
      </binding>
    </mod-up>
    </button>
  -->
 
</PropertyList>
tom_nl
 
Posts: 84
Joined: Tue Aug 04, 2020 10:41 am
Location: Netherlands
OS: OS X Big Sur

Re: Joystick xml codes Library project - open for contributi

Postby Puffergas » Thu Feb 25, 2021 7:05 pm

Honeycomb Yoke
Written for the Cessna 172
Tested only on Raspberry Pi OS and FlightGear 2020.3.6
Code: Select all
<?xml version="1.0"?>

<!--

  Copyright (c) 2021 FlightGear Flight Simulator

  This program is free software: you can redistribute it and/or modify
  it under the terms of the GNU General Public License as published by
  the Free Software Foundation, either version 2 of the License, or
  (at your option) any later version.

  This program is distributed in the hope that it will be useful,
  but WITHOUT ANY WARRANTY; without even the implied warranty of
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  GNU General Public License for more details.

  You should have received a copy of the GNU General Public License
  along with this program.  If not, see <http://www.gnu.org/licenses/>.

********************************************************************

Written for the Cessna 172 and only tested on Raspberry Pi OS running
FlightGear 2020.3.6

********************************************************************
-->


<!--
********************************************************************
*
* Bindings for Honeycomb Aeronautical Alpha Flight Controls - Yoke
*
*
* Axis 0: ailerons
* Axis 1: elevator
* Axes 2 and 3 (hat): view direction
*
* Button  0: YOKE white-Trigger left-handle  >>>>>>>>  View, Cycle Forwards
* Button  1: YOKE white-top-Button left-handle  >>>>>  View, Reset
* Button  2: YOKE white-top-Button right-handle
* Button  3: YOKE red-top-Button right-handle
* Button  4: YOKE outer-Rocker down left-handle  >>>>  Elevator Trim, Up
* Button  5: YOKE outer-Rocker up left-handle  >>>>>>  Elevator Trim, Down
* Button  6: YOKE inner-Rocker down left-handle  >>>>  Flaps, Down
* Button  7: YOKE inner-Rocker up left-handle  >>>>>>  Flaps, Up
* Button  8: YOKE top-Rocker inward right-handle  >>>  Rudder Trim, Left
* Button  9: YOKE top-Rocker outward right-handle  >>  Rudder Trim, Right
* Button 10: YOKE bottom-Rocker inward right-handle
* Button 11: YOKE bottom-Rocker outward right-handle
* Button 12: BASE Master Alternator up  >>>>>>>>>>>>>  Master Alternator, ON OFF
* Button 13: BASE Master Alternator down
* Button 14: BASE Master Battery up  >>>>>>>>>>>>>>>>  Battery, ON OFF
* Button 15: BASE Master Battery down
* Button 16: BASE Avionics Bus1 up  >>>>>>>>>>>>>>>>>  Master Avionics, ON OFF
* Button 17: BASE Avionics Bus1 down
* Button 18: BASE Avionics Bus2 up
* Button 19: BASE Avionics Bus2 down
* Button 20: BASE Beacon up  >>>>>>>>>>>>>>>>>>>>>>>>  Beacon, ON OFF
* Button 21: BASE Beacon down
* Button 22: BASE Land up  >>>>>>>>>>>>>>>>>>>>>>>>>>  Landing Lights, ON OFF
* Button 23: BASE Land down
* Button 24: BASE Taxi up  >>>>>>>>>>>>>>>>>>>>>>>>>>  Taxi Lights, ON OFF
* Button 25: BASE Taxi down
* Button 26: BASE Nav up  >>>>>>>>>>>>>>>>>>>>>>>>>>>  Navigation Lights, ON OFF
* Button 27: BASE Nav down
* Button 28: BASE Strobe up  >>>>>>>>>>>>>>>>>>>>>>>>  Strobe Light, ON OFF
* Button 29: BASE Strobe down
* Button 30: BASE Off  >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>  Magneto, OFF
* Button 31: BASE Right Mag  >>>>>>>>>>>>>>>>>>>>>>>>  Magneto, Right
* Button 32: BASE Left Mag  >>>>>>>>>>>>>>>>>>>>>>>>>  See note below
* Button 33: BASE Both Mag  >>>>>>>>>>>>>>>>>>>>>>>>>  See note below
* Button 34: BASE Start  >>>>>>>>>>>>>>>>>>>>>>>>>>>>  See note below

********************************************************************
-->

<PropertyList>
  <name type="string">Honeycomb Aeronautical Alpha Flight Controls</name>

  <axis>
      <desc>Aileron</desc>
      <binding>
          <command>property-scale</command>
          <property>/controls/flight/aileron</property>
          <factor type="double">1</factor>
          <offset type="double">0</offset>
      </binding>
  </axis>

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

  <axis n="2">
      <desc>View, Direction</desc>
      <direction>left</direction>
      <low>
          <repeatable>true</repeatable>
          <binding>
              <command>nasal</command>
              <script>view.panViewDir(1)</script>
              <module>__js1</module>
              <offset type="double">1</offset>
          </binding>
      </low>
      <high>
          <repeatable>true</repeatable>
          <binding>
              <command>nasal</command>
              <script>view.panViewDir(-1)</script>
              <module>__js1</module>
              <offset type="double">1</offset>
          </binding>
      </high>
  </axis>

  <axis n="3">
      <desc>View, Elevation</desc>
      <direction>upward</direction>
      <low>
          <repeatable>true</repeatable>
          <binding>
              <command>nasal</command>
              <script>view.panViewPitch(1)</script>
              <module>__js1</module>
              <offset type="double">1</offset>
          </binding>
     </low>
     <high>
          <repeatable>true</repeatable>
          <binding>
              <command>nasal</command>
              <script>view.panViewPitch(-1)</script>
              <module>__js1</module>
              <offset type="double">1</offset>
          </binding>
      </high>
  </axis>
 
  <button n="0">
      <desc>View, Cycle Forwards</desc>
      <repeatable>false</repeatable>
      <binding>
          <command>nasal</command>
          <script>view.stepView(1)</script>
      </binding>
  </button>

  <button n="1">
      <desc>View, Reset</desc>
      <repeatable>false</repeatable>
      <binding>
          <command>nasal</command>
          <script>
              setprop("/sim/current-view/view-number", 0);
              view.resetView()
          </script>
      </binding>
  </button>

  <button n="4">
      <desc>Elevator Trim, Up</desc>
      <repeatable>true</repeatable>
      <binding>
          <command>nasal</command>
          <script>controls.elevatorTrim(-1)</script>
      </binding>
  </button>

  <button n="5">
      <desc>Elevator Trim, Down</desc>
      <repeatable>true</repeatable>
      <binding>
          <command>nasal</command>
          <script>controls.elevatorTrim(1)</script>
      </binding>
  </button>

  <button n="6">
      <desc>Flaps, Down</desc>
      <repeatable>false</repeatable>
      <binding>
          <command>nasal</command>
          <script>controls.flapsDown(1)</script>
      </binding>
  </button>

  <button n="7">
      <desc>Flaps, Up</desc>
      <repeatable>false</repeatable>
      <binding>
          <command>nasal</command>
          <script>controls.flapsDown(-1)</script>
      </binding>
  </button>

  <button n="8">
      <desc>Rudder Trim, Left</desc>
      <repeatable>true</repeatable>
      <binding>
          <command>nasal</command>
          <script>controls.rudderTrim(-1)</script>
      </binding>
  </button>

  <button n="9">
      <desc>Rudder Trim, Right</desc>
      <repeatable>true</repeatable>
      <binding>
          <command>nasal</command>
          <script>controls.rudderTrim(1)</script>
      </binding>
  </button>

  <button n="12">
      <desc>Master Alternator, ON OFF</desc>
      <repeatable>false</repeatable>
      <binding>
          <command>nasal</command>
          <script>setprop("/controls/switches/master-alt", 1);</script>
      </binding>
      <mod-up>
          <binding>
              <command>nasal</command>
              <script>setprop("/controls/switches/master-alt", 0)</script>
          </binding>
      </mod-up>
  </button>

  <button n="14">
      <desc>Battery, ON OFF</desc>
      <repeatable>false</repeatable>
      <binding>
          <command>nasal</command>
          <script>setprop("/controls/switches/master-bat", 1)</script>
      </binding>
      <mod-up>
          <binding>
              <command>nasal</command>
              <script>setprop("/controls/switches/master-bat", 0)</script>
          </binding>
      </mod-up>
      </button>

  <button n="16">
      <desc>Master Avionics, ON OFF</desc>
      <repeatable>false</repeatable>
      <binding>
          <command>nasal</command>
          <script>setprop("/controls/switches/master-avionics", 1)</script>
      </binding>
      <mod-up>
          <binding>
              <command>nasal</command>
              <script>setprop("/controls/switches/master-avionics", 0)</script>
          </binding>
      </mod-up>
  </button>

  <button n="20">
      <desc>Beacon, ON OFF</desc>
      <repeatable>false</repeatable>
      <binding>
          <command>nasal</command>
          <script>setprop("/controls/lighting/beacon", 1)</script>
      </binding>
      <mod-up>
          <binding>
              <command>nasal</command>
              <script>setprop("/controls/lighting/beacon", 0)</script>
          </binding>
      </mod-up>
  </button>

  <button n="22">
      <desc>Landing Lights, ON OFF</desc>
      <repeatable>false</repeatable>
      <binding>
          <command>nasal</command>
          <script>setprop("/controls/lighting/landing-lights", 1)</script>
      </binding>
      <mod-up>
          <binding>
              <command>nasal</command>
              <script>setprop("/controls/lighting/landing-lights", 0)</script>
          </binding>
      </mod-up>
  </button>

  <button n="24">
      <desc>Taxi Lights, ON OFF</desc>
      <repeatable>false</repeatable>
      <binding>
          <command>nasal</command>
          <script>setprop("/controls/lighting/taxi-light", 1)</script>
      </binding>
      <mod-up>
          <binding>
              <command>nasal</command>
              <script>setprop("/controls/lighting/taxi-light", 0)</script>
          </binding>
      </mod-up>
  </button>

  <button n="26">
      <desc>Navigation Lights, ON OFF</desc>
      <repeatable>false</repeatable>
      <binding>
          <command>nasal</command>
          <script>setprop("/controls/lighting/nav-lights", 1)</script>
      </binding>
      <mod-up>
          <binding>
              <command>nasal</command>
              <script>setprop("/controls/lighting/nav-lights", 0)</script>
          </binding>
      </mod-up>
  </button>

  <button n="28">
      <desc>Strobe Light, ON OFF</desc>
      <repeatable>false</repeatable>
      <binding>
          <command>nasal</command>
          <script>setprop("/controls/lighting/strobe", 1)</script>
      </binding>
      <mod-up>
          <binding>
              <command>nasal</command>
              <script>setprop("/controls/lighting/strobe", 0)</script>
          </binding>
      </mod-up>
  </button>

  <button n="30">
      <desc>Magneto, OFF</desc>
      <repeatable>false</repeatable>
      <binding>
          <command>nasal</command>
          <script>setprop("/controls/switches/magnetos", 0)</script>
      </binding>
  </button>

  <button n="31">
      <desc>Magneto, Right</desc>
      <repeatable>false</repeatable>
      <binding>
          <command>nasal</command>
          <script>setprop("/controls/switches/magnetos", 1)</script>
      </binding>
  </button>

<!-- Linux and FlightGear does not handle more than 32 USB buttons.
     See FlightGear Ticket 2212.

  <button n="32">
      <desc>Magneto, Left</desc>
      <repeatable>false</repeatable>
      <binding>
          <command>nasal</command>
          <script>setprop("/controls/switches/magnetos", 2)</script>
      </binding>
  </button>

  <button n="33">
      <desc>Magneto, Both</desc>
      <repeatable>false</repeatable>
      <binding>
          <command>nasal</command>
          <script>setprop("/controls/switches/magnetos", 3)</script>
      </binding>
  </button>

  <button n="34">
      <desc>Starter, ON OFF</desc>
      <repeatable>false</repeatable>
      <binding>
          <command>nasal</command>
          <script>setprop("/controls/lighting/strobe", 1)</script>
      </binding>
      <mod-up>
          <binding>
              <command>nasal</command>
              <script>setprop("/controls/lighting/strobe", 0)</script>
          </binding>
      </mod-up>
  </button>
-->

</PropertyList>


Cheers
Puffergas
 
Posts: 56
Joined: Thu Jan 02, 2020 1:09 am

Previous

Return to Hardware

Who is online

Users browsing this forum: No registered users and 3 guests