Jump to content

AltInput DLL For Joysticks


Recommended Posts

When compiling and using the AltInput dll, everything seems to improve drastically. However, the SAS no longer functions. It's on and it looks like it's working but it does nothing for the stability of the craft. The problem section is here:

VesselAutopilot.VesselSAS VesselSAS = FlightGlobals.ActiveVessel.Autopilot.SAS;
Boolean overrideSAS = (Math.Abs(CurrentState.pitch) > VesselSAS.controlDetectionThreshold) ||
						(Math.Abs(CurrentState.yaw) > VesselSAS.controlDetectionThreshold) ||
						(Math.Abs(CurrentState.roll) > VesselSAS.controlDetectionThreshold);
VesselSAS.ManualOverride(overrideSAS);

Does anyone see an issue right off that I'm missing?

Link to comment
Share on other sites

You might want to check that manual override (still?) does what you expect it to. It might be easier to run your control inputs in PostAutoPilotUpdate and just not put anything through if input is not detected.

public static bool IsNeutral(AxisBinding axis)
{
  return axis.IsNeutral() && Math.Abs(axis.GetAxis()) < VesselSAS.controlDetectionThreshold;
}

 

Edited by Crzyrndm
Link to comment
Share on other sites

I'm basically fumbling my way through this . . . when do you suggest I place your code? Here is a larger chunk of what I currently have:

        public static void UpdateState(FlightCtrlState CurrentState)
        {
            // Go through all our axes to find the ones we need to update
            foreach (FieldInfo field in AxisFields)
            {
                if (Math.Abs((float)field.GetValue(CurrentState)) < Math.Abs((float)field.GetValue(UpdatedState)))
                {
                    field.SetValue(CurrentState, (float)field.GetValue(UpdatedState));
                    // The throttles are a real PITA to override
                    if (field.Name == "mainThrottle")
                        FlightInputHandler.state.mainThrottle = 0.0f;
                    else if (field.Name == "wheelThrottle")
                        FlightInputHandler.state.wheelThrottle = 0.0f;
                }
            }

            // If SAS is on, we need to override it or else our changes are ignored
            VesselAutopilot.VesselSAS VesselSAS = FlightGlobals.ActiveVessel.Autopilot.SAS;
            Boolean overrideSAS = (Math.Abs(CurrentState.pitch) > VesselSAS.controlDetectionThreshold) ||
                                    (Math.Abs(CurrentState.yaw) > VesselSAS.controlDetectionThreshold) ||
                                    (Math.Abs(CurrentState.roll) > VesselSAS.controlDetectionThreshold);
            VesselSAS.ManualOverride(overrideSAS);
        }

The area in question is, obviously, at the bottom.

Edited by Styles2304
Link to comment
Share on other sites

The little code comment is probably totally worthless now that I think about it (since it uses KSPs controller bindings while this seems to be something else entirely...). What's probably happening is that the SAS updates the ctrlstate before you do, and then even when manual override is false its output no longer exists. Simple fix, when you don't want control from this plugin, don't fiddle with the ctrlState at all (ie. if (manualOverride) UpdateCtrlState();)

Edited by Crzyrndm
Link to comment
Share on other sites

This thread is quite old. Please consider starting a new thread rather than reviving this one.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...