• 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 Custom EventIDs - Questions!

n4gix

Resource contributor
Messages
11,674
Country
unitedstates
Since there does not seem to be an appropriate forum for this question, I'm using this forum to ask. The question actually involves modeldef.xml scripting, as well as C gauge programming.

We are allowed to create custom EventIDs which are actually required for "Shared Cockpit" development, but thus far at least there seems to be a dearth of information on how to actually USE them, aside from a very brief mention of them in the SDK, and a few (undocumented) examples in the modeldef.xml file from FSX Acceleration, where they were used for the FA-18...

This example shows how to use <CallbackJumpDragging>, which is a techique I throughly despise:
Code:
      <CallbackJumpDragging>
        <XMovement>
          <Delta>2</Delta>
          <EventIdInc>0x11001</EventIdInc>
          <EventIdDec>0x11002</EventIdDec>
        </XMovement>
      </CallbackJumpDragging>
This example shows how to use a single, left-click for a binary switch:
Code:
    <MouseRect>
      <Cursor>Hand</Cursor>
      <MouseFlags>LeftSingle</MouseFlags>
      <EventID>0x00011003</EventID>
    </MouseRect>
There are however no examples whatever about multi-button (i.e., left/middle/right clicking) or mouse wheel useage.

So, my question is... does anyone know if such is possible at all, and/or has anyone tried this at all?

Is it possible to pass a value to a custom EventID at all?

Is something like this possible:

Code:
      <CallbackCode>
          4 (>K:0x11002)
      </CallbackCode>
 
Last edited:
Hi Bill,
Good question!
Unfortunately I never succeed in defining other way to trigger a custom event than the two ones you shown...
Using a K: structure should be very helpfull but so far, I don't know how to proceed...

One thing we used, is to trigger a FSX useless Event (for example with a CallbackCode block, multi-button case and/or updating L:Var etc...) and catch this Event in C++ in order to execute my custom tasks (using L:Var value, etc...)...

It was often helpfull as a work around...
Regards,
Sylvain
 
Oh, I have absolutely no trouble whatever "reading" L:vars from the 3d model within my C gauge. Unfortunately however, L:vars won't update across a networked "Shared Cockpit" situation... :(
 
Bill,

Are you able to detect the events in a C gauge in the aircraft in question?
If so, I think you will then need to get into gauge serialization to share the data with another user.

Doug
 
This one has a wheel and down repeat
Code:
    <MouseRect>
      <Cursor>UpArrow</Cursor>
      <MouseFlags>LeftSingle+Wheel+DownRepeat</MouseFlags>
      <TooltipID>TOOLTIPTEXT_AUTOPILOT_HEADING_INDICATOR</TooltipID>
      <EventID>0x00011030</EventID>
    </MouseRect>

This has left click, left drag and Mouse wheel (CallbackJumpDraggin)
Code:
    <MouseRect>
      <Cursor>Hand</Cursor>
      <MouseFlags>LeftSingle+LeftDrag+Wheel</MouseFlags>
      <CallbackJumpDragging>
        <XMovement>
          <Delta>2</Delta>
          <EventIdInc>0x00011036</EventIdInc>
          <EventIdDec>0x00011037</EventIdDec>
        </XMovement>
      </CallbackJumpDragging>
    </MouseRect>

Is it possible to pass a value to a custom EventID at all?
Custom parameter
Code:
  <PartInfo>
    <Name>lever_fire_suppression</Name>
    <AnimLength>100</AnimLength>
    <Animation>
      <Parameter>
        <Code>
          (L:lever_fire_suppression, number) 100 *
        </Code>
        <Lag>400</Lag>
      </Parameter>
    </Animation>
    <MouseRect>
      <Cursor>Hand</Cursor>
      <EventID>0x00011008</EventID>
    </MouseRect>
  </PartInfo>

let me know if any of these helped! DG:rolleyes:
 
Last edited:
Bill,

Are you able to detect the events in a C gauge in the aircraft in question?
If so, I think you will then need to get into gauge serialization to share the data with another user.

Doug

Oh, that part is rather trivial, after finding and re-reading Susan Ashlock's article from six years ago that is...

The problem I'm running into is that I have to script the XML for modeldef.xml to control the switches, knobs, and whirly things (:D), while another person is coding up the C++ gauge system.

While binary switches can easily be done with a single EventID, multi-position switches using only <CallbackJumpDragging> with <EventIdInc> and <EventIdDec> is just a major PITA...

...since there's no way to assign left-click increase and right-click decrease... :censored:

I was rather hoping that someone, somewhere had discovered an alternate way of using EventIDs. :idea:
 
Custom parameter
Code:
  <PartInfo>
    <Name>lever_fire_suppression</Name>
    <AnimLength>100</AnimLength>
    <Animation>
      <Parameter>
        <Code>
          (L:lever_fire_suppression, number) 100 *
        </Code>
        <Lag>400</Lag>
      </Parameter>
    </Animation>
    <MouseRect>
      <Cursor>Hand</Cursor>
      <EventID>0x00011008</EventID>
    </MouseRect>
  </PartInfo>

let me know if any of these helped! DG:rolleyes:

Honestly, no. Every part will require animation using a custom L:var in any case. The C++ code will take care to preset and control the values of the L:var used in the model.

The above example is simply another case of a binary switch using a single EventID code. A three or four positon switch would require the nasty <CallbackJumpDragging> method, which is what I wished to avoid entirely if at all possible.
 
A three or four positon switch would require the nasty <CallbackJumpDragging> method

3 way switch using custom event id's. Tested and works perfect. I use these methods for my rmt switch and others.
Code:
  <PartInfo>
    <Name>test</Name>
    <AnimLength>20</AnimLength>
    <Animation>
      <Parameter>
        <Code>(L:test,enum) 6.33 * 10 +</Code>
	<Lag>40</Lag>
      </Parameter>
    </Animation>
    <MouseRect>
      <Cursor>Hand</Cursor>
            <TooltipText>test</TooltipText>
      <MouseFlags>LeftSingle+RightSingle+WheelUp+WheelDown+DownRepeat</MouseFlags>
      <CallbackCode>
        (M:Event) 'LeftSingle'  scmp 0 == if{ (L:test, enum) -- -1 max (>L:test, enum) }
        (M:Event) 'RightSingle' scmp 0 == if{ (L:test, enum) ++ 1 min (>L:test, enum) }
	(L:test, enum) -1 == if{ (>K:0x00011008) }
	(L:test, enum) 0 == if{ (>K:0x00011008) }
	(L:test, enum) 1 == if{ (>K:0x00011008) }
      </CallbackCode>
    </MouseRect>
  </PartInfo>

4 way switch using custom event id's, including the wheel.
Code:
  <PartInfo>
    <Name>test2</Name>
    <AnimLength>60</AnimLength>
    <Animation>
      <Parameter>
        <Code>(L:test2,enum) 10 * 30 +</Code>
	<Lag>40</Lag>
      </Parameter>
    </Animation>
    <MouseRect>
      <Cursor>Hand</Cursor>
     <TooltipText>test2</TooltipText>
      <MouseFlags>LeftSingle+RightSingle+WheelUp+WheelDown+DownRepeat</MouseFlags>
      <CallbackCode>
        (M:Event) 'LeftSingle'  scmp 0 == if{ (L:test2, enum) -- 0 max (>L:test2, enum) }
        (M:Event) 'RightSingle' scmp 0 == if{ (L:test2, enum) ++ 3 min (>L:test2, enum) }

                 (L:test2,enum)   3 == if{ (>K:0x00011008) }  
                 (L:test2,enum)   2 == if{ (>K:0x00011008) }  
                 (L:test2,enum)   1 == if{ (>K:0x00011008) }  
                 (L:test2,enum)   0 == if{ (>K:0x00011008) }
        (M:Event) 'WheelUp'  scmp 0 == if{ (L:test2, enum) -- 0 max (>L:test2, enum) }
        (M:Event) 'WheelDown' scmp 0 == if{ (L:test2, enum) ++ 3 min (>L:test2, enum) }

                 (L:test2,enum)   3 == if{ (>K:0x00011008) }  
                 (L:test2,enum)   2 == if{ (>K:0x00011008) }  
                 (L:test2,enum)   1 == if{ (>K:0x00011008) }  
                 (L:test2,enum)   0 == if{ (>K:0x00011008) }
      </CallbackCode>
    </MouseRect>
  </PartInfo>

By the way i worked hard on making a perfect 4 way switch early this year. So it seems to be what you need for events that can use right click.
And i learned all this from reading and you, Bill....I hope this code will help this time!

DG:eek::eek:
 
Last edited:
By the way i worked hard on making a perfect 4 way switch early this year. So it seems to be what you need for events that can use right click.
And i learned all this from reading and you, Bill....I hope this code will help this time!

DG:eek::eek:

Thank you for that. I actually already have something similar to your last example here:

Code:
  <PartInfo>
    <Name>GLEX_Ovhd_MBattery</Name>
    <AnimLength>50</AnimLength>
    <Animation>
      <Parameter>
        <Code>
          (L:GLEX_MBattery,enum) 25 *
        </Code>
        <Lag>400</Lag>
      </Parameter>
    </Animation>
    <MouseRect>
      <Cursor>Hand</Cursor>
      <MouseFlags>LeftSingle+RightSingle+WheelUp+WheelDown</MouseFlags>
      <CallbackCode>
        (M:Event) 'LeftSingle' scmp 0 ==
        if{ (L:GLEX_MBattery, enum) -- 0 max (>L:GLEX_MBattery, enum) (>K:0x18107) }
        (M:Event) 'WheelDown' scmp 0 ==
        if{ (L:GLEX_MBattery, enum) -- 0 max (>L:GLEX_MBattery, enum) (>K:0x18107) }
        (M:Event) 'RightSingle' scmp 0 ==
        if{ (L:GLEX_MBattery, enum) ++  2 min (>L:GLEX_MBattery, enum) (>K:0x18107) }
        (M:Event) 'WheelUp' scmp 0 ==
        if{ (L:GLEX_MBattery, enum) ++  2 min (>L:GLEX_MBattery, enum) (>K:0x18107) }
      </CallbackCode>
    </MouseRect>
  </PartInfo>

The only real difference being that I'm trying to pass the value of (L:GLEX_MBattery, enum) to the custom EventID. Unfortunately, there doesn't seem to be a method to read a value from a custom EventID in the C++ gauge.

Without that ability, then the entire exercise becomes moot, as it is the C++ gauge itself that needs to process the custom EventID's value, then control the actual logic for the 3d switch's display. Since this is "mirrored" via gauge serialization, the remote user's a/c will remain in synch with the primary user's aircraft.

In other words, the L:var used to animate the 3d switch would be sent from the C++ gauge, instead of using the "localized L:var":
Code:
        <Code>
          (L:GLEX_MBat_CPlus,enum) 25 *
        </Code>
 
What is the point of the custom EventID here? A C++ gauge would have no way of knowing anything more than that someone had "clicked" on a switch...

The C++ gauge would not know (1) the current position of the switch, (2) whether the "click" was left/right/middle or wheelup/wheeldown, nor would it be able to control the logic and set the 3d switch's position... :confused:

Code:
                 (L:test2,enum)   3 == if{ (>K:0x00011008) }  
                 (L:test2,enum)   2 == if{ (>K:0x00011008) }  
                 (L:test2,enum)   1 == if{ (>K:0x00011008) }  
                 (L:test2,enum)   0 == if{ (>K:0x00011008) }
 
Okay, it occured to me that I've actually been asking the wrong question, or at the very least asking from the wrong end...

So, starting over I have only two questions:

1. Is it possible to pass a value to a custom EventID?

2. How would one decode such a passed value in the C++ gauge's event handler?

Code:
void __stdcall My_Event_Handler(DWORD event_id,DWORD unknown,PVOID user_buffer,DWORD user_param)
{
	if(event_id == 0x18107)
	{
	    /* How would one "read/decode" the value of 0x18107 */	
	}
}

EDIT:
To answer my own question and put some closure to the question...

Thanks go to WarpD for pointing out what should have been obvious! :o

It is really simple enough. The "fs_event" example I was using as a prototype was incomplete! The second DWORD isn't "unknown" at all, but should be "evdata." Then it's simply a matter of setting up a case evaluation for the 2nd DWORD:

Code:
void __stdcall My_Event_Handler(DWORD event_id,DWORD evdata,PVOID user_buffer,DWORD user_param)
{
	if(event_id == 0x18107)
	{
		switch (evdata)
		{
		case 0:
		     MBattSw=0 ; /* set local C variable */
		     break;
		case 1:
		     MBattSw=1 ; /* set local C variable */
		     break;
		}
	}
	if(event_id == 0x18108)
	{
		switch (evdata)
		{
		case 0:
			break;
		case 1:
			break;
		case 2:
			break;
		case 3:
			break;
		}
	}
	if(event_id == 0x18109)
	{
		switch (evdata)
		{
		case 0:
			break;
		case 1:
			break;
		case 2:
			break;
		case 3:
			break;
		case 4:
			break;
		case 5:
			break;
		case 6:
			break;
		}
	}

}
 
Last edited:
Hi Bill,
here again, since i need to better understand how to pass values using custom events:
Code:
<PartInfo>
  <Name>governor_switch</Name>
  <AnimLength>50</AnimLength>
  <Animation>
  <Parameter>
  <Code>
       (L:governor_switch, number) 25 *
     </Code>
  </Parameter>
  </Animation>
    <MouseRect>
  <Cursor>hand</Cursor>
  <TooltipText>GOVERNOR TEST SWITCH</TooltipText>
  <MouseFlags>Wheel</MouseFlags>
  <CallbackJumpDragging>
  <XMovement>
  <Delta>1</Delta>
  <EventIdInc>0x0001117F</EventIdInc>
  <EventIdDec>0x0001117E</EventIdDec>
  </XMovement>
  </CallbackJumpDragging>
    </MouseRect>
</PartInfo>
above example works flawlessy, event 0x0001117F and 0x0001117E are triggered and trapped by event handler.
However no values can be sent to the C++ event handler itself.
Following your suggestion tried below code:
Code:
<PartInfo>
  <Name>governor_switch</Name>
  <AnimLength>50</AnimLength>
  <Animation>
  <Parameter>
  <Code>
       (L:governor_switch, number) 25 *
     </Code>
  </Parameter>
  </Animation>
    <MouseRect>
  <Cursor>hand</Cursor>
  <TooltipText>GOVERNOR TEST SWITCH</TooltipText>
  <MouseFlags>WheelUp+WheelDown</MouseFlags>
     <CallbackCode>
     (M:Event) 'WheelUp' scmp 0 ==  if{
       (L:governor_switch, number) 2 &lt; if{ 1 (>L:SOUND_ROTARY,number) }
       (L:governor_switch, number) ++ 2 min (>L:governor_switch, number)
       }
     (M:Event) 'WheelDown'  scmp 0 ==  if{
       (L:governor_switch, number) 0 > if{ 1 (>L:SOUND_ROTARY,number) }
       (L:governor_switch, number) -- 0 max (>L:governor_switch, number)
       }
     (L:governor_switch, number) (>K:0x0001117F)
     </CallbackCode>
  </MouseRect>
</PartInfo>
Even if the callback code is executed properly (switch does set on right position)
custom event 0x0001117F seems not to be triggered nor trapped by C++ event handler.
Any idea ?
TIA
/Mario
 
Last edited:
Wow! It's been several years since last looking at this. As it happens, all of the above is just crap. It doesn't work at all...

Instead, I have adopted a much simpler scheme which has been working quite well. Instead of having multiple EventIDs to trap in C++, I have a single variable to trap (L:EVENT,enum) in which the hex EventID# has been inserted. I also use a custom (L:event_id#,enum) that controls the animation in the model. Here is a brief example of a rotary knob and the complete XML script. This knob has left/right/center click actions:
Code:
  <PartInfo>
    <Name>B350i_CCP_DATA</Name>
    <AnimLength>50</AnimLength>
    <Animation>
      <Parameter>
        <Code>
          (L:0x110E1,enum)
        </Code>
      </Parameter>
    </Animation>
    <MouseRect>
      <Cursor>Hand</Cursor>
      <MouseFlags>LeftSingle+RightSingle+Wheel+DownRepeat+MiddleSingle+MiddleRelease</MouseFlags>
      <CallbackCode>
        (M:Event) 'LeftSingle' scmp 0 ==
        (M:Event) 'WheelDown' scmp 0 == or
        if{ (L:0x110E1, enum) -- (>L:0x110E1, enum) 0x110E1 (>L:EVENT,enum) (L:0x110E1, enum) 0 &lt; if{ 50 (>L:0x110E1, enum) } }

        (M:Event) 'RightSingle' scmp 0 ==
        (M:Event) 'WheelUp' scmp 0 == or
        if{ (L:0x110E1, enum) ++ (>L:0x110E1, enum) 0x110E2 (>L:EVENT,enum) (L:0x110E1, enum) 50 &gt; if{ 0 (>L:0x110E1, enum) } }

        (M:Event) 'MiddleSingle' scmp 0 ==
        if{ 1 (>L:0x110E3, enum) 0x110E3 (>L:EVENT,enum) }
        (M:Event) 'MiddleRelease' scmp 0 == or
        if{ 0 (>L:0x110E3, enum) }
      </CallbackCode>
    </MouseRect>
  </PartInfo>
NOTES:
  1. The animation is controlled via the (L:0x110E1, enum) variable.
  2. The three mouse actions are triggered by the three hex EventIDs:
  • LeftClick - 0x110E1
  • RightClick - 0x110E2
  • MiddleClick - 0x110E3
All I'm concerned with is passing "mouse commands" to the C++ gauge. It's up to the actual C++ code to determine what to do with the information once it's been decoded. The only reason why I choose to use the same "hex number" instead of a more "properly named" (L:variable,enum) is because it is more obviously related to the C++ scheme.

If it is absolutely necessary to pass some specific value to be associated with the (L:EVENT,enum) being passed, you could of course do so by setting another variable in the mouse scripts such as nn (>L:EVENTval,enum), which could likewise be trapped and read if the preceeding (L:EVENT,enum) has been trapped.

I hope this makes sense to you! :teacher:
 
Actually Bill's example is supported by XMLEVENTS class from XMLTools; then people that work in XML only wouldn't need to use/code a C++ event handler to capture and process those custom events.

Tom
 
Tom, that raises an interesting question. Why would anyone working in XML only even need to capture and process custom events? Unless it's necessary for Shared Cockpit maybe?
 
Yes Bill, Shared Cockpit would be the main reason, and probably the same for C++ coders as well.

Tom
 
Back
Top