<?xml version="1.0"?>

<!-- Copyright (c) 2026 Josh Davidson (Octal450) -->

<PropertyList>
	
	<!-- Roll Axis -->
	<filter>
		<name>IT-CONTROLLER: Heading/LNAV</name>
		<type>gain</type>
		<gain>
			<expression>
				<table>
					<property>/velocities/airspeed-kt</property>
					<entry><ind>140</ind><dep>1.3</dep></entry>
					<entry><ind>360</ind><dep>2.5</dep></entry>
				</table>
			</expression>
		</gain>
		<enable>
			<condition>
				<and>
					<property>/it-autoflight/output/apfd-on</property>
					<or>
						<equals>
							<property>/it-autoflight/output/lat</property>
							<value>0</value>
						</equals>
						<equals>
							<property>/it-autoflight/output/lat</property>
							<value>1</value>
						</equals>
						<and>
							<equals>
								<property>/it-autoflight/output/lat</property>
								<value>5</value>
							</equals>
							<equals>
								<property>/it-autoflight/internal/takeoff-lvl</property>
								<value>0</value>
							</equals>
						</and>
					</or>
				</and>
			</condition>
		</enable>
		<input>/it-autoflight/internal/heading-error-deg</input>
		<reference>0</reference>
		<output>/it-autoflight/internal/target-roll-deg</output>
		<min>
			<property>/it-autoflight/internal/bank-limit</property>
			<scale>-1.0</scale>
		</min>
		<max>/it-autoflight/internal/bank-limit</max>
	</filter>
	
	<filter>
		<name>IT-CONTROLLER: VOR/LOC</name>
		<type>gain</type>
		<gain>
			<expression>
				<table>
					<property>/velocities/airspeed-kt</property>
					<entry><ind>140</ind><dep>1.6</dep></entry>
					<entry><ind>360</ind><dep>2.6</dep></entry>
				</table>
			</expression>
		</gain>
		<enable>
			<condition>
				<and>
					<property>/it-autoflight/output/apfd-on</property>
					<equals>
						<property>/it-autoflight/output/lat</property>
						<value>2</value>
					</equals>
				</and>
			</condition>
		</enable>
		<input>/it-autoflight/internal/nav-heading-error-deg</input>
		<reference>0</reference>
		<output>/it-autoflight/internal/target-roll-deg</output>
		<min>
			<property>/it-autoflight/internal/bank-limit</property>
			<scale>-1.0</scale>
		</min>
		<max>/it-autoflight/internal/bank-limit</max>
	</filter>
	
	<logic>
		<input>
			<and>
				<property>/it-autoflight/output/ap-on</property>
				<equals>
					<property>/it-autoflight/output/lat</property>
					<value>4</value>
				</equals>
				<equals>
					<property>/gear/gear[1]/wow</property>
					<value>0</value>
				</equals>
				<equals>
					<property>/gear/gear[2]/wow</property>
					<value>0</value>
				</equals>
			</and>
		</input>
		<output>/it-autoflight/internal/align-roll-mode</output>
	</logic>
	
	<pid-controller>
		<name>IT-CONTROLLER: Align Roll</name>
		<type>gain</type>
		<enable>
			<condition>
				<equals>
					<property>/it-autoflight/internal/align-roll-mode</property>
					<value>1</value>
				</equals>
			</condition>
		</enable>
		<input>/it-autoflight/internal/nav-heading-error-deg</input>
		<reference>0</reference>
		<output>/it-autoflight/internal/target-roll-deg</output>
		<config>
			<Kp>
				<expression>
					<table>
						<property>/velocities/airspeed-kt</property>
						<entry><ind>140</ind><dep>-1.6</dep></entry>
						<entry><ind>360</ind><dep>-2.6</dep></entry>
					</table>
				</expression>
			</Kp>
			<Ti>5.0</Ti>
			<Td>0.001</Td>
			<u_min>
				<expression>
					<table>
						<property>/position/gear-agl-ft</property>
						<entry><ind>50</ind><dep>-10</dep></entry>
						<entry><ind> 5</ind><dep>  0</dep></entry>
					</table>
				</expression>
			</u_min>
			<u_max>
				<expression>
					<table>
						<property>/position/gear-agl-ft</property>
						<entry><ind>50</ind><dep>10</dep></entry>
						<entry><ind> 5</ind><dep> 0</dep></entry>
					</table>
				</expression>
			</u_max>
		</config>
	</pid-controller>
	
	<filter>
		<name>IT-CONTROLLER: Rollout/Takeoff</name>
		<type>gain</type>
		<gain>1.0</gain>
		<enable>
			<condition>
				<or>
					<and>
						<equals>
							<property>/it-autoflight/output/lat</property>
							<value>4</value>
						</equals>
						<equals>
							<property>/it-autoflight/internal/align-roll-mode</property>
							<value>0</value>
						</equals>
					</and>
					<and>
						<equals>
							<property>/it-autoflight/output/lat</property>
							<value>5</value>
						</equals>
						<equals>
							<property>/it-autoflight/internal/takeoff-lvl</property>
							<value>1</value>
						</equals>
					</and>
					<equals>
						<property>/it-autoflight/output/lat</property>
						<value>6</value>
					</equals>
				</or>
			</condition>
		</enable>
		<input>0</input>
		<output>/it-autoflight/internal/target-roll-deg</output>
	</filter>
	
	<filter>
		<name>System Command: Roll Target Inactive Sync</name>
		<type>gain</type>
		<gain>1.0</gain>
		<enable>
			<condition>
				<not><property>/it-autoflight/output/apfd-on</property></not>
			</condition>
		</enable>
		<input>/orientation/roll-deg</input>
		<output>/it-autoflight/internal/target-roll-deg</output>
		<min>
			<property>/it-autoflight/internal/bank-limit</property>
			<scale>-1.0</scale>
		</min>
		<max>/it-autoflight/internal/bank-limit</max>
	</filter>
	
	<filter>
		<name>System Command: Target Roll Filter</name>
		<type>noise-spike</type>
		<input>/it-autoflight/internal/target-roll-deg</input>
		<output>/it-autoflight/internal/target-roll</output>
		<max-rate-of-change>
			<condition>
				<not><property>/it-autoflight/output/apfd-on</property></not>
			</condition>
			<value>1000</value>
		</max-rate-of-change>
		<max-rate-of-change>
			<condition>
				<not><property>/it-autoflight/output/ap-on</property></not>
			</condition>
			<value>15</value>
		</max-rate-of-change>
		<max-rate-of-change>6</max-rate-of-change>
	</filter>
	
	<filter>
		<name>System Command: Roll Rate Target</name>
		<type>gain</type>
		<gain>-0.8</gain>
		<input>/orientation/roll-deg</input>
		<reference>/it-autoflight/internal/target-roll</reference>
		<output>/it-autoflight/internal/roll-rate</output>
		<min>-5</min>
		<max>5</max>
	</filter>
	
	<filter>
		<name>System Command: Aileron Air Inactive Sync</name>
		<type>gain</type>
		<gain>1.0</gain>
		<enable>
			<condition>
				<not>
					<and>
						<property>/it-autoflight/output/ap-on</property>
						<equals>
							<property>/gear/gear[1]/wow</property>
							<value>0</value>
						</equals>
						<equals>
							<property>/gear/gear[2]/wow</property>
							<value>0</value>
						</equals>
					</and>
				</not>
			</condition>
		</enable>
		<input>/controls/flight/aileron</input>
		<output>/it-autoflight/internal/aileron-cmd</output>
	</filter>
	
	<pid-controller>
		<name>System Command: Aileron Air</name>
		<enable>
			<condition>
				<and>
					<property>/it-autoflight/output/ap-on</property>
					<equals>
						<property>/gear/gear[1]/wow</property>
						<value>0</value>
					</equals>
					<equals>
						<property>/gear/gear[2]/wow</property>
						<value>0</value>
					</equals>
				</and>
			</condition>
		</enable>
		<input>/orientation/roll-rate-degps</input>
		<reference>/it-autoflight/internal/roll-rate</reference>
		<output>/it-autoflight/internal/aileron-cmd</output>
		<config>
			<Kp>
				<expression>
					<product>
						<table>
							<property>/velocities/airspeed-kt</property>
							<entry><ind>130</ind><dep>0.17</dep></entry>
							<entry><ind>360</ind><dep>0.07</dep></entry>
						</table>
						<table> <!-- Reduce deflection if outer ailerons are not locked -->
							<property>/systems/fcs/aileron-out-enable</property>
							<entry><ind>0</ind><dep>1.00</dep></entry>
							<entry><ind>1</ind><dep>0.72</dep></entry> <!-- Calculated based on Cl moment -->
						</table>
					</product>
				</expression>
			</Kp>
			<Ti>1.0</Ti>
			<Td>0.0001</Td>
			<u_min>-1.0</u_min>
			<u_max>1.0</u_max>
		</config>
	</pid-controller>
	
	<filter>
		<name>System Command: Aileron Ground</name>
		<type>gain</type>
		<gain>-0.1</gain>
		<input>/orientation/roll-deg</input>
		<reference>0</reference>
		<output>/it-autoflight/internal/aileron-rollout</output>
	</filter>
	
	<filter>
		<name>System Command: Aileron Inactive Sync</name>
		<type>gain</type>
		<gain>1.0</gain>
		<enable>
			<condition>
				<not><property>/it-autoflight/output/ap-on</property></not>
			</condition>
		</enable>
		<input>/controls/flight/aileron</input>
		<output>/systems/fcc/afs/roll-cmd</output>
	</filter>
	
	<filter>
		<name>System Command: Aileron Filter</name>
		<type>noise-spike</type>
		<initialize-to>output</initialize-to>
		<enable>
			<condition>
				<property>/it-autoflight/output/ap-on</property>
			</condition>
		</enable>
		<input>
			<condition>
				<and>
					<equals>
						<property>/gear/gear[1]/wow</property>
						<value>0</value>
					</equals>
					<equals>
						<property>/gear/gear[2]/wow</property>
						<value>0</value>
					</equals>
				</and>
			</condition>
			<property>/it-autoflight/internal/aileron-cmd</property>
		</input>
		<input>/it-autoflight/internal/aileron-rollout</input>
		<output>/systems/fcc/afs/roll-cmd</output>
		<max-rate-of-change>1.2</max-rate-of-change>
	</filter>
	
	<!-- Yaw Axis -->
	<filter>
		<name>IT-CONTROLLER: Align/Rollout Yaw Rate Target</name>
		<type>gain</type>
		<gain>1.0</gain>
		<input>
			<condition>
				<or>
					<equals>
						<property>/gear/gear[1]/wow</property>
						<value>0</value>
					</equals>
					<equals>
						<property>/gear/gear[2]/wow</property>
						<value>0</value>
					</equals>
				</or>
			</condition>
			<expression>
				<sum>
					<product>
						<table>
							<property>/position/gear-agl-ft</property>
							<entry><ind>150</ind><dep>1</dep></entry>
							<entry><ind> 60</ind><dep>0</dep></entry>
						</table>
						<property>/it-autoflight/internal/nav-heading-error-deg</property>
					</product>
					<product>
						<table>
							<property>/position/gear-agl-ft</property>
							<entry><ind>150</ind><dep>0</dep></entry>
							<entry><ind> 60</ind><dep>1</dep></entry>
						</table>
						<property>/it-autoflight/internal/nav-course-heading-error-deg</property>
					</product>
				</sum>
			</expression>
		</input>
		<input>
			<expression>
				<sum>
					<property>/it-autoflight/internal/nav-course-heading-error-deg</property>
					<product>
						<property>/it-autoflight/internal/nav-deflection-norm</property>
						<value>15</value>
					</product>
				</sum>
			</expression>
		</input>
		<output>/it-autoflight/internal/yaw-rate</output>
		<min>
			<condition>
				<and>
					<equals>
						<property>/gear/gear[1]/wow</property>
						<value>0</value>
					</equals>
					<equals>
						<property>/gear/gear[2]/wow</property>
						<value>0</value>
					</equals>
				</and>
			</condition>
			<value>-5</value>
		</min>
		<min>-2</min>
		<max>
			<condition>
				<and>
					<equals>
						<property>/gear/gear[1]/wow</property>
						<value>0</value>
					</equals>
					<equals>
						<property>/gear/gear[2]/wow</property>
						<value>0</value>
					</equals>
				</and>
			</condition>
			<value>5</value>
		</max>
		<max>2</max>
	</filter>
	
	<filter>
		<name>IT-CONTROLLER: Align/Rollout Yaw Inactive Centering</name>
		<type>gain</type>
		<gain>1.0</gain>
		<enable>
			<condition>
				<not>
					<and>
						<property>/it-autoflight/output/ap-on</property>
						<equals>
							<property>/it-autoflight/output/lat</property>
							<value>4</value>
						</equals>
						<greater-than-equals>
							<property>/velocities/groundspeed-kt</property>
							<value>1</value>
						</greater-than-equals>
					</and>
				</not>
			</condition>
		</enable>
		<input>0</input>
		<output>/it-autoflight/internal/rudder-cmd</output>
	</filter>
	
	<pid-controller>
		<name>IT-CONTROLLER: Align/Rollout Yaw</name>
		<enable>
			<condition>
				<and>
					<property>/it-autoflight/output/ap-on</property>
					<equals>
						<property>/it-autoflight/output/lat</property>
						<value>4</value>
					</equals>
					<greater-than-equals>
						<property>/velocities/groundspeed-kt</property>
						<value>1</value>
					</greater-than-equals>
				</and>
			</condition>
		</enable>
		<input>/orientation/yaw-rate-degps</input>
		<reference>/it-autoflight/internal/yaw-rate</reference>
		<output>/it-autoflight/internal/rudder-cmd</output>
		<config>
			<Kp>
				<expression>
					<product>
						<table>
							<property>/velocities/airspeed-kt</property>
							<entry><ind>140</ind><dep>0.27</dep></entry>
							<entry><ind>200</ind><dep>0.21</dep></entry>
						</table>
						<table>
							<property>/gear/gear[0]/wow</property>
							<entry><ind>0</ind><dep>1.0</dep></entry>
							<entry><ind>1</ind><dep>0.8</dep></entry>
						</table>
					</product>
				</expression>
			</Kp>
			<Ti>1.5</Ti>
			<Td>0.001</Td>
			<u_min>-1.0</u_min>
			<u_max>1.0</u_max>
		</config>
	</pid-controller>
	
	<filter>
		<name>System Command: Rudder</name>
		<type>noise-spike</type>
		<input>
			<condition>
				<and>
					<property>/it-autoflight/output/ap-on</property>
					<equals>
						<property>/it-autoflight/output/lat</property>
						<value>4</value>
					</equals>
				</and>
			</condition>
			<property>/it-autoflight/internal/rudder-cmd</property>
		</input>
		<input>0</input>
		<output>/systems/fcc/afs/yaw-cmd</output>
		<max-rate-of-change>1.2</max-rate-of-change>
	</filter>

</PropertyList>
