Profile image

Lets talk about InputControllers

Dev NathanMikeska  6.6 years ago

Hey everyone! Lets chat a bit about the InputController. For those of you unfamiliar with it, this post won't mean much to you. For the XML modders (and Overload mod users) out there that are familiar with it, there are a few changes to it in the 1.7 release that you may like to be aware of.

Before 1.7

The 'input' attribute defines the input axis associated with the controller. This might be a normal axis like 'Roll' or 'VTOL' which returns a value anywhere from -1 to 1 or it might be a boolean type input that is either on or off like 'LandingGear' or 'FireWeapons'. Prior to 1.7, those boolean type inputs would return an axis value of 0 or 1.

Input controllers have a 'min' and a 'max' value. If the value of an input axis is greater than 0, the input value is multiplied by the controller 'max' value to get the final output value of the input controller. If the input axis is less than 0, the absolute value of the input axis value is multiplied by the controller 'min' value to get the final output value. An input of zero will always return an output of 0. If the 'invert' attribute is set to 'true' the the value of the input axis is inverted and then the same min/max logic applies.

Example: input="Roll" min="-0.5" max="1" invert="false"
Input: 1 --> Output: 1
Input: 0.5 --> Output: 0.5
Input: 0 --> Output: 0
Input: -0.5 --> Output: -0.25
Input: -1 --> Output: -0.5

Example: input="Roll" min="-0.5" max="1" invert="true"
Input: 1 --> Output: -0.5
Input: 0.5 --> Output: -0.25
Input: 0 --> Output: 0
Input: -0.5 --> Output: 0.5
Input: -1 --> Output: 1

Example: input="LandingGear" min="-0.5" max="1" invert="false"
Input: 1 --> Output: 1
Input: 0 --> Output: 0

Example: input="LandingGear" min="-0.5" max="1" invert="true"
Input: 1 --> Output: -0.5
Input: 0 --> Output: 0

1.7 Changes

The 1.7 update introduces 2 important changes that you should be aware of when working with an InputController. Boolean inputs now return a value of -1 or 1 rather than the 0 or 1 that they used to. This allows those inputs to better take advantage of the min/max values of an input controller. The other change is the addition of the 'invertType' XML attribute.

The 'invertType' can be set to 'axis' or 'output'. The default for most parts is 'axis' and the default for rotators is 'output'. This affects the behavior of controller when 'invert' is set to 'true'. The invert type of 'axis' works just like the old input controller did, where the axis input value is inverted and then the min/max logic runs. If set to 'output' the input controller uses the non-inverted input axis value, runs the min/max logic, and then inverts the output of the controller.

When opening up an old plane file, the game should automatically do any conversions necessary to keep the same functionality as before. This may involve swapping the min/max values and toggling the invert flag. When creating things like custom landing gear on rotators, you may now find yourself needing to set the min value to 0 and the max value to 1 so that the rotator works similar to before the update.

While some things may require a slightly different approach than before, you should still have all the same functionality as before as well as some new functionality.

Example: input="Roll" min="-0.5" max="1" invert="false"
Input: 1 --> Output: 1
Input: 0.5 --> Output: 0.5
Input: 0 --> Output: 0
Input: -0.5 --> Output: -0.25
Input: -1 --> Output: -0.5

Example: input="Roll" min="-0.5" max="1" invert="true" invertType='axis'
Input: 1 --> Output: -0.5
Input: 0.5 --> Output: -0.25
Input: 0 --> Output: 0
Input: -0.5 --> Output: 0.5
Input: -1 --> Output: 1

Example: input="Roll" min="-0.5" max="1" invert="true" invertType='output'
Input: 1 --> Output: -1
Input: 0.5 --> Output: -0.5
Input: 0 --> Output: 0
Input: -0.5 --> Output: 0.25
Input: -1 --> Output: 0.5

Example: input="LandingGear" min="-0.5" max="1" invert="false"
Input: 1 --> Output: 1
Input: -1 --> Output: -0.5

Example: input="LandingGear" min="-0.5" max="1" invert="true" invertType='axis'
Input: 1 --> Output: -0.5
Input: -1 --> Output: 1

Example: input="LandingGear" min="-0.5" max="1" invert="true" invertType='output'
Input: 1 --> Output: -1
Input: -1 --> Output: 0.5

Its also worth pointing out that we have a 'zeroOnDeactivate' attribute as well that, if set to 'true', will cause the output of the controller to be zero when its activation group is not enabled.

Let me know if you have any questions, concerns or problems. Thanks!

  • Log in to leave a comment
  • Profile image

    anyone know how the pigpen canard rotator works with the string command written like this?
    clamp(Canard/40 + String etc...)

    1.9 years ago
  • Profile image
    1,285 InvisibleMan

    @Holdupboi in 1.9 above, use sum(input) or sum(input * multiplier) if you want something faster

    +1 3.3 years ago
  • Profile image
    4,038 YoDudeChase

    @Holdupboi set input to a insanely high number

    3.5 years ago
  • Profile image
    8,973 ZWLenning

    has the zeroOnDeactivate attribute been removed?

    3.8 years ago
  • Profile image

    Wait
    Hold on
    inputType?

    +5 3.9 years ago
  • Profile image

    How do I make an infinite rolling rotator? Because I want to make a gatling cannon

    +2 4.0 years ago
  • Profile image
    505 NAGO

    Will the next update fix the mods on mobile to be fixed because I made a plane with a lot of mods but when I was going to use it with out knowing the mods weren't working and my game crashed and my simple planes files were corrupted and I had to buy the game again because it said that I didn't download it before can you help please?

    4.2 years ago
  • Profile image
    9,246 SaintNPC

    trying to figure out how to get reverse lights to show up on my car, i can set it to pitch control but it won't let me save any changes other than that, no min, max, or input inverse. Are lights affected by any of these or am I missing something?

    Edit: I see now that BeaconLight.State is different from InputController.State. I really want better lighting. D: As of right now I can get brake lights to work though.

    4.2 years ago
  • Profile image

    How do you invert input in a BeaconLight? They don't have the same inputController
    thing as normal Input-controlled parts

    +1 4.2 years ago
  • Profile image
    69.2k Chancey21

    Yes @Weaverfish

    5.7 years ago
  • Profile image
    38.0k Weaverfish

    Possible to set a detacher to activate with anything other than activation group 1-8?

    6.5 years ago
  • Profile image
    8,626 BeryllCorp

    @NathanMikeska zeroOnDisable does not work on cycling pistons

    6.6 years ago
  • Profile image
    55.3k Beefy

    First insight at booleans:

    "WTF IS HAPPENING WITH MY LANDING GEAR?!"

    remembers this post

    ._.
    oh yeah

    +1 6.6 years ago
  • Profile image
    31.3k Mostly

    Thank you. So many people have been saying that they were glitched. I'm glad I won't be seeing those types of posts again. They were getting a bit obnoxious.

    6.6 years ago
  • Profile image
    14.9k Rodrigo110

    Speaking of literal input controllers, can you make iOS devices connected to keyboards able to recognise all the keyboard controls?

    6.6 years ago
  • Profile image
    87.3k Kerbango

    Nice thank you. This answered a few questions I was mulling over.

    6.6 years ago
  • Profile image

    @WNP78 ok thanks dad

    6.6 years ago
  • Profile image

    @F104Deathtrap in like an hour (I have homework) ill mention you on an unlisted version, but it should be fine, the stabs are all the way at the back

    6.6 years ago
  • Profile image
    14.7k MrWarPac

    LOW SPEED ROLL AILERONS CONFIRMED

    6.6 years ago
  • Profile image
    Dev WNP78

    @ElGatoVolador yes, there already is. launchCountermeasures I believe

    6.6 years ago
  • Profile image

    @MechWARRIOR57 Are you sure your stabilizers are large enough and far enough to the rear of your bomber?

    6.6 years ago
  • Profile image

    @alexchub1 Boolean used to be 1 or 0, now it's 1 or -1. Boolean means only 2 possible outputs, like a light switch. Also, there are a couple ways we can reverse the controls now.

    6.6 years ago
  • Profile image

    ... I have no idea...

    6.6 years ago
  • Profile image

    Will we get a input for counter measures?

    6.6 years ago
  • Profile image
    18.5k alexchub1

    Can someone explain in normal way??

    +1 6.6 years ago
  • Log in to see more comments