Board index FlightGear Support Hardware

Input configuration by choosing the aircraft

Joysticks, pedals, monitors.

Input configuration by choosing the aircraft

Postby I-VANM » Sun Jan 23, 2022 4:03 pm

Hello!
Sorry for posting a new thread, I was unable to find an answer in the documentation + forum...

I would like to create two separate input files, say "Pro-Flight-Cessna-Yoke-C172.xml" and "Pro-Flight-Cessna-Yoke-B747.xml" (with different contents, of course - that's something I already can do), AND let FlightGear read the correct input file by simply choosing the airplane.

Something like this:
getprop ("current aircraft");
IF current aircraft == c172p THEN use the file "Pro-Flight-Cessna-Yoke-C172.xml"
ELSIF current aircraft == B747 THEN use the file "Pro-Flight-Cessna-Yoke-B747.xml"

Sounds logical? How to procede? Where to put this kind of instruction?
Should I better continue to develope a single, huge "Pro-Flight-Cessna-Yoke.xml" file with different configurations in it?
Thank you!
Ivan
I-VANM
 
Posts: 10
Joined: Mon Jun 01, 2020 10:45 am

Re: Input configuration by choosing the aircraft

Postby wkitty42 » Sun Jan 23, 2022 10:38 pm

you cannot... FG uses the file with the name that matches the controller's name...

the best you can do is have one file and detect the craft inside it and then use the desired control settings for that craft...
"You get more air close to the ground," said Angalo. "I read that in a book. You get lots of air low down, and not much when you go up."
"Why not?" said Gurder.
"Dunno. It's frightened of heights, I guess."
User avatar
wkitty42
 
Posts: 9146
Joined: Fri Feb 20, 2015 4:46 pm
Location: central NC, USA
Callsign: wk42
Version: git next
OS: Kubuntu 20.04

Re: Input configuration by choosing the aircraft

Postby I-VANM » Fri Jan 28, 2022 10:31 am

Thank you, wkitty43, I've done several buttons using a var and "if { } elsif { }" for the two aircrafts. Everything works fine.
But...
Now I'm trying to assign to the same axis two functions: controls.mixtureAxis() for the c172p and controls.gearDown () for the B747. Both works well separately.
The last function is asking for a <low> </low> <high> </high> syntax, that seems to be fully incompatible with the "if { } elsif { }" syntax (maybe because of the nestified bindings?).
Here the NOT working code:

Code: Select all
<axis>   
     <number>   
         <unix>4</unix>   
         <windows>3</windows>   
     </number>   
   <name>Red lever</name>   
     <desc>Mixture or Gear, hopefully</desc>
<binding>
<command>nasal</command>
 <script>
  var model = getprop("/sim/aero");
  if (model =="c172p") {
         controls.mixtureAxis();</script>
  }elsif (model =="B747") {
   <low>
   <binding>
      <command>nasal</command>
         <script>
            controls.gearDown (-1);
         </script>
   </binding>
   </low>

   <high>
   <binding>
      <command>nasal</command>
         <script>
            controls.gearDown (1);
         </script>
   </binding>
   </high>
  }
</script>
</binding>
</axis>


Any suggestion? May I change my approach?
TIA
Ivan
I-VANM
 
Posts: 10
Joined: Mon Jun 01, 2020 10:45 am

Re: Input configuration by choosing the aircraft

Postby wkitty42 » Fri Jan 28, 2022 11:53 am

yeah, i don't think you can mix XML and nasal like that...

perhaps this will work? it is done in all XML if i'm understanding what you are trying to do properly... i don't know where those low and high tags come from or what they are supposed to work on, though... i'm also not sure if the conditions can be used in this position and trigger the bindings like this but it is worth a shot...

if it doesn't work, it might point you in the more proper direction... i'm pretty sure others have done this because the topic has come up numerous times since i've been here (2015)... i just don't find their code posted anywhere so this is my best eWAG on how it might be done...
Code: Select all
<axis>   
  <number>   
    <unix>4</unix>   
    <windows>3</windows>   
  </number>   
  <name>Red lever</name>   
  <desc>Mixture or Gear, hopefully</desc>
  <condition>
    <equals>
      <property>/sim/aero</property>
      <value>c172p</value>
    </equals>
    <binding>
      <command>nasal</command>
      <script>controls.mixtureAxis();</script>
    </binding>
  </condition>
  <condition>
    <equals>
      <property>/sim/aero</property>
      <value>B747</value>
    </equals>
    <low>
      <binding>
        <command>nasal</command>
        <script>controls.gearDown (-1);</script>
      </binding>
    </low>
    <high>
      <binding>
        <command>nasal</command>
        <script>controls.gearDown (1);</script>
      </binding>
    </high>
  </condition>
</axis>
"You get more air close to the ground," said Angalo. "I read that in a book. You get lots of air low down, and not much when you go up."
"Why not?" said Gurder.
"Dunno. It's frightened of heights, I guess."
User avatar
wkitty42
 
Posts: 9146
Joined: Fri Feb 20, 2015 4:46 pm
Location: central NC, USA
Callsign: wk42
Version: git next
OS: Kubuntu 20.04

Re: Input configuration by choosing the aircraft

Postby I-VANM » Sat Jan 29, 2022 6:43 pm

Thank you!
The working code (for C172 and A-10 Warthog) follows:

Code: Select all
<axis>
 <number>
  <unix>4</unix>
  <windows>3</windows>
 </number>
 <name>Red lever</name>
 <desc>Mixture or Gear</desc>

<!-- Cessna part -->
     <binding>
        <condition>
         <equals>
         <property>/sim/aero</property>
         <value>c172p</value>
         </equals>
       </condition>
                 <command>nasal</command>
                   <script>controls.mixtureAxis()</script>
     </binding>

<!-- Warthog part -->
  <low>
    <binding>
       <command>nasal</command>
                <script>var model = getprop("/sim/aero");if (model =="A-10-yasim") {controls.gearDown (-1);} </script>
    </binding>
  </low>

  <high>
     <binding>
         <command>nasal</command>
                 <script>var model = getprop("/sim/aero");if (model =="A-10-yasim") {controls.gearDown (1);} </script>
     </binding>
  </high>

</axis>


<high> and <low> is used e.g. in Coolie Hats, reads the position of the axis and acts as a button.
Thank you again!
I-VANM
 
Posts: 10
Joined: Mon Jun 01, 2020 10:45 am


Return to Hardware

Who is online

Users browsing this forum: No registered users and 9 guests