Sign in to follow this  
Guest Patrick_Waugh

Starters that work in FS9 and FSX

Recommended Posts

If anyone is interested, this code allows the same gauge to be used to start recip engines in both sims...char engine1_gauge_name[] = GAUGE_NAME;extern PELEMENT_HEADER engine1_list;extern MOUSERECT engine1_mouse_rect[];GAUGE_HEADER_FS700(GAUGE_W, engine1_gauge_name, &engine1_list, engine1_mouse_rect, NULL, 0, 0, 0);BOOL FSAPI engine1_mouse_click_down( PPIXPOINT relative_point, FLAGS32 mouse_flags){ send_key_event(KEY_MAGNETO1_DECR,0); return FALSE;}BOOL FSAPI engine1_mouse_click_up( PPIXPOINT relative_point, FLAGS32 mouse_flags){ send_key_event(KEY_MAGNETO1_INCR,0); return FALSE;}MOUSE_BEGIN( engine1_mouse_rect, HELP_NONE, 0, 0 ) MOUSE_TOOLTIP_TEXT_ID (TOOLTIPTEXT_ENG1_MAGNETO_SWITCH,NULL) MOUSE_CHILD_FUNCT(1,1,50,93,CURSOR_DOWNARROW,MOUSE_LEFTSINGLE | MOUSE_DOWN_REPEAT,engine1_mouse_click_down) MOUSE_CHILD_FUNCT(51,1,50,93,CURSOR_UPARROW,MOUSE_LEFTSINGLE | MOUSE_DOWN_REPEAT,engine1_mouse_click_up)MOUSE_ENDFLOAT64 FSAPI engine1_icon_cb( PELEMENT_ICON pelement){ double mag; lookup_var(&mag_left[1]); lookup_var(&mag_right[1]); mag = (mag_left[1].var_value.n * 2.) + mag_right[1].var_value.n; if ( mag > 2. ) mag = mag + pelement->source_var.var_value.n; return mag;}MAKE_ICON(engine1_Icon,OffBitmap,NULL,NULL,IMAGE_USE_ERASE | IMAGE_USE_TRANSPARENCY | BIT7,0,11,36,RECIP_ENGINE1_STARTER,engine1_icon_cb,ICON_SWITCH_TYPE_STEP_TO,5,0,0)PELEMENT_HEADER engine1_IconList[] = {&engine1_Icon.header,NULL};MAKE_STATIC(engine1_Static,BackgroundBitmap,&engine1_IconList,NULL,IMAGE_USE_ERASE | IMAGE_USE_TRANSPARENCY | BIT7,0,0,0)PELEMENT_HEADER engine1_list = &engine1_Static.header;Doug

Share this post


Link to post
Share on other sites
Help AVSIM continue to serve you!
Please donate today!

Hmm... You know how well I program XML, don't you. :-)Something like: (A:Recip eng left magneto:1,bool) 2 * (A:Recip eng right magneto:1,bool) +The above display element from the FSDZ Connie; the mouse function from the default FS9 Baron.The key here is to use the magneto_incr function, rather than the toggle_starter function. As has been discussed here before, the toggle_starter function does not work the same way in the two sims.The C++ code I posted includes an extra icon value for the magneto_start value, in addition to off, right, left and both. It gets this from the actual starter variable (RECIP_ENGINE1_STARTER).Doug

Share this post


Link to post
Share on other sites

Doug,Thanks. What does the BIT7 flag do for you?Also, did you know you don't need the forward declarations if you format your code like this:

char engine1_gauge_name[] = GAUGE_NAME;FLOAT64 FSAPI engine1_icon_cb( PELEMENT_ICON pelement){	double mag;	lookup_var(&mag_left<1>);	lookup_var(&mag_right<1>);	mag = (mag_left<1>.var_value.n * 2.) + mag_right<1>.var_value.n;	if ( mag > 2. ) 		mag = mag + pelement->source_var.var_value.n;	return mag;}MAKE_ICON(	engine1_Icon,	OffBitmap,	NULL,	NULL,	IMAGE_USE_ERASE | IMAGE_USE_TRANSPARENCY | BIT7,	0,	11,36,	RECIP_ENGINE1_STARTER, engine1_icon_cb,	ICON_SWITCH_TYPE_STEP_TO,	5,	0,0)PELEMENT_HEADER engine1_IconList[] = {&engine1_Icon.header,NULL};MAKE_STATIC(	engine1_Static,	BackgroundBitmap,	&engine1_IconList,	NULL,	IMAGE_USE_ERASE | IMAGE_USE_TRANSPARENCY | BIT7,	0,	0,0)PELEMENT_HEADER engine1_list = &engine1_Static.header;BOOL FSAPI engine1_mouse_click_down( PPIXPOINT relative_point, FLAGS32 mouse_flags){	send_key_event(KEY_MAGNETO1_DECR,0);	return FALSE;}BOOL FSAPI engine1_mouse_click_up( PPIXPOINT relative_point, FLAGS32 mouse_flags){	send_key_event(KEY_MAGNETO1_INCR,0);	return FALSE;}MOUSE_BEGIN( engine1_mouse_rect, HELP_NONE, 0, 0 )MOUSE_TOOLTIP_TEXT_ID( TOOLTIPTEXT_ENG1_MAGNETO_SWITCH, NULL )	MOUSE_CHILD_FUNCT( 1, 1, 50, 93, CURSOR_DOWNARROW, MOUSE_LEFTSINGLE | MOUSE_DOWN_REPEAT, engine1_mouse_click_down )	MOUSE_CHILD_FUNCT( 51, 1, 50, 93, CURSOR_UPARROW,MOUSE_LEFTSINGLE | MOUSE_DOWN_REPEAT, engine1_mouse_click_up )MOUSE_ENDGAUGE_HEADER_FS700(GAUGE_W, engine1_gauge_name, &engine1_list, engine1_mouse_rect, NULL, 0, 0, 0);

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this