Okay, I'll try to make it more clear...
The task is to create a 3d switch cover for the virtual cockpit and animate/link it to the corresponding 2d version of the switch in a C gauge.
There is a "new method" that ACES created that allows us to create custom event IDs in a model, so that the IDs can be referenced in the panel system or in a SimConnect client. The specific method of implementation is -in my view- unnecessarily complicated and convoluted. YMMV of course.
In addition, since my company is commited to producing concurrent FS9 and FSX versions of the same aircraft, I need a method that will work in both platforms...
What I see as the KISS solution is this:
1) create a new <Animation> and <PartInfo> section in the modeldef.xml file, such as the following, then keyframe animate the part and use the Animation/Attachpoint Tools as usual*:
* N.B. "Translating" the script below to "FS9" format is trivial, and will allow the same solution to work cross-platform with no other modifications to the C gauges.
Code:
<Animation name="switch_cover" guid="FD7F7013-28B4-4317-8947-12B3A5ABD8D0" length="50" type="Sim" typeParam2="switch_cover" typeParam="AutoPlay" />
<PartInfo>
<Name>switch_cover</Name>
<AnimLength>50</AnimLength>
<Animation>
<Parameter>
<Code>
(L:SwitchCover,number) 50 *
</Code>
<Lag>200</Lag>
</Parameter>
</Animation>
<MouseRect>
<Cursor>Hand</Cursor>
<TooltipText>Open/Close Cover</TooltipText>
<CallbackCode>(L:SwitchCover,number) ! (>L:SwitchCover,number)</CallbackCode>
</MouseRect>
</PartInfo>
Note that the script above will animate the switch cover and also provides the mouse rectangle to enable operation in the virtual cockpit.
2) Add the necessary support to the C gauge to enable bi-directional communications.
a. First we need to "read" the L:variable to detect when/if the status has changed in the VC. This is rediculously simple:
Code:
FLOAT64 SwitchCover = 0 ;
case PANEL_SERVICE_PRE_DRAW:
execute_calculator_code("(L:SwitchCover,enum)",&SwitchCover,NULL,NULL) ;
break;
b. Code the mouse callback to set the L:var as needed:
Code:
ID SwitchCover_id ;
// Switch Cover
BOOL FSAPI SwitchCover_cb( PPIXPOINT relative_point, FLAGS32 mouse_flags)
{
SwitchCover_id = check_named_variable ( "SwitchCover" ) ;
if (SwitchCover == 0)
{ set_named_variable_value ( SwitchCover_id, (FLOAT64)1.0 ) ; }
else { set_named_variable_value ( SwitchCover_id, (FLOAT64)0.0 ) ; }
}
c. Use the same L:var to control the 2d bitmap appearance
Code:
// Switch Cover
FLOAT64 FSAPI SwitchCover_cb( PELEMENT_ICON pelement)
{
FLOAT64 val=pelement->source_var.var_value.n;
if ( SwitchCover == 1 )
{ val = 0 ; }
else { val = -1 ; }
return val;
}