Board index FlightGear Support Hardware

Xbox Controller

Joysticks, pedals, monitors.

Xbox Controller

Postby Egod » Wed Nov 02, 2022 7:45 pm

Hi, How would I connect an Xbox controller as a Joystick.
Egod
 
Posts: 4
Joined: Wed Nov 02, 2022 7:41 pm

Re: Xbox Controller

Postby property_tree » Wed Nov 02, 2022 11:09 pm

From my experience, it should just detect it, and allow you to configure it with the joystick options, which can be found in the first menu in the top bar menu.

You'll get a window with a drop down menu that lists all detected control devices, choose your gamepad there.
It will use a default configuration, which on your computer is saved as an XML file, and this default will be changed to a specialized one if you change any button or axis configuration.

This specific configuration file is also an XML file, and will be named after your device.

The creation of this file is automatic whenever you change a setting.

There is a way to do advanced fine tuning by editing that generated, specific configuration file, but if you do that while the program is still running, then you have to reload the inputs via the 'debug' menu entry in the top menu bar.

In other words, editing your joystick settings from within the running simulator, creates and changes a custom/specialized configuration file and overwrites it automatically. But it does not LOAD it automatically if you edit that file with a text editor outside of the program. You either need to restart flightgear or reload it via the debug menu. And if you have done your own editing with a text editor while the sim is running, and then, without reloading it with the debug menu, change button/axis bindings in the sim, your own outside changes will be overwritten immediately.
property_tree
 
Posts: 98
Joined: Wed Oct 26, 2022 1:13 pm

Re: Xbox Controller

Postby wkitty42 » Wed Nov 02, 2022 11:28 pm

Egod wrote in Wed Nov 02, 2022 7:45 pm:Hi, How would I connect an Xbox controller as a Joystick.

you just connect it and FG should detect it... the problem is whether FG has an appropriate XML file for it...

i've been using my xbox one controller with FG for about a year... the other day i sent james a copy of the xml file... hopefully it will be included in FG soon-ish... i use it with the UFO all the time... the only thing i know of that may require editing is to add more "name" properties if there are xbox controllers that do not identify themselves with the same ID as the name mine does...

i fly with the right stick and look with the left one... clicking down on the sticks resets the other's position... left trigger is rudder left, right trigger is rudder right... when the triggers are not squeezed, the rudder should be straight... this may require you to tune your stick in your OS... the bumpers or shoulders are the throttle up/down... everything is listed in the header, below... the reason you want to put a *copy* in the given directory is because if you use the in-sim configurator, it will remove that comment header and then you won't have a reference to look at for what does what...

i'll share it here as raw code, too... copy the code into a plain ASCII text file named exactly as "Microsoft-X-Box-One-S-pad.xml" without the quotes... place a copy of this file in your %APPDATA%/flightgear.org/Input/Joysticks directory... start FG and see if it works for you...

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

<!--
**************Microsoft X-box One S pad Controller layout****************

Axes 0,1 (Left-stick):            View direction and elevation
Axis 2,5 (Trigger buttons LT/RT): Rudder
Axis 3 (Right-stick U/D):         Elevator
Axis 4 (Right-stick L/R):         Ailerons
Axis 6 (D-pad L/R):               Aileron trim
Axis 7 (D-pad U/D):               Elevator trim

Button 0 (A):                     Flaps down
Button 1 (B):                     Brakes
Button 2 (X):                     Flaps up
Button 3 (Y):                     Park brake toggle
Button 4 (Left shoulder):         Throttle decrease
Button 5 (Right shoulder):        Throttle increase
Button 6 (Back):                  Landing gear toggle
Button 7 (Start):                 Pause
Button 9 (Press right-stick):     Reset view
Button 10 (Press left-stick):     Center controls

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

<PropertyList>
  <name type="string">Microsoft X-Box One S pad</name>
  <axis>
    <desc type="string">View Direction</desc>
    <low>
      <repeatable type="string">true</repeatable>
      <binding>
        <command type="string">property-adjust</command>
        <property type="string">/sim/current-view/goal-heading-offset-deg</property>
        <step type="double">2</step>
      </binding>
    </low>
    <high>
      <repeatable type="string">true</repeatable>
      <binding>
        <command type="string">property-adjust</command>
        <property type="string">/sim/current-view/goal-heading-offset-deg</property>
        <step type="double">-2</step>
      </binding>
    </high>
  </axis>
  <axis n="1">
    <desc type="string">View Elevation</desc>
    <low>
      <repeatable type="string">true</repeatable>
      <binding>
        <command type="string">property-adjust</command>
        <property type="string">/sim/current-view/goal-pitch-offset-deg</property>
        <step type="double">-1</step>
      </binding>
    </low>
    <high>
      <repeatable type="string">true</repeatable>
      <binding>
        <command type="string">property-adjust</command>
        <property type="string">/sim/current-view/goal-pitch-offset-deg</property>
        <step type="double">1</step>
      </binding>
    </high>
  </axis>
  <axis n="2">
    <desc type="string">Rudder</desc>
    <binding>
      <command type="string">property-scale</command>
      <property type="string">/controls/flight/rudder</property>
      <factor type="double">-1</factor>
      <offset type="double">0</offset>
      <power type="double">1</power>
    </binding>
  </axis>
  <axis n="3">
    <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="4">
    <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="5">
    <desc type="string">Rudder</desc>
    <binding>
      <command type="string">property-scale</command>
      <property type="string">/controls/flight/rudder</property>
      <factor type="double">1</factor>
      <offset type="double">0</offset>
      <power type="double">1</power>
    </binding>
  </axis>
  <axis n="6">
    <desc type="string">Aileron trim</desc>
    <low>
      <repeatable type="string">true</repeatable>
      <binding>
        <command type="string">property-adjust</command>
        <property type="string">/controls/flight/aileron-trim</property>
        <step type="double">-0.002</step>
      </binding>
    </low>
    <high>
      <repeatable type="string">true</repeatable>
      <binding>
        <command type="string">property-adjust</command>
        <property type="string">/controls/flight/aileron-trim</property>
        <step type="double">0.002</step>
      </binding>
    </high>
  </axis>
  <axis n="7">
    <desc type="string">Elevator trim</desc>
    <low>
      <repeatable type="string">true</repeatable>
      <binding>
        <command type="string">property-adjust</command>
        <property type="string">/controls/flight/elevator-trim</property>
        <step type="double">-1.5</step>
      </binding>
    </low>
    <high>
      <repeatable type="string">true</repeatable>
      <binding>
        <command type="string">property-adjust</command>
        <property type="string">/controls/flight/elevator-trim</property>
        <step type="double">1.5</step>
      </binding>
    </high>
  </axis>
  <button>
    <desc type="string">Flaps Down</desc>
    <binding>
      <command type="string">nasal</command>
      <script type="string">controls.flapsDown(1);</script>
    </binding>
    <repeatable type="double">0</repeatable>
  </button>
  <button n="1">
    <desc type="string">Brakes</desc>
    <repeatable type="string">false</repeatable>
    <binding>
      <command type="string">nasal</command>
      <script type="string">controls.applyBrakes(1);</script>
    </binding>
    <mod-up>
      <binding>
        <command type="string">nasal</command>
        <script type="string">controls.applyBrakes(0);</script>
      </binding>
    </mod-up>
  </button>
  <button n="2">
    <desc type="string">Flaps Up</desc>
    <binding>
      <command type="string">nasal</command>
      <script type="string">controls.flapsDown(-1);</script>
    </binding>
    <repeatable type="double">0</repeatable>
  </button>
  <button n="3">
    <desc type="string">Custom</desc>
    <repeatable type="bool">false</repeatable>
    <binding>
      <command type="string">nasal</command>
      <script type="string">
   var pb = getprop("/controls/gear/brake-parking");
   pb = !pb;
   setprop ("/controls/gear/brake-parking",pb)
   </script>
      <module type="string">__js0</module>
    </binding>
  </button>
  <button n="4">
    <desc type="string">Custom</desc>
    <repeatable type="bool">true</repeatable>
    <binding>
      <command type="string">property-adjust</command>
      <property type="string">/controls/engines/engine[0]/throttle</property>
      <step type="double">-0.01</step>
    </binding>
    <binding n="1">
      <command type="string">property-adjust</command>
      <property type="string">/controls/engines/engine[1]/throttle</property>
      <step type="double">-0.01</step>
    </binding>
    <binding n="2">
      <command type="string">property-adjust</command>
      <property type="string">/controls/engines/engine[2]/throttle</property>
      <step type="double">-0.01</step>
    </binding>
    <binding n="3">
      <command type="string">property-adjust</command>
      <property type="string">/controls/engines/engine[3]/throttle</property>
      <step type="double">-0.01</step>
    </binding>
    <binding n="4">
      <command type="string">property-adjust</command>
      <property type="string">/controls/engines/engine[4]/throttle</property>
      <step type="double">-0.01</step>
    </binding>
    <binding n="5">
      <command type="string">property-adjust</command>
      <property type="string">/controls/engines/engine[5]/throttle</property>
      <step type="double">-0.01</step>
    </binding>
    <binding n="6">
      <command type="string">property-adjust</command>
      <property type="string">/controls/engines/engine[6]/throttle</property>
      <step type="double">-0.01</step>
    </binding>
    <binding n="7">
      <command type="string">property-adjust</command>
      <property type="string">/controls/engines/engine[7]/throttle</property>
      <step type="double">-0.01</step>
    </binding>
  </button>
  <button n="5">
    <desc type="string">Custom</desc>
    <repeatable type="bool">true</repeatable>
    <binding>
      <command type="string">property-adjust</command>
      <property type="string">/controls/engines/engine[0]/throttle</property>
      <step type="double">0.01</step>
    </binding>
    <binding n="1">
      <command type="string">property-adjust</command>
      <property type="string">/controls/engines/engine[1]/throttle</property>
      <step type="double">0.01</step>
    </binding>
    <binding n="2">
      <command type="string">property-adjust</command>
      <property type="string">/controls/engines/engine[2]/throttle</property>
      <step type="double">0.01</step>
    </binding>
    <binding n="3">
      <command type="string">property-adjust</command>
      <property type="string">/controls/engines/engine[3]/throttle</property>
      <step type="double">0.01</step>
    </binding>
    <binding n="4">
      <command type="string">property-adjust</command>
      <property type="string">/controls/engines/engine[4]/throttle</property>
      <step type="double">0.01</step>
    </binding>
    <binding n="5">
      <command type="string">property-adjust</command>
      <property type="string">/controls/engines/engine[5]/throttle</property>
      <step type="double">0.01</step>
    </binding>
    <binding n="6">
      <command type="string">property-adjust</command>
      <property type="string">/controls/engines/engine[6]/throttle</property>
      <step type="double">0.01</step>
    </binding>
    <binding n="7">
      <command type="string">property-adjust</command>
      <property type="string">/controls/engines/engine[7]/throttle</property>
      <step type="double">0.01</step>
    </binding>
  </button>
  <button n="6">
    <desc type="string">Custom</desc>
    <repeatable type="bool">false</repeatable>
    <binding>
      <command type="string">nasal</command>
      <script type="string">
   controls.gearToggle()
   </script>
      <module type="string">__js0</module>
    </binding>
  </button>
  <button n="7">
    <desc type="string">Custom</desc>
    <repeatable type="bool">false</repeatable>
    <binding>
      <command type="string">nasal</command>
      <script type="string">
   var p =getprop ("/sim/freeze/master");
   p = !p;
   setprop ("sim/freeze/master",p);
   setprop ("sim/freeze/clock",p)
   </script>
      <module type="string">__js0</module>
    </binding>
  </button>
  <button n="9">
    <desc type="string">Center Controls</desc>
    <binding>
      <command type="string">nasal</command>
      <script type="string">controls.centerFlightControls();</script>
    </binding>
    <mod-ctrl>
      <desc type="string">Clear all trims</desc>
        <binding>
          <command type="string">property-assign</command>
          <property type="string">/controls/flight/elevator-trim</property>
          <value>0</value>
        </binding>
        <binding>
          <command type="string">property-assign</command>
          <property type="string">/controls/flight/aileron-trim</property>
          <value>0</value>
        </binding>
        <binding>
          <command type="string">property-assign</command>
          <property type="string">/controls/flight/rudder-trim</property>
          <value>0</value>
        </binding>
    </mod-ctrl>
  </button>
  <button n="10">
    <desc type="string">Custom</desc>
    <repeatable type="bool">false</repeatable>
    <binding>
      <command type="string">nasal</command>
      <script type="string">view.resetView()</script>
      <module type="string">__js0</module>
    </binding>
  </button>
</PropertyList>
"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: 9148
Joined: Fri Feb 20, 2015 4:46 pm
Location: central NC, USA
Callsign: wk42
Version: git next
OS: Kubuntu 20.04


Return to Hardware

Who is online

Users browsing this forum: No registered users and 6 guests