Board index FlightGear Support Hardware

Where to find "controls.throttleAxis()"

Joysticks, pedals, monitors.

Where to find "controls.throttleAxis()"

Postby Olaf Rogat » Sun Feb 05, 2023 3:13 pm

Hallo,

Configuring my "Honeycomb-Aeronautical-Bravo-Throttle-Quadrant" I wrote a configuration file containing the following:

Code: Select all
  <axis n="0">
       <desc>Throttle</desc>
       <binding>
           <command>nasal</command>
           <script>
                   controls.throttleAxis(1);
           </script>
       </binding>
   </axis>


This code works in principle but the direction of the Axis has to be turned and the "1" as an argument does not help. Therefore I tried to find the definition of the function by inserting a "print();" statement.
A "print();" command right after the function call in the configuration file works fine. After that I run a grep command

/usr/share/games/flightgear> grep -r -i "controls.throttle"

and receive the information that the definition can be found in

/usr/share/flightgear/Aircraft/c172p/Nasal/engine.nas.

Any attempt to add a "pritn()" statement in this file does not give any result.

Does anybody know where I can find the definition code of "controls.throttleAxis()" to be able to adjust the code for my needs?

I am running:

FlightGear version: 2020.3.6
SimGear version: 2020.3.6
OSG version: 3.6.5
PLIB version: 185

Aircraft: C172p

Ubuntu 22.04.1 LTS

Thanks for help
best regards
Olaf
Olaf Rogat
 
Posts: 4
Joined: Fri Nov 12, 2021 11:12 am

Re: Where to find "controls.throttleAxis()"

Postby Alant » Sun Feb 05, 2023 4:58 pm

fgdata/nasal/controls.nas line 118, and see comment at line 108.
Alan
Alant
 
Posts: 1223
Joined: Wed Jun 23, 2010 6:58 am
Location: Portugal
Callsign: Tarnish99
Version: latest Git
OS: Windows 10/11

Re: Where to find "controls.throttleAxis()"

Postby Olaf Rogat » Mon Feb 06, 2023 7:14 pm

Alant wrote in Sun Feb 05, 2023 4:58 pm:fgdata/nasal/controls.nas line 118, and see comment at line 108.
Alan


Dear Alant,

thank you for your quick answer. I tried to fill in a print(".."); command in

Code: Select all
107 # Joystick axis handlers (use cmdarg).  Shouldn't be called from
108 # other contexts.  A non-null argument reverses the axis direction.
109 var axisHandler = func(pre, post) {
110     func(invert = 0) {
           print("Message from axisHandler");      #################### <--- inserted print command
111         var val = cmdarg().getNode("setting").getValue()(;
112         if(invert) val = -val;
113         foreach(var e; engines)
114             if(e.selected.getValue())
115                 setprop(pre ~ e.index ~ post, (1 - val) / 2);
116     }
117 }
118

but did not received a console output.

I am really a novice in NASAL; so, I thought that there should be a bit of code that will be executed every time "controls.throttle()" is invoked. But I can't find it.

Best regards
Olaf
Olaf Rogat
 
Posts: 4
Joined: Fri Nov 12, 2021 11:12 am


Return to Hardware

Who is online

Users browsing this forum: No registered users and 3 guests