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

P3D v4 Trigger Event whilst Key Trapped

Messages
29
Country
unitedkingdom
Hi,

I have got close to what I want to achieve with the code below. I want to trigger (L:FTR, bool) only whilst "CTRL, SHIFT, F" is pressed as a kind of 'while' statemet.

Monitoring the outputs it is happening close to what I want/expected but there is a slight 'blip' on the initial key press when the FTR bool output goes 1..0..1.... for a couple of gauge cycles.

Is there a better way to write the code?

Reset code when keys not pressed.
XML:
<!-- Resetting FTR bool and TIMER when key not pressed -->
<Element>
<Select>
<Value>
.....
0 (>L:TIMER, enum)
0 (>L:FTR, bool)
</Value>
</Select>
</Element>

Key press event. Timer is looping/incrementing inside the key press only.
XML:
<!-- FORCE TRIM RELEASE (FTR) -->
<On Key="838" ID="CTRL, SHIFT, F">
<Visible>(L:KBD CONTROL, bool) 1 ==</Visible>
(L:TIMER,enum) ++ (>L:TIMER,enum)
(L:FTR, bool) ! (L:TIMER, enum) 0 &gt; &amp;&amp; if{
1 (>L:FTR, bool)
}
</On>
 
Yes, Keypress is shortly interrupted.
My solution was a counter.
An excerpt of my code and adaption.
This is not tested!

Code:
<!-- FORCE TRIM RELEASE (FTR) -->
<On Key="838" ID="CTRL, SHIFT, F">
<Visible>(L:KBD CONTROL, bool) 1 ==</Visible>
    (L:NavM_Key_is_in_Use818,number) 0 &gt;
    if{
      0.2 (&gt;L:NavM_Key_is_in_Use818,number)
      }

    (L:NavM_Key_is_in_Use818,number) 0 ==
    if{
      1 (&gt;L:NavM_Key_is_in_Use818,number)
       1 (>L:FTR, bool)
       }
</On>
   

<Element>
  <Select>
    <Value>
      (L:NavM_Key_is_in_Use818,number) 0.1 - 0 max (&gt;L:NavM_Key_is_in_Use818,number)
     (L:NavM_Key_is_in_Use818,number) 0 ==
     if{
       0 (>L:FTR, bool)
       }
    </Value>
  </Select>
</Element>

Of course there is small delay in resetting L:FTR
Maybe you have to change this value "0.2 (&gt;L:NavM_Key_is_in_Use818,number)" to a higher value.
 
Maybe this would work...

The Boolean MakeNoise would cause some code to be carried out that would continue until the Left Button is released.


HTML:
<Cursor Type="Grab"/>
<Click Kind="LeftSingle+LeftRelease" >
   (M:Event) 'LeftSingle' scmp 0 ==
           if{ 1 (&gt;L:MakeNoise,bool) }
   (M:Event) 'LeftRelease' scmp 0 ==
           if{ 0 (&gt;L:MakeNoise,bool) }
</Click>

Walter
 
Thanks @EduHir that worked perfectly!

@BaiterOne I had experimented with your suggestion but as I was trying to get this to work for a key combo press it doesn't quite have the same effect. I couldn't find the equivalent for (M:Key) using a 'release' condition as suggested in the wiki section.
 
Back
Top