• 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.

FSXA 3 position switch with one position spring-loaded

Messages
683
Country
us-california
I have the following code to drive the switch that controls the left generator. It works well, but I need it to be spring loaded using RightSingle going from 1 to 0 and and RightRelease to return to 1.

Code:
<PartInfo>
  <Name>XLS_GEN_L_TOGGLE</Name>
    <AnimLength>50</AnimLength>
      <Animation>
        <Parameter>
         <Code>(L:C560_GEN_L_TOGGLE,enum) 25 * </Code>
        </Parameter>
     </Animation>
     <MouseRect>
       <Cursor>Hand</Cursor>
       <MouseFlags>LeftSingle+RightSingle+WheelUp+WheelDown+DownRepeat</MouseFlags>
       <CallbackCode>
        (M:Event) 'RightSingle'  scmp 0 == if{ (L:C560_GEN_L_TOGGLE, enum) -- 0 max (>L:C560_GEN_L_TOGGLE, enum) }
        (M:Event) 'LeftSingle' scmp 0 == if{ (L:C560_GEN_L_TOGGLE, enum) ++ 2 min (>L:C560_GEN_L_TOGGLE, enum) }
        (L:C560_GEN_L_TOGGLE, enum) 0 == if{ 0x1813E (>L:C560_VC_EVENT,enum) }
        (L:C560_GEN_L_TOGGLE, enum) 1 == if{ 0x1813C (>L:C560_VC_EVENT,enum) }
        (L:C560_GEN_L_TOGGLE, enum) 2 == if{ 0x1813D (>L:C560_VC_EVENT,enum) }
       </CallbackCode>
     </MouseRect>
</PartInfo>

Any help would be greatly appreciated.
 
Since there is a C++ guy using hex events there...perhaps he can reset the L var for you if the relevant event fires?
 
Robert, add mouse events for RightRelease & RightDrag

Code:
<MouseFlags>LeftSingle+RightSingle+RightRelease+RightDrag+WheelUp+WheelDown+DownRepeat</MouseFlags>
       <CallbackCode>
        (M:Event) 'RightSingle'  scmp 0 == if{ (L:C560_GEN_L_TOGGLE, enum) -- 0 max (>L:C560_GEN_L_TOGGLE, enum) }
        (M:Event) 'LeftSingle' scmp 0 == if{ (L:C560_GEN_L_TOGGLE, enum) ++ 2 min
        (M:Event) 'RightRelease scmp 0 ==
        (M:Event) 'RightDrag scmp 0 == or
             if{ 1 (>L:C560_GEN_L_TOGGLE,enum) }
The mouse event for RightDrag is so the switch won't get "stuck" if the mouse cursor moves off the switch before the release event is detected.
 
As long as you have the right drag in the mouse flags you do not need the event.
But keep in mind that if the return switch is only one direction, only use the drag for that direction. So do not use left and right drag. Adding a drag that is not present can cause the switch to get stuck.

This code will start the switch in the middle position. To do this you use -1 to 1. Rather than 0 to 2 and add 25+ to the code section. I removed the down repeat from the mouse flags since this is not a knob.
Code:
<PartInfo>
  <Name>XLS_GEN_L_TOGGLE</Name>
    <AnimLength>50</AnimLength>
      <Animation>
        <Parameter>
         <Code>(L:C560_GEN_L_TOGGLE,enum) 25 * 25 +</Code>
        </Parameter>
     </Animation>
     <MouseRect>
       <Cursor>Hand</Cursor>
       <MouseFlags>LeftSingle+RightSingle+RightDrag+WheelUp+WheelDown</MouseFlags>
       <CallbackCode>

        (M:Event) 'LeftSingle' scmp 0 == if{ (L:C560_GEN_L_TOGGLE, enum) ++ 1 min (>L:C560_GEN_L_TOGGLE, enum) }

        (M:Event) 'RightSingle'  scmp 0 == if{ (L:C560_GEN_L_TOGGLE, enum) -- -1 max (>L:C560_GEN_L_TOGGLE, enum) }

        (M:Event) 'RightRelease'  scmp 0 == if{ 0 (>L:C560_GEN_L_TOGGLE, enum) }

       </CallbackCode>
     </MouseRect>
</PartInfo>
 
Last edited:
Back
Top