QQ登录

只需一步,快速开始

查看: 11433|回复: 3
打印 上一主题 下一主题

摇杆配置与XML编写

[复制链接]

主题

好友

26

积分

报考学院待录取

跳转到指定楼层
楼主
发表于 2016-11-8 21:04:52 |只看该作者 |倒序浏览
本帖最后由 VeyronC 于 2016-11-8 21:16 编辑

      USB 接上 Mad-Catz-FLY5-Stick 摇杆之后能自动识别到,默认状态下,油门、副翼、升降舵可用,方向舵等其他操作需要自己配置 xml 文件。
      进入 FG 后,点 Help -> Joystick Configuration,可以进入摇杆配置界面,里面可以查看路径和配置操作。
      若点击 ResetConfiguration,会自动使用 C:\ProgramFiles\FlightGear2.10.0.3\data\Input\Joysticks\Default\joystick.xml 下的配置文件。
      若更改配置后,会自动跳到 C:\FlightGear\flightgear-debug\Input\Joysticks\Mad-Catz-FLY5-Stick.xml (这个路径是之前用另一个版本自己编译的路径,为何跳这了?)
      点击 Refresh Joysticks 可以将更改保存。
      Configuration File 处显示了文件路径。
file:///C:/Users/cpr/AppData/Local/Temp/msohtmlclip1/01/clip_image002.png
      摇杆里的移动杆对应 xml 里的标签 <axis n="几"></axis>
      摇杆里的按键对应 xml 里的标签 <button n="几"></button>,对于赛钛客FLY5这款,对应按键上的数字是这里的 几+1。这个可以在上面的 Joystick Configuration 中试出来。
      根据示例代码设置,并参考FG文件夹里面的 data\keyboard.xml 文件来配置。因为FLY5这款的移动杆有限,那么方向舵我想用按键来设置,就先看 keybord.xml 中内容和方向舵移动有关的按键项<key>,对应移植过去给<button>标签之内即可。
   
<key n="364">
  
  <name>Insert</name>
  
  <desc>Move rudder left</desc>
  
  <repeatable type="bool">true</repeatable>
  
  <binding>
  
   <command>property-adjust</command>
  
   <property>/controls/flight/rudder</property>
  
   <step type="double">-0.05</step>
  
  </binding>
  
  
</key>
  
   
<button n="9">
  
    <desc type="string">Custom</desc>
  
    <repeatable type="bool">true</repeatable>
  
    <binding>
  
      <command type="string">property-adjust</command>
  
      <property type="string">/controls/flight/rudder</property>
  
      <step type="double">-0.05</step>
  
    </binding>
  
  
  </button>
  
      设置视角切换,可以在 JoysickConfiguration 中设置某个按键为 View Cycle Forwards。
      一套简易实用的自定义 xml 摇杆配置代码如下:
   
<?xml version="1.0"?>
  
  
<PropertyList>
  
  <name type="string">Mad Catz  F.L.Y.5 Stick</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>
  
    <binding>
  
      <command type="string">nasal</command>
  
      <script type="string">controls.throttleAxis();</script>
  
    </binding>
  
  </axis>
  
  
  <axis n="6">
  
    <desc type="string">View  (horizontal)</desc>
  
    <low>
  
      <binding>
  
        <command type="string">nasal</command>
  
        <script type="string">setprop("/sim/current-view/goal-heading-offset-deg", getprop("/sim/current-view/goal-heading-offset-deg") + 30);</script>
  
      </binding>
  
    </low>
  
    <high>
  
      <binding>
  
        <command type="string">nasal</command>
  
        <script type="string">setprop("/sim/current-view/goal-heading-offset-deg", getprop("/sim/current-view/goal-heading-offset-deg") - 30);</script>
  
      </binding>
  
    </high>
  
  </axis>
  
  
  <axis n="7">
  
    <desc type="string">View  (vertical)</desc>
  
    <low>
  
      <binding>
  
        <command type="string">nasal</command>
  
        <script type="string">setprop("/sim/current-view/goal-pitch-offset-deg", getprop("/sim/current-view/goal-pitch-offset-deg") - 20);</script>
  
      </binding>
  
    </low>
  
    <high>
  
      <binding>
  
        <command type="string">nasal</command>
  
        <script type="string">setprop("/sim/current-view/goal-pitch-offset-deg", getprop("/sim/current-view/goal-pitch-offset-deg") + 20);</script>
  
      </binding>
  
    </high>
  
  </axis>
  
  
  <button>
  
    <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="9">  <!--对应FLY5摇杆上按键10-->
  
    <desc type="string">Custom</desc>
  
    <repeatable type="bool">true</repeatable>
  
    <binding>
  
      <command type="string">property-adjust</command>
  
      <property type="string">/controls/flight/rudder</property>
  
      <step type="double">-0.05</step>
  
    </binding>
  
  </button>
  
  
  <button n="10">
  
    <desc type="string">Custom</desc>
  
    <repeatable type="bool">true</repeatable>
  
    <binding>
  
      <command type="string">property-adjust</command>
  
      <property type="string">/controls/flight/rudder</property>
  
      <step type="double">0.05</step>
  
    </binding>
  
  </button>
  
  
  <button n="13">
  
    <desc type="string">View Cycle  Forwards</desc>
  
    <binding>
  
      <command type="string">nasal</command>
  
      <script type="string">view.stepView(1);</script>
  
    </binding>
  
    <repeatable type="double">0</repeatable>
  
  </button>
  
</PropertyList>
  
  

FlightGear摇杆配置与XML编写.pdf

422.36 KB, 下载次数: 18, 下载积分: 金钱 -2

分享到: QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
分享分享0 收藏收藏0

主题

好友

55

积分

航院新生

沙发
发表于 2018-4-8 17:20:39 |只看该作者
讲的很清楚,谢谢分享!
回复

使用道具 举报

主题

好友

56

积分

航院新生

板凳
发表于 2018-4-9 11:19:19 |只看该作者
写的很好,多谢楼主分享
回复

使用道具 举报

主题

好友

16

积分

报考学院待录取

地板
发表于 2021-5-13 21:40:41 |只看该作者
FEWDFER
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 加入FG

本版积分规则

手机版|联系我们| FlightGear ( 吉ICP备19002044号-7 )

GMT+8, 2024-5-9 09:50

Powered by Discuz! X3.2

© 2001-2013 FlightGear Inc.

返回顶部