Board index FlightGear Support Hardware

Joysticks on the HID layer

Joysticks, pedals, monitors.

Joysticks on the HID layer

Postby eatdirt » Thu Sep 23, 2021 10:35 pm

Hi there,
I am trying to make my HOTAS throttle control working under the HID layer, in the hope of making the LEDS easily controllable. Currently, that throttle is supported by FG-ROOT/Input/Joysticks/ThrustMaster/Warthog/Warthog-Throttle.xml, but the LEDS won't work, possibly due to FG no longer allowing writes on /dev/hidraw.

Anyway, I am getting rapidly into troubles in trying to make the HID layer working. Here the recipe to start, thanks to the dev mailing list:

1) Disable the event input and activate a lot of logs (to be able to read the name of the axis and buttons).

Code: Select all
fgfs --aircraft=UFO --log-class=input --log-level=debug --prop:/sim/input/no-event-input=true


2) Make the standard joystick input doing nothing by creating, for instance, an empty configuration file within

Code: Select all
FG-HOME/Input/Joysticks


in my case:
Code: Select all
FG-HOME/Input/Joysticks/Thrustmaster-Throttle---HOTAS-Warthog.xml
which only contains:

Code: Select all
<?xml version="1.0"?>
 <PropertyList>
  <name type="string">Thrustmaster Throttle - HOTAS Warthog</name>
</PropertyList>




3) Create a new xml config file for the HID layer there:

Code: Select all
FG-HOME/Input/Event


in my case:
Code: Select all
FG-HOME/Input/Event/Thrustmaster/Warthog/HOTAS_Warthog_Throttle.xml


That guy currently reads:
Code: Select all
<PropertyList>
  <name>Thrustmaster Throttle - HOTAS Warthog</name>
  <debug-events type="bool">true</debug-events>

  <nasal>
    <script>
      var left_engines = [0, 2, 4, 6, 8, 10];
      var right_engines = [1, 3, 5, 7, 9, 11];
    </script>   
  </nasal>

<event>
    <name>abs-z-translate</name>
    <desc>Right throttle</desc>
    <factor type="double">6.1039e-05</factor>
    <binding>
      <command>nasal</command>
      <script>controls.perEngineSelectedAxisHandler(0)(right_engines);</script>
    </binding>
  </event>

  <event>
    <name>abs-z-rotate</name>
    <desc>Left throttle</desc>
    <factor type="double">6.1039e-05</factor>
    <binding>
      <command>nasal</command>
      <script>controls.perEngineSelectedAxisHandler(0)(left_engines);</script>
    </binding>
  </event>
 
 



4) Start flightgear with the above-mentioned options, checkout the property tree, devices appear in
Code: Select all
/input/event


Inside the tree, the bindings and various other subtrees appear.

Problems:
a) The "setting" value returned in the property tree ranges from the raw bits output by the joystick, e.g. from 0 to 16383, not within [0,1]. Its name is "setting" and not "value".
b) When I do bind directly to the property tree, it seems to work (I've tested with the rudder), but the above piece of code for the HOTAS throttle simply does nothing, in spite of "setting" varying when I am moving the throttles. It looks like the nasal script is either skipped or do not take the right argument?

Any advice welcome.

Cheers,
Chris.
eatdirt
 
Posts: 1012
Joined: Wed Aug 15, 2018 3:06 pm

Return to Hardware

Who is online

Users browsing this forum: No registered users and 4 guests