Board index FlightGear Support Hardware

Parking break with Xbox One Controller

Joysticks, pedals, monitors.

Parking break with Xbox One Controller

Postby Ninoky43 » Thu May 13, 2021 7:11 pm

Hello,
I am currently using an Xbox One controller with Flight Gear 2020.8.3 on windows 10, trying to fly with a Cessna 172. Everything seems to be working except the parking break command.

Here is the code in the .xml file (took it from here : viewtopic.php?t=29576# and only changed the controller's name):

Code: Select all
<?xml version="1.0" ?>
<!--
**************X360 Controller for Windows layout****************

Axes 0,1 (Left-stick):          View direction and elevation
Axis 2 (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 8 (Press left-stick):    Reset view

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

<PropertyList>

<name>Controller (Xbox One For Windows)</name>

<axis n="0">
  <desc>View Direction</desc>
  <low>
   <repeatable>true</repeatable>
   <binding>
    <command>property-adjust</command>
    <property>/sim/current-view/goal-heading-offset-deg</property>
    <step type="double">2</step>
   </binding>
  </low>
  <high>
   <repeatable>true</repeatable>
   <binding>
    <command>property-adjust</command>
    <property>/sim/current-view/goal-heading-offset-deg</property>
    <step type="double">-2</step>
   </binding>
  </high>
</axis>

<axis n="1">
  <desc>View Elevation</desc>
  <low>
   <repeatable>true</repeatable>
   <binding>
    <command>property-adjust</command>
    <property>/sim/current-view/goal-pitch-offset-deg</property>
    <step type="double">-1</step>
   </binding>
  </low>
  <high>
   <repeatable>true</repeatable>
   <binding>
    <command>property-adjust</command>
    <property>/sim/current-view/goal-pitch-offset-deg</property>
    <step type="double">1</step>
   </binding>
  </high>
</axis>

<axis n="2">
  <desc>Rudder</desc>
  <binding>
   <command>property-scale</command>
   <property>/controls/flight/rudder</property>
   <factor type="double">-1.0</factor>
  </binding>
</axis>

<axis n="3">
  <desc>Elevator</desc>
  <binding>
   <command>property-scale</command>
   <property>/controls/flight/elevator</property>
   <factor type="double">-1.0</factor>
   <squared type="bool">true</squared>
  </binding>
</axis>

<axis n="4">
  <desc>Aileron</desc>
  <binding>
   <command>property-scale</command>
   <property>/controls/flight/aileron</property>
   <squared type="bool">true</squared>
  </binding>
</axis>

<axis n="6">
  <desc>Aileron trim</desc>
  <low>
   <repeatable>true</repeatable>
   <binding>
    <command>property-adjust</command>
    <property>/controls/flight/aileron-trim</property>
    <step type="double">-0.002</step>
   </binding>
  </low>
  <high>
   <repeatable>true</repeatable>
   <binding>
    <command>property-adjust</command>
    <property>/controls/flight/aileron-trim</property>
    <step type="double">0.002</step>
   </binding>
  </high>
</axis>

<axis n="7">
  <desc>Elevator trim</desc>
  <low>
   <repeatable>true</repeatable>
   <binding>
    <command>property-adjust</command>
    <property>/controls/flight/elevator-trim</property>
    <step type="double">-1.5</step>
   </binding>
  </low>
  <high>
   <repeatable>true</repeatable>
   <binding>
    <command>property-adjust</command>
    <property>/controls/flight/elevator-trim</property>
    <step type="double">1.5</step>
   </binding>
  </high>
</axis>

<button n="0">
  <desc>Flaps Down</desc>
  <repeatable>false</repeatable>
  <binding>
   <command>nasal</command>
   <script>controls.flapsDown(1)</script>
  </binding>
  <mod-up>
   <binding>
    <command>nasal</command>
    <script>controls.flapsDown(0)</script>
   </binding>
  </mod-up>
</button>

<button n="1">
  <desc>Brakes</desc>
  <binding>
   <command>nasal</command>
   <script>controls.applyBrakes(1)</script>
  </binding>
  <mod-up>
   <binding>
    <command>nasal</command>
    <script>controls.applyBrakes(0)</script>
   </binding>
  </mod-up>
</button>

<button n="2">
  <desc>Flaps Up</desc>
  <repeatable>false</repeatable>
  <binding>
   <command>nasal</command>
   <script>controls.flapsDown(-1)</script>
  </binding>
  <mod-up>
   <binding>
    <command>nasal</command>
    <script>controls.flapsDown(0)</script>
   </binding>
  </mod-up>
</button>

<button n="3">
  <desc>Parking brake</desc>
  <repeatable type="bool">false</repeatable>
  <binding>
   <command>nasal</command>
   <script>
   var pb = !getprop("/controls/gear/brake-parking");
   pb = pb!;
   setprop ("/controls/gear/brake-parking",pb);
   </script>
  </binding>
</button>

<button n="4">
  <desc>Decrease throttle</desc>
  <repeatable type="bool">true</repeatable>
  <binding>
   <command>nasal</command>
   <script>
     controls.incThrottle(-0.01, -1.0)
   </script>
  </binding>
 </button>

<button n="5">
  <desc>Increase throttle</desc>
  <repeatable type="bool">true</repeatable>
  <binding>
   <command>nasal</command>
   <script>
     controls.incThrottle(0.01, 1.0)
   </script>
  </binding>
<mod-shift>
   <desc>full throttle</desc>
   <repeatable type="bool">true</repeatable>
  <binding>
   <command>nasal</command>
   <script>
     props.setAll("/controls/engines/engine", "throttle", 1)
   </script>
  </binding>
  </mod-shift>
  </button>

<button n="6">
  <desc>Landing gear toggle</desc>
  <repeatable type="bool">false</repeatable>
  <binding>
   <command>nasal</command>
   <script>
   controls.gearToggle()
   </script>
  </binding>
</button>

<button n="7">
  <desc>Pause</desc>
  <repeatable type="bool">false</repeatable>
  <binding>
   <command>nasal</command>
   <script>
   var p =getprop ("/sim/freeze/master");
   p = !p;
   setprop ("sim/freeze/master",p);
   setprop ("sim/freeze/clock",p)
   </script>
  </binding>
</button>

<button n="8">
  <desc>Center View</desc>
  <repeatable type="bool">false</repeatable>
  <binding>
   <command>nasal</command>
   <script>view.resetView()</script>
  </binding>
</button>

</PropertyList>


As I said, everything else seems to be working.

The button on the controller should be Y, as it is recognised directly in FlightGear and I can't figure out why the parking brake doesn't move when I press it...
I tried to look up for the button number via js_demo. The controller is detected but none of the buttons get displayed in the program when I press them; even though they work fine in FlightGear.

(And yes, I can use shift+b on the keyboard, it works, but I was just wondering if there was any fix for the controller :mrgreen: )


Any clue on what's wrong here ?
Thanks
Ninoky43
 
Posts: 2
Joined: Thu May 13, 2021 6:26 pm
Location: France
Version: 2020.8.3
OS: Windows 10

Re: Parking break with Xbox One Controller

Postby wkitty42 » Thu May 13, 2021 7:21 pm

IIRC, the c172p doesn't use the standard built in method for the parking brake... someone else was wanting to do the same as you but adding it to one of their joystick buttons... i don't recall what they had to do but it was a little custom code in the xml to make it work like the c172p is expecting... you should be able to search it out using the forum's search and the terms "c172p joystick parking brake"... i think that should find it for you... then you would modify what you have in a similar fashion...

NOTE that the file you used is really old and likely from before the c172p's reworking and updating... there was a lot changed during that process so it is very possible that old techniques just don't work any more...
"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

Re: Parking break with Xbox One Controller

Postby Ninoky43 » Thu May 13, 2021 8:16 pm

Thanks !

I finally managed to find the post with working code.
The parking brake is now working as it should be :D

Here is the link to the post : viewtopic.php?f=4&t=25157&hilit=c172p+joystick+parking+brake&start=2415#p263496

And here is the code provided by @someguy :

Code: Select all
<button n="12">
       <desc>Parking Brake</desc>
       <binding>
          <command>nasal</command>
          <script>
             brake = !getprop("/controls/gear/brake-parking");
             if (brake) {
                gui.popupTip("Parking Brake ON");
             } else {
                gui.popupTip("Parking Brake OFF");
             }
             controls.applyParkingBrake(1)
          </script>
       </binding>
    </button>


Thanks again for your reply
Ninoky43
 
Posts: 2
Joined: Thu May 13, 2021 6:26 pm
Location: France
Version: 2020.8.3
OS: Windows 10


Return to Hardware

Who is online

Users browsing this forum: nerdjuice and 9 guests