Board index FlightGear Support Hardware

Map axis to view direction?

Joysticks, pedals, monitors.

Re: Map axis to view direction?

Postby wkitty42 » Thu Feb 15, 2018 3:59 pm

the GUI does two things...

1. IF you change any options from their defaults, the GUI copies the xml file to the $FGHOME/Input/Joysticks directory and applies the changes.

2. the GUI allows you to assign specific actions to the available buttons and axises that are recognized.

if you need something that is not an action or option available in the GUI, then you have to manually edit the file in $FGHOME/Input/Joysticks to add that action or option... an example of this might be to apply a certain amount of acceleration so the further you move the stick, the sharper the movement is instead of it being linear... another option would be to reduce the sensitivity of the stick so you have to move it further...

if you need something that is not an action or option available in the GUI and the necessary joystick file does not exist in $FGHOME/Input/Joysticks, then you need to manually copy the necessary file from $FGDATA/Input/Joysticks to $FGHOME/Input/Joysticks so you can edit it...

does that help?
Last edited by wkitty42 on Thu Feb 15, 2018 4:03 pm, edited 1 time in total.
"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: 4674
Joined: Fri Feb 20, 2015 3:46 pm
Location: central NC, USA
Callsign: wk42
Version: git next
OS: Kubuntu 14.04.5

Re: Map axis to view direction?

Postby Richard » Thu Feb 15, 2018 4:02 pm

By an uncanny stroke of luck I happen to be working on the joystick configuration at the moment; so I can add this directly.

View Vertical Axis and View Horizontal axis will map +/- 180 to the selected joystick axis.

Image
Richard
 
Posts: 601
Joined: Sun Nov 02, 2014 10:17 pm
Version: Git
OS: Win10

Re: Map axis to view direction?

Postby panash » Thu Feb 15, 2018 5:09 pm

Yes, I have been deleting the copied data in
C:\Users\{Your username}\AppData\Roaming\flightgear.org\input\joysticks
to force a refresh from the flightgear install directory.

However I can't get

<name>vJoy Device</name>
<axis n="0">
<desc>6DOFYaw</desc>
<binding>
<command>property-scale</command>
<property>/sim/current-view/goal-heading-offset-deg</property>
<factor type="double">180.0</factor>
</binding>
</axis>

to work
panash
 
Posts: 23
Joined: Thu Oct 30, 2014 3:02 pm

Re: Map axis to view direction?

Postby sim » Thu Feb 15, 2018 11:20 pm

User avatar
sim
 
Posts: 1381
Joined: Tue Jun 30, 2009 2:13 pm
Location: Shropshire England
Callsign: Fly4Fun
Version: 0.9.10 up
OS: 64 Win 10 HD6450

Re: Map axis to view direction?

Postby panash » Fri Feb 16, 2018 8:57 am

That's where I copied and pasted it from but it doesn't work for me. The only difference is the "vJoy" virtual device.
panash
 
Posts: 23
Joined: Thu Oct 30, 2014 3:02 pm

Re: Map axis to view direction?

Postby panash » Fri Feb 16, 2018 9:24 am

in fact newforestroadwarrior has done exactly what I want to do but I just can't consistently get the joystick axis to connect to the FG simulation engine.
panash
 
Posts: 23
Joined: Thu Oct 30, 2014 3:02 pm

Re: Map axis to view direction?

Postby panash » Sat Feb 17, 2018 4:14 pm

I've got it; I've got it; I've got it. I need to edit/create three files and put the following in

1) $FG_ROOT/Input/Joysticks/default/joysticks.xml
Code: Select all
<?xml version="1.0"?>
<!--
************************************************************************
Default joystick bindings.
pulls in vJoy virtual joystick driver
and
PPM (Pulse Position Modulation) Radio Control Transmitter style joystick
File: $FG_ROOT/Input/Joysticks/default/joysticks.xml
************************************************************************
$Id$
-->

<PropertyList>
  <name>default</name>
  <js n="0" include="Input/Joysticks/vJoy/vJoy.xml"/>
  <js n="1" include="Input/Joysticks/PPM/PPM.xml"/>
</PropertyList>

<!-- end of joystick.xml -->


2) $FG_ROOT/Input/Joysticks/vJoy/vJoy.xml
Code: Select all
<?xml version="1.0"?>

<!--
************************************************************************
VJoy Virtual joystick bindings.

Assigned to heading, pitch and field of view (zoom) views
File: $FG_ROOT/Input/Joysticks/vJoy/vJoy.xml
************************************************************************
$Id$
-->

<PropertyList>

<name>vJoy Device</name>
<axis n="0">
<desc>6DOFYaw</desc>
<binding>
<command>property-scale</command>
<property>/sim/current-view/goal-heading-offset-deg</property>
<factor type="double">180.0</factor>
</binding>
</axis>

<axis n="1">
<desc>pitch</desc>
<binding>
<command>property-scale</command>
<property>/sim/current-view/goal-pitch-offset-deg</property>
<factor type="double">180.0</factor>
</binding>
</axis>

<axis n="2">
<desc>FoV</desc>
<binding>
<command>property-scale</command>
<property>/sim/current-view/field-of-view</property>
      <offset type="double">-2</offset>
<factor type="double">-30</factor>
</binding>
</axis>


</PropertyList>

<!-- end of vJoy.xml -->


3) $FG_ROOT/Input/Joysticks/PPM/PPM.xml
Code: Select all
<?xml version="1.0"?>
************************************************************************
PPM (Pulse Position Modulation) Radio Control Transmitter style joystick
File: $FG_ROOT/Input/Joysticks/PPM/PPM.xml
************************************************************************

<PropertyList>
  <name type="string">PPM</name>
  <axis n="0">
    <desc type="string">Aileron</desc>
    <binding>
      <command type="string">property-scale</command>
      <property type="string">/controls/flight/aileron</property>
      <dead-band type="double">0</dead-band>
      <factor type="double">1</factor>
      <offset type="double">0</offset>
    </binding>
  </axis>
  <axis n="1">
    <desc type="string">Elevator</desc>
    <binding>
      <command type="string">property-scale</command>
      <property type="string">/controls/flight/elevator</property>
      <dead-band type="double">0</dead-band>
      <factor type="double">1</factor>
      <offset type="double">0</offset>
    </binding>
  </axis>
 
<axis n="2">
    <desc type="string">Throttle</desc>
    <direction type="string">forward</direction>
    <binding>
      <command type="string">nasal</command>
      <script type="string">controls.throttleAxis(-1)</script>
      <module type="string">__js0</module>
    </binding>
    <!-- <binding n="1">
      <command type="string">property-scale</command>
      <property type="string">/controls/flight/throttle</property>
      <factor type="double">1</factor>
      <setting type="double">0.619043231</setting>
    </binding> -->
  </axis>

  <axis n="3">
    <desc type="string">Rudder</desc>
    <binding>
      <command type="string">property-scale</command>
      <property type="string">/controls/flight/rudder</property>
      <dead-band type="double">0</dead-band>
      <factor type="double">1</factor>
      <offset type="double">0</offset>
    </binding>
  </axis>
  <axis n="4">
    <desc type="string">flaps</desc>
    <direction type="string">forward</direction>
    <binding>
      <command type="string">nasal</command>
      <script type="string">controls.flapsAxis(1)</script>
      <module type="string">__js0</module>
      <setting type="double">0.3412680328</setting>
    </binding>
    <binding n="1">
      <command type="string">property-scale</command>
      <property type="string">/controls/flight/flaps</property>
      <factor type="double">-1</factor>
      <setting type="double">0.3412680328</setting>
    </binding>
  </axis>
</PropertyList>



It works well enough to form a starting point for writing the head tracking code in Python. The coefficients & offsets will need working on as does the "flaps" and later the "gear" axis.

Google "6CH USB 3D RC Helicopter Airplane Flight Simulator A2P4" for my "transmitter"
panash
 
Posts: 23
Joined: Thu Oct 30, 2014 3:02 pm

Re: Map axis to view direction?

Postby sim » Sat Feb 17, 2018 11:16 pm

Well done Panash,
So you now can pan view left/right and up/down and zoom view in/out too. Best resist the temptation to get airbourne while the aileron elevator etc are controlling view movements instead of flying control cables! :lol:

Once converted my own Aviator.xml so waggling the stick moved the views.
User avatar
sim
 
Posts: 1381
Joined: Tue Jun 30, 2009 2:13 pm
Location: Shropshire England
Callsign: Fly4Fun
Version: 0.9.10 up
OS: 64 Win 10 HD6450

Previous

Return to Hardware

Who is online

Users browsing this forum: No registered users and 3 guests