Johan G wrote in Fri Jul 03, 2020 8:10 am:I am a bit late, but this looks like a great addition, and, like Stuart said, not just for keyboard pilots.
Glad you like it.
Share and spread the word
Johan G wrote in Fri Jul 03, 2020 8:10 am:I am a bit late, but this looks like a great addition, and, like Stuart said, not just for keyboard pilots.
<?xml version="1.0"?>
<!--
Improved view
Copyright 2020 PH-JAKE
SPDX-License-Identifier: GPL-2.0-or-later
This configuration file aims to improve the cockpit viewing pitch angles when flying with
keyboard controls, thereby removing the need to reach for the mouse to adjust view pitch
angles especially in high bank turns. This becomes apparent when flying bubble canopy aircraft,
typically fighter aircraft. But also the normal cockpit view pitch is improved by not looking
down at instrument level when looking in other directions.
To install this configuration add a 'config' option to the fgfs command line, e.g., in the
launcher Settings page under Additional settings.
The configuration operates in two modes: simple and full.
Simple mode is suitable for normal cockpits where the roof limits view upwards.
Full mode is suitable for bubble canopy aircraft with an unobstructed view around.
Aircraft tagged as 'fighter' enable full mode automatically, otherwise simple mode is engaged.
The View menu provides an option to toggle the mode from simple to full and back.
Background information
The configuration works by adding a binding to the existing keyboard bindings for cockpit view
control, i.e., Shift-1 through Shift-9, except Shift-5 on the numeric keypad. In full mode they
use the current bank angle and view direction to calculate a compromise between looking at the
horizon and looking down, in order to create an optimum view. In simple mode in all but forward
view the pitch of the forward view is simply halved, so to get a slightly better look outside.
During loading the aircraft model is interrogated to see if the 'fighther', 'glider' or
'aerobatic' tag is present. If so a bubble canopy is assumed and full mode engaged. Otherwise
the simple mode is active.
The keyboard bindings are numbered to stay out of the way of other additional bindings, but
it's not impossible for them to overlap. This may interfere with the operation. The same is
true for the View menu item.
First posted on https://forum.flightgear.org/viewtopic.php?f=18&t=37513
Release 1.0 2020-05-18 - Initial release
Release 1.1 2020-06-02 - Added more tags to automatically set full mode
Release 2.0 2021-01-21 - Handle roll beyond 90 degrees
--><PropertyList>
<nasal>
<load>
<script><![CDATA[
foreach (var tag; props.globals.getNode("/sim/tags", 1).getChildren("tag")) {
if ((tag.getValue() == "fighter") or
(tag.getValue() == "glider") or
(tag.getValue() == "aerobatic")) {
setprop("/sim/current-view/improved-view-mode", 1);
}
}
]]></script>
</load>
</nasal>
<sim>
<current-view>
<improved-view-mode type="bool">false</improved-view-mode>
</current-view>
<menubar>
<default>
<menu n="1">
<enabled type="bool">true</enabled>
<item n="19">
<label>Toggle Improved View Mode</label>
<binding>
<command>nasal</command>
<script><![CDATA[
var mode = getprop("/sim/current-view/improved-view-mode");
mode = !mode;
setprop("/sim/current-view/improved-view-mode", mode);
gui.popupTip(mode?"Improved view mode full":"Improved view mode simple", 3);
var hdg = getprop("/sim/current-view/goal-heading-offset-deg");
var front = getprop("/sim/view/config/front-direction-deg");
# hdg becomes 360 when resetting view with Shift-Q while looking right...
if ((hdg != front) and (hdg != 360)) {
__kbd.setViewPitch();
}
]]></script>
</binding>
</item>
</menu>
</default>
</menubar>
</sim>
<input>
<keyboard>
<nasal>
<script><![CDATA[
var setViewPitch = func() {
var mode = getprop("/sim/current-view/improved-view-mode");
var pitch = 0;
if (mode) {
var hdg = getprop("/sim/current-view/goal-heading-offset-deg");
var roll = getprop("/orientation/roll-deg");
if (roll > 90) { roll = 90 - roll; }
if (roll < -90) { roll = roll + 90; }
pitch = -(roll*math.sin(hdg*D2R))/2;
} else {
pitch = getprop("/sim/current-view/config/pitch-offset-deg")/2;
}
setprop("/sim/current-view/goal-pitch-offset-deg", pitch);
}
]]></script>
</nasal>
<!-- The number keys -->
<key n="49">
<!-- 1 -->
<mod-shift>
<!-- Look back left -->
<binding n="9">
<command>nasal</command>
<script>
setViewPitch();
</script>
</binding>
</mod-shift>
</key>
<key n="50">
<!-- 2 -->
<mod-shift>
<!-- Look back-->
<binding n="9">
<command>nasal</command>
<script>
setViewPitch();
</script>
</binding>
</mod-shift>
</key>
<key n="51">
<!-- 3 -->
<mod-shift>
<!-- Look back right -->
<binding n="9">
<command>nasal</command>
<script>
setViewPitch();
</script>
</binding>
</mod-shift>
</key>
<key n="52">
<!-- 4 -->
<mod-shift>
<!-- Look left -->
<binding n="9">
<command>nasal</command>
<script>
setViewPitch();
</script>
</binding>
</mod-shift>
</key>
<!-- Key 5 is not related to a view -->
<key n="54">
<!-- 6 -->
<mod-shift>
<!-- Look right -->
<binding n="9">
<command>nasal</command>
<script>
setViewPitch();
</script>
</binding>
</mod-shift>
</key>
<key n="55">
<!-- 7 -->
<mod-shift>
<!-- Look front-left -->
<binding n="9">
<command>nasal</command>
<script>
setViewPitch();
</script>
</binding>
</mod-shift>
</key>
<key n="56">
<!-- 8 -->
<mod-shift>
<!-- Look front -->
<binding n="9">
<command>property-assign</command>
<property>/sim/current-view/goal-pitch-offset-deg</property>
<property>/sim/current-view/config/pitch-offset-deg</property>
</binding>
</mod-shift>
</key>
<key n="57">
<!-- 9 -->
<mod-shift>
<!-- Look front right -->
<binding n="9">
<command>nasal</command>
<script>
setViewPitch();
</script>
</binding>
</mod-shift>
</key>
<!-- The numeric keypad keys -->
<key n="356">
<!-- Left -->
<mod-shift>
<!-- Look left -->
<binding n="9">
<command>nasal</command>
<script>
setViewPitch();
</script>
</binding>
</mod-shift>
</key>
<key n="357">
<!-- Up -->
<mod-shift>
<!-- Look front -->
<binding n="9">
<command>property-assign</command>
<property>/sim/current-view/goal-pitch-offset-deg</property>
<property>/sim/current-view/config/pitch-offset-deg</property>
</binding>
</mod-shift>
</key>
<key n="358">
<!-- Right -->
<mod-shift>
<!-- Look right -->
<binding n="9">
<command>nasal</command>
<script>
setViewPitch();
</script>
</binding>
</mod-shift>
</key>
<key n="359">
<!-- Down -->
<mod-shift>
<!-- Look back -->
<binding n="9">
<command>nasal</command>
<script>
setViewPitch();
</script>
</binding>
</mod-shift>
</key>
<key n="360">
<!-- PageUp -->
<mod-shift>
<!-- Look front right -->
<binding n="9">
<command>nasal</command>
<script>
setViewPitch();
</script>
</binding>
</mod-shift>
</key>
<key n="361">
<!-- PageDn -->
<mod-shift>
<!-- Look back right -->
<binding n="9">
<command>nasal</command>
<script>
setViewPitch();
</script>
</binding>
</mod-shift>
</key>
<key n="362">
<!-- Home -->
<mod-shift>
<!-- Look front left -->
<binding n="9">
<command>nasal</command>
<script>
setViewPitch();
</script>
</binding>
</mod-shift>
</key>
<key n="363">
<!-- End -->
<mod-shift>
<!-- Look back left -->
<binding n="9">
<command>nasal</command>
<script>
setViewPitch();
</script>
</binding>
</mod-shift>
</key>
</keyboard>
</input>
</PropertyList>
Users browsing this forum: No registered users and 2 guests