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

Knob Rotation; LH RH; ModelDefXML code

Messages
10,163
Country
us-arizona
Hey all,

So, I need a code that has left and right rotation for things like Kohlsman and Heading, Altitude... But to also MiddleSingle click/select (MouseRect).

I was looking through stock existing codes for knobs in the ModelDef and find they are mostly all drag/X axis, 360 deg KF rotations.

Is... there.. such a thing as a regular dual/direction (left/right) rotation knob code that is not a drag - X axis type animation so that I can install other click types?

Sample;


Code:
   <PartInfo>
      <Name>knob_heading</Name>
        <AnimLength>100</AnimLength>
          <Animation>
<!--            <Rotation>Z</Rotation>  -->
                 <Parameter>
                   <Sim>
                       <Variable>AUTOPILOT HEADING LOCK DIR</Variable>
                       <Units>radians</Units>
                        <MinValue>0</MinValue>
                        <MaxValue>100</MaxValue>
                       <Scale>20</Scale>
                   </Sim>
                </Parameter>
          </Animation>
      <MouseRect>
         <Cursor>Hand</Cursor>
         <TooltipID>TOOLTIPTEXT_AUTOPILOT_HEADING_INDICATOR</TooltipID>
         <MouseFlags>LeftSingle+LeftDrag+Wheel</MouseFlags>
         <CallbackJumpDragging>
            <XMovement>
               <Delta>1</Delta>
               <EventIdInc>HEADING_BUG_INC</EventIdInc>
           <EventIdDec>HEADING_BUG_DEC</EventIdDec>
            </XMovement>
         </CallbackJumpDragging>
      </MouseRect>
   </PartInfo>


What I would like... But the knob flips out, goes back and fourth.
What I need is the knob to rotate left with left click, right with right click, etc.

Is that possible with knob rotation animations with things like Heading, Kohlsman, Altitude, etc?

Code:
<PartInfo>
      <Name>md302_knob</Name>
      <AnimLength>100</AnimLength>
      <Animation>
        <Parameter>
            <Code>
              (L:MD302 KNOB,bool) 100 *
            </Code>
            <Lag>200</Lag>
        </Parameter>
      </Animation>
      <MouseRect>
        <Cursor>Hand</Cursor>
        <TooltipText>MD302 BARO ADJ</TooltipText>
              <MouseFlags>LeftSingle+RightSingle+WheelUp+WheelDown+MiddleSingle</MouseFlags>
            <CallbackCode>
            (M:Event) 'WheelDown' scmp 0 ==
            (M:Event) 'LeftSingle' scmp 0 == or if{
                (&gt;K:KOHLSMAN_DEC)
                (L:MD302 KNOB,bool) ! (&gt;L:MD302 KNOB,bool)
                }
            (M:Event) 'WheelUp' scmp 0 ==
            (M:Event) 'RightSingle' scmp 0 == or if{
                (&gt;K:KOHLSMAN_INC)
                (L:MD302 KNOB,bool) ! (&gt;L:MD302 KNOB,bool)
                }
            (M:Event) 'MiddleSingle' scmp 0 == if{
                (L:MD302 SETTINGS MENU,bool) ! (&gt;L:MD302 SETTINGS MENU,bool)
                }
            </CallbackCode>
      </MouseRect>
    </PartInfo>
 
Bill,

Maybe give this a try,
Increase the AnimLength in the declaration header to 360, animate as such at: 0,1,90,180,270,359 Dealing with a circular rotation now.
Remove the <Lag>, rotations don't like it.
You can adjust the speed per click etc.. by changing the now given values: (5 +) and (5 -)
The problem you were having is that you were toggling booleans ( 0 -> 1, 1 -> 0 ), multiplying them by 100 for animation. The only animation you would ever get is 0 and 100, nothing in between.
XML:
<PartInfo>
    <Name>md302_knob</Name>
    <AnimLength>360</AnimLength>
    <Animation>
      <Parameter>
            <Code>
              (&gt;L:MD302 KNOB, number)
            </Code>
            <!-- <Lag>200</Lag> -->
      </Parameter>
    </Animation>
    <MouseRect>
      <Cursor>Hand</Cursor>
      <TooltipText>MD302 BARO ADJ</TooltipText>
              <MouseFlags>LeftSingle+RightSingle+WheelUp+WheelDown+MiddleSingle</MouseFlags>
            <CallbackCode>
            (M:Event) 'WheelDown' scmp 0 ==
            (M:Event) 'LeftSingle' scmp 0 == or if{
                 (&gt;K:KOHLSMAN_DEC)
                 (L:MD302 KNOB, number) 5 - dnor (&gt;L:MD302 KNOB, number)
                 }
            (M:Event) 'WheelUp' scmp 0 ==
            (M:Event) 'RightSingle' scmp 0 == or if{
                 (&gt;K:KOHLSMAN_INC)
                 (L:MD302 KNOB, number) 5 + dnor (&gt;L:MD302 KNOB, number)
                 }
            (M:Event) 'MiddleSingle' scmp 0 == if{
                 (L:MD302 SETTINGS MENU,bool) ! (&gt;L:MD302 SETTINGS MENU,bool)
                 }
            </CallbackCode>
    </MouseRect>
</PartInfo>
 
Just an FYI... middle click is not available to everyone... it certainly doesn't work on my mouse... so might want to offer an alternative...
 
I always use, mouse wheel as rotation knob
so I have spare place for left click (push) and right click (pull). sometimes it need "release" for spring animation
when develop Osprey, right click for rotation sometimes became an issue, cause middle finger not familiar by fast clicking like forefinger.

in general like this:
Code:
    <PartInfo>
        <Name>knob</Name>
        <AnimLength>100</AnimLength>
        <Animation>
            <Parameter>
                <Code>(L:knobrotate, enum) 1 * </Code>
            </Parameter>
        </Animation>
        <MouseRect>
            <Cursor>Hand</Cursor>
            <TooltipText>Knob Rotation</TooltipText>  
            <MouseFlags>LeftSingle+LeftRelease+WheelUp+WheelDown</MouseFlags>
            <CallbackCode>
                (M:Event) 'WheelUp'     scmi 0 == if{ 0x11000 (&gt;L:knobrotate,enum) }
                (M:Event) 'WheelDown'   scmi 0 == if{ 0x11001 (&gt;L:knobrotate,enum) }
                (M:Event) 'LeftSingle'  scmi 0 == if{ 0x11002 (&gt;L:otherfunc,bool) }
                (M:Event) 'LeftRelease' scmi 0 == if{ 0x11003 (&gt;L:otherfunc,bool) }
            </CallbackCode>
        </MouseRect>
    </PartInfo>
 
Last edited:
Many thanks guys. Very much appreciated.

Microsoft really liked to use those mouse drag Axis rotationals... Its in quite a bit of their codes.
 
Which in a VC is a major pain, since the actual drag might just actually be a diagonal movement depending on the angle of view! :eek:
yikes[1].gif
 
Back
Top