• Which the release of FS2020 we see an explosition of activity on the forun and of course we are very happy to see this. But having all questions about FS2020 in one forum becomes a bit messy. So therefore we would like to ask you all to use the following guidelines when posting your questions:

    • Tag FS2020 specific questions with the MSFS2020 tag.
    • Questions about making 3D assets can be posted in the 3D asset design forum. Either post them in the subforum of the modelling tool you use or in the general forum if they are general.
    • Questions about aircraft design can be posted in the Aircraft design forum
    • Questions about airport design can be posted in the FS2020 airport design forum. Once airport development tools have been updated for FS2020 you can post tool speciifc questions in the subforums of those tools as well of course.
    • Questions about terrain design can be posted in the FS2020 terrain design forum.
    • Questions about SimConnect can be posted in the SimConnect forum.

    Any other question that is not specific to an aspect of development or tool can be posted in the General chat forum.

    By following these guidelines we make sure that the forums remain easy to read for everybody and also that the right people can find your post to answer it.

FSX return to center switch with 5 inputs...

Messages
35
Country
unitedstates
I like to type these out and hopefully teach myself something trying to explain them in addition to maybe getting a tip from you wizards.

My switch is a 3 way switch with a spring back to center but the return to center is controlled by a separate input than the movement right and left.

So 3 states. 0,1,2. 5 inputs. 0_on, 0_off, 1_on, 2_on, 2_off.

I want to be able to drag left / right and return to center but I also have mouse rectangles that have logic that seem to do what I want but I can't get it into the drag.

This mouse rectangle logic moves the switch to the right and then back again.

Code:
(M:Event) 'LeftSingle' scmi 0 ==
              if{ A:(state, enum) 1 == if { (>K:2_on) } }
              (A:state, enum) 2 == if{ (>K:2_off) }

I would like to cram this into something like this...taken from another post for its drag and return functionality but I already bastardized it.

Code:
      <MouseFlags>LeftSingle+LeftRelease+LeftDrag</MouseFlags>
      <CallbackCode>
        (M:Event) 'LeftSingle'  scmi 0 == if{ (M:X) (&gt;L:ClickStart,) }
        (M:Event) 'LeftDrag'    scmi 0 == if{ (M:X) (L:ClickStart,) &lt; if{ (&gt;K:0_on)  }
              els{ (&gt;K:2_on)  }  }
      </CallbackCode>

The drag to either side works but doesn't return.
 
My two cents worth:

Your A:state variable isn't valid. Same issue with the K: vars. I presume you need these to be L variables instead?

With L:vars, its probably a good idea to go ahead and give them units such as enum in this case.

Then check for the obvious syntax and typo errors.
 
hi rpmc,

Thanks for looking at it. That is really pseudo code, and lets just pretend there are valid A: and K: variables with those names. The mouse rectangle example I posted works as a single click and returns to center using the on and off values. Not sure how to combine it with the drag.

I did forget to put the value in for the (L:Clickstart, number) and only had a comma.

Here is the code with a release, that works to return but isn't tied to the drag action

Code:
            <MouseFlags>LeftSingle+LeftDrag+LeftRelease</MouseFlags>
            <CallbackCode>
				(M:Event) 'LeftSingle' scmp 0 == if{ (M:X) (&gt;L:ClickStart, number) }
				(M:Event) 'LeftRelease' scmi 0 ==
					if{ (A:STATE, enum) 0 == if{ (&gt;K:0_off) }  }
					els{ (A:STATE, enum) 2 == if{ (&gt;K:2_off) } }
				(M:Event) 'LeftDrag' scmi 0 == if{ (M:X) (L:ClickStart, number) - 0 &lt;
					if{ (A:STATE, enum) 1 == if{ (&gt;K:0_on) }  }
					els{ (A:STATE, enum) 1 == if{ (&gt;K:2_on) } } }
			</CallbackCode>
 
Last edited:
This is my coding for a spill valve switch which works a bit like a spring loaded joystick.
The neutral position is centred. The 12 o'clock position has a detent that holds the switch unless clicked or operated by an auto-close function (off-stage). It also has a click-hold-release for the 8 o'clock and 4 o'clock positions.
In the norm position (detent) the spill valve is set to 25% open. In the click-hold-release positions the valve opens or closes from 0 -100%
vololiberista

Code:
<Gauge Name="LEFT SPILL VALVE" Version="1.0">
<Update>
(L:SetSpill,bool) 0 == 
   if{ 
      2 (>L:SPILL, number) 100 (>L:spill_segment,enum)
      1 (>L:SetSpill, bool) 
   }
</Update>

   <Element>
      <Select>
         <Value>(L:SPILLSWITCH,number)</Value> 
         <Case Value="0">
            <Image Name="L_spill_off.bmp"/>
         </Case>
         <Case Value="1">
            <Image Name="L_spill_shut.bmp"/>
         </Case>
         <Case Value="2">
            <Image Name="L_spill_norm.bmp"/>
         </Case>
         <Case Value="3">
            <Image Name="L_spill_spill.bmp"/>
         </Case>
      </Select>
   </Element>

  <Mouse>
 <Tooltip>Left Spill Valve %((L:spill_segment,enum) near)%!d!%%</Tooltip>
      <Area Left="0" Top="22" Right="13" Bottom="39">
         <Cursor Type="Hand"/>
         <Click Kind="LeftSingle+LeftRelease" Repeat="Yes">
            (M:Event) 'LeftSingle' scmp 0 == if{ 0 (>L:SPILL,number) 1 (>L:SPILLSWITCH,number) (L:spill_segment,enum) 0 &gt;
if{ (L:spill_segment,enum) -- (>L:spill_segment,enum) } }
         (M:Event) 'LeftRelease' scmp 0 == if{ 0 (>L:SPILL,number) 0 (>L:SPILLSWITCH,number) (L:spill_segment,enum) 0 &gt;
if{ (L:spill_segment,enum) -- (>L:spill_segment,enum) } }
        </Click>
      </Area>

      <Area Top="0" Bottom="12">
         <Cursor Type="Hand"/>
         <Click>1 (>L:SPILL,number) 25 (>L:spill_segment,enum) 2 (>L:SPILLSWITCH,number) 1 (>L:Sound_click,enum)</Click>
      </Area>
      <Area Left="14" Top="22" Right="25" Bottom="39">
         <Cursor Type="Hand"/>
         <Click Kind="LeftSingle+LeftRelease" Repeat="Yes">
            (M:Event) 'LeftSingle' scmp 0 == if{ 2 (>L:SPILL,number) 3 (>L:SPILLSWITCH,number) (L:spill_segment,enum) 100 &lt;
if{ (L:spill_segment,enum) ++ (>L:spill_segment,enum) } }
          (M:Event) 'LeftRelease' scmp 0 == if{ 2 (>L:SPILL,number) 0 (>L:SPILLSWITCH,number) (L:spill_segment,enum) 100 &lt;
if{ (L:spill_segment,enum) ++ (>L:spill_segment,enum) } }
        </Click>
      </Area>

   </Mouse>
</Gauge>
 
Last edited:
rpmc, sorry wasn't even really correct calling it pseudo code which wouldn't have any syntax attempt. I just meant the variable names there are not really what I'm using and I know they dont' exist in FSX natively.

Thanks for the example to follow Volo, I'll try and see what I can adopt.
 
I just meant the variable names there are not really what I'm using and I know they dont' exist in FSX natively.

So why don't you post the real variables and events the code is using? Would be easier for any of us to give proper help.

Tom
 
Tom, I'm using Prepar3D.

The animation .xml logic is the same and my names represent the functionality.
 
Back
Top