Board index FlightGear Support Compiling

Set both levers at same time.  Topic is solved

Building FlightGear from source, and in the need for help?

Set both levers at same time.

Postby Dris » Sat Apr 09, 2022 1:37 pm

Hi!

In the file SenecaII.xml from Models folder I have the following command lines:

Code: Select all

    <animation>
        <type>rotate</type>
        <object-name>ThrottleControl.L</object-name>
        <property>controls/engines/engine[0]/throttle</property>
        <factor>45.0</factor>
        <axis>
            <x1-m>-1.87609</x1-m>
            <y1-m>1</y1-m>
            <z1-m>1.24033</z1-m>
            <x2-m>-1.87609</x2-m>
            <y2-m>-1</y2-m>
            <z2-m>1.24033</z2-m>
        </axis>
    </animation>

    <animation>
        <type>rotate</type>
        <object-name>ThrottleControl.R</object-name>
        <property>controls/engines/engine[1]/throttle</property>
        <factor>45.0</factor>
        <axis>
            <x1-m>-1.87609</x1-m>
            <y1-m>1</y1-m>
            <z1-m>1.24033</z1-m>
            <x2-m>-1.87609</x2-m>
            <y2-m>-1</y2-m>
            <z2-m>1.24033</z2-m>
        </axis>
    </animation>

    <animation>
      <type>pick</type>
      <object-name>ThrottleControl.L</object-name>
      <visible>true</visible>
      <action>
        <button>1</button>
        <repeatable>false</repeatable>
        <binding>
          <command>nasal</command>
          <script>SenecaII.mouseHandler.set( "/controls/engines/engine[0]/throttle", 0.01 );</script>
         </binding>
         <mod-up>
          <binding>
           <command>nasal</command>
           <script>SenecaII.mouseHandler.set()</script>
          </binding>
         </mod-up>
      </action>
    </animation>

    <animation>
      <type>pick</type>
      <object-name>ThrottleControl.R</object-name>
      <visible>true</visible>
      <action>
        <button>1</button>
        <repeatable>false</repeatable>
        <binding>
          <command>nasal</command>
          <script>SenecaII.mouseHandler.set( "/controls/engines/engine[1]/throttle", 0.01 );</script>
        </binding>
        <mod-up>
        <binding>
           <command>nasal</command>
           <script>SenecaII.mouseHandler.set()</script>
        </binding>
        </mod-up>
      </action>
    </animation>


These command lines allow to set the levers one by one (first the left one and after the right one, for example) by draging with the scroll wheel. I want to know how can I programm that both levers can be set at the same time, in order to produce a simetric throttle force in both engines at the same time.

Thanks!
Dris
 
Posts: 36
Joined: Thu Feb 17, 2022 10:34 pm

Re: Set both levers at same time.

Postby TheEagle » Sat Apr 09, 2022 2:07 pm

The first half of the code has absolutely nothing to do with the throttle adjustments - all the first two <animation>s with type rotate do is rotate the levers in response to the throttle command ! You only need to combine the two other animations (those with type pick) into one. So, replace this:
Code: Select all
     <animation>
      <type>pick</type>
      <object-name>ThrottleControl.L</object-name>
      <visible>true</visible>
      <action>
        <button>1</button>
        <repeatable>false</repeatable>
        <binding>
          <command>nasal</command>
          <script>SenecaII.mouseHandler.set( "/controls/engines/engine[0]/throttle", 0.01 );</script>
         </binding>
         <mod-up>
          <binding>
           <command>nasal</command>
           <script>SenecaII.mouseHandler.set()</script>
          </binding>
         </mod-up>
      </action>
    </animation>

    <animation>
      <type>pick</type>
      <object-name>ThrottleControl.R</object-name>
      <visible>true</visible>
      <action>
        <button>1</button>
        <repeatable>false</repeatable>
        <binding>
          <command>nasal</command>
          <script>SenecaII.mouseHandler.set( "/controls/engines/engine[1]/throttle", 0.01 );</script>
        </binding>
        <mod-up>
        <binding>
           <command>nasal</command>
           <script>SenecaII.mouseHandler.set()</script>
        </binding>
        </mod-up>
      </action>
    </animation>

with this:
Code: Select all
     <animation>
      <type>pick</type>
      <object-name>ThrottleControl.L</object-name>
      <object-name>ThrottleControl.R</object-name>
      <visible>true</visible>
      <action>
        <button>1</button>
        <repeatable>false</repeatable>
        <binding>
          <command>nasal</command>
          <script>
            SenecaII.mouseHandler.set( "/controls/engines/engine[0]/throttle", 0.01 );
            SenecaII.mouseHandler.set( "/controls/engines/engine[1]/throttle", 0.01 );
          </script>
         </binding>
         <mod-up>
          <binding>
           <command>nasal</command>
           <script>SenecaII.mouseHandler.set()</script>
          </binding>
         </mod-up>
      </action>
    </animation>

(should work - but didn't test it). But while you are at it, you could as well delete the whole code part you posted and use this instead:
Code: Select all
    <animation>
        <type>knob</type>
        <object-name>ThrottleControl.L</object-name>
        <property>controls/engines/engine[0]/throttle</property>
        <factor>45.0</factor>
        <axis>
            <x1-m>-1.87609</x1-m>
            <y1-m>1</y1-m>
            <z1-m>1.24033</z1-m>
            <x2-m>-1.87609</x2-m>
            <y2-m>-1</y2-m>
            <z2-m>1.24033</z2-m>
        </axis>
        <action>
            <binding>
                <command>property-adjust</command>
                <property>controls/engines/engine[0]/throttle</property>
                <min>0</min>
                <max>1</max>
                <factor>0.01</factor>
            </binding>
            <binding>
                <command>property-adjust</command>
                <property>controls/engines/engine[1]/throttle</property>
                <min>0</min>
                <max>1</max>
                <factor>0.01</factor>
            </binding>
        </action>
        <shift-action>
            <binding>
                <command>property-adjust</command>
                <property>controls/engines/engine[0]/throttle</property>
                <min>0</min>
                <max>1</max>
                <factor>0.01</factor>
            </binding>
        </shift-action>
        <hovered>
            <binding>
               <command>set-tooltip</command>
               <tooltip>left-throttle</tooltip>
               <label>Left throttle: %d%%</label>
               <measure-text>Left throttle: 100%</measure-text>
               <property>controls/engines/engine[0]/throttle</property>
               <mapping>percent</mappin>
            </binding>
        </hovered>
    </animation>
    <animation>
        <type>knob</type>
        <object-name>ThrottleControl.R</object-name>
        <property>controls/engines/engine[1]/throttle</property>
        <factor>45.0</factor>
        <axis>
            <x1-m>-1.87609</x1-m>
            <y1-m>1</y1-m>
            <z1-m>1.24033</z1-m>
            <x2-m>-1.87609</x2-m>
            <y2-m>-1</y2-m>
            <z2-m>1.24033</z2-m>
        </axis>
        <action>
            <binding>
                <command>property-adjust</command>
                <property>controls/engines/engine[1]/throttle</property>
                <min>0</min>
                <max>1</max>
                <factor>0.01</factor>
            </binding>
            <binding>
                <command>property-adjust</command>
                <property>controls/engines/engine[0]/throttle</property>
                <min>0</min>
                <max>1</max>
                <factor>0.01</factor>
            </binding>
        </action>
        <shift-action>
            <binding>
                <command>property-adjust</command>
                <property>controls/engines/engine[1]/throttle</property>
                <min>0</min>
                <max>1</max>
                <factor>0.01</factor>
            </binding>
        </shift-action>
        <hovered>
            <binding>
               <command>set-tooltip</command>
               <tooltip>right-throttle</tooltip>
               <label>Right throttle: %d%%</label>
               <measure-text>Right throttle: 100%</measure-text>
               <property>controls/engines/engine[1]/throttle</property>
               <mapping>percent</mappin>
            </binding>
        </hovered>
    </animation>


This uses the more modern knob animation instead of the old-fashioned combination of pick and rotate animation, but is also better to use:
  • Usually you want to adjust the throttle of both engines equally. For that, on any of the two levers, either drag, or scroll, or left-click to increase and middle-click to decrease.
  • But if you really want to adjust only one throttle, you can still do that as well - just put your mouse on the respective lever and hold down Shift while scrolling or dragging or clicking !
  • Additionally, each lever now displays it's current setting in percent in a tooltip when you put your mouse over it.

BTW - it would be great if this modification could be merged into FGAddon.
Cessna 210 (Wiki)
My other aircraft: my wiki profile !
Other: FGTools (GitHub)
World tour: View on SkyVector
Please consider donating $1 / €1 to help me finance a new camera !
User avatar
TheEagle
 
Posts: 3411
Joined: Sat May 01, 2021 3:27 pm
Location: France
Pronouns: You, he
Callsign: F-EAGLE
IRC name: none
Version: Git next
OS: Ubuntu Studio 22.04

Re: Set both levers at same time.

Postby Dris » Sat Apr 09, 2022 2:50 pm

Hi TheEagle!

The first one doesn`t work. When I set the levers only the right one moves and only the right throttle increases.
Image

The second code doesn't work. When I launch the plane with this code, the plane doesn't appear.
Image
Dris
 
Posts: 36
Joined: Thu Feb 17, 2022 10:34 pm

Re: Set both levers at same time.  

Postby TheEagle » Sat Apr 09, 2022 3:29 pm

For the first code, I have no clue why it doesn't move both levers …
For the second, I missed a "g" in a closing tag which caused a mismatched tag error while loading the model … sorry for that. This should work:
Code: Select all
    <animation>
        <type>knob</type>
        <object-name>ThrottleControl.L</object-name>
        <property>controls/engines/engine[0]/throttle</property>
        <factor>45.0</factor>
        <axis>
            <x1-m>-1.87609</x1-m>
            <y1-m>1</y1-m>
            <z1-m>1.24033</z1-m>
            <x2-m>-1.87609</x2-m>
            <y2-m>-1</y2-m>
            <z2-m>1.24033</z2-m>
        </axis>
        <action>
            <binding>
                <command>property-adjust</command>
                <property>controls/engines/engine[0]/throttle</property>
                <min>0</min>
                <max>1</max>
                <factor>0.01</factor>
            </binding>
            <binding>
                <command>property-adjust</command>
                <property>controls/engines/engine[1]/throttle</property>
                <min>0</min>
                <max>1</max>
                <factor>0.01</factor>
            </binding>
        </action>
        <shift-action>
            <binding>
                <command>property-adjust</command>
                <property>controls/engines/engine[0]/throttle</property>
                <min>0</min>
                <max>1</max>
                <factor>0.01</factor>
            </binding>
        </shift-action>
        <hovered>
            <binding>
               <command>set-tooltip</command>
               <tooltip>left-throttle</tooltip>
               <label>Left throttle: %d%%</label>
               <measure-text>Left throttle: 100%</measure-text>
               <property>controls/engines/engine[0]/throttle</property>
               <mapping>percent</mapping>
            </binding>
        </hovered>
    </animation>
    <animation>
        <type>knob</type>
        <object-name>ThrottleControl.R</object-name>
        <property>controls/engines/engine[1]/throttle</property>
        <factor>45.0</factor>
        <axis>
            <x1-m>-1.87609</x1-m>
            <y1-m>1</y1-m>
            <z1-m>1.24033</z1-m>
            <x2-m>-1.87609</x2-m>
            <y2-m>-1</y2-m>
            <z2-m>1.24033</z2-m>
        </axis>
        <action>
            <binding>
                <command>property-adjust</command>
                <property>controls/engines/engine[1]/throttle</property>
                <min>0</min>
                <max>1</max>
                <factor>0.01</factor>
            </binding>
            <binding>
                <command>property-adjust</command>
                <property>controls/engines/engine[0]/throttle</property>
                <min>0</min>
                <max>1</max>
                <factor>0.01</factor>
            </binding>
        </action>
        <shift-action>
            <binding>
                <command>property-adjust</command>
                <property>controls/engines/engine[1]/throttle</property>
                <min>0</min>
                <max>1</max>
                <factor>0.01</factor>
            </binding>
        </shift-action>
        <hovered>
            <binding>
               <command>set-tooltip</command>
               <tooltip>right-throttle</tooltip>
               <label>Right throttle: %d%%</label>
               <measure-text>Right throttle: 100%</measure-text>
               <property>controls/engines/engine[1]/throttle</property>
               <mapping>percent</mapping>
            </binding>
        </hovered>
    </animation>
Cessna 210 (Wiki)
My other aircraft: my wiki profile !
Other: FGTools (GitHub)
World tour: View on SkyVector
Please consider donating $1 / €1 to help me finance a new camera !
User avatar
TheEagle
 
Posts: 3411
Joined: Sat May 01, 2021 3:27 pm
Location: France
Pronouns: You, he
Callsign: F-EAGLE
IRC name: none
Version: Git next
OS: Ubuntu Studio 22.04

Re: Set both levers at same time.

Postby Dris » Sat Apr 09, 2022 3:39 pm

Hi TheEagle!

Now It works perfectly! A lot of thanks! You are awesome!
Dris
 
Posts: 36
Joined: Thu Feb 17, 2022 10:34 pm

Re: Set both levers at same time.

Postby TheEagle » Sat Apr 09, 2022 3:41 pm

No problem ! :) Please do not forget to mark this topic as "Solved" ! :wink:
Cessna 210 (Wiki)
My other aircraft: my wiki profile !
Other: FGTools (GitHub)
World tour: View on SkyVector
Please consider donating $1 / €1 to help me finance a new camera !
User avatar
TheEagle
 
Posts: 3411
Joined: Sat May 01, 2021 3:27 pm
Location: France
Pronouns: You, he
Callsign: F-EAGLE
IRC name: none
Version: Git next
OS: Ubuntu Studio 22.04


Return to Compiling

Who is online

Users browsing this forum: No registered users and 3 guests