March 22, 200521 yr Hi all,C++ Airspeed Indicator and Airspeed Bug Mouse problem:The Airspeed Bug needle and mouse function is working, the problem is that I have not been able to limit the values controlled by the mouse, which despite all efforts still varies between 0 to 990 knots. Relevant code://-- (main .c file) -->MODULE_VAR airspeed_bug = {AUTOPILOT_AIRSPEED_HOLD_VAR};//-- (asi.c file -->MOUSE_FUNCTION asi_speed_up_set; //airspeed bug setMOUSE_FUNCTION asi_speed_down_set; //airspeed bug setMOUSE_BEGIN( asi_mouse_rect, 0, 0, 0 ) MOUSE_CHILD_FUNCT( 283, 24, 30, 30, CURSOR_UPARROW, MOUSE_LEFTSINGLE | MOUSE_DOWN_REPEAT, asi_speed_up ) MOUSE_CHILD_FUNCT( 250, 24, 30, 30, CURSOR_DOWNARROW, MOUSE_LEFTSINGLE | MOUSE_DOWN_REPEAT, asi_speed_down ) MOUSE_CHILD_FUNCT( 31, 24, 30, 30, CURSOR_HAND, MOUSE_LEFTSINGLE, asi_bug_set ) MOUSE_CHILD_FUNCT( 283, 260, 30, 40, CURSOR_UPARROW, MOUSE_LEFTSINGLE | MOUSE_DOWN_REPEAT, asi_speed_up_set ) MOUSE_CHILD_FUNCT( 247, 260, 30, 40, CURSOR_DOWNARROW, MOUSE_LEFTSINGLE | MOUSE_DOWN_REPEAT, asi_speed_down_set ) MOUSE_END// Maximum/minimum airspeed bug to be registered#define GAUGE_MAX_AIRSPEED_BUG 250#define GAUGE_MIN_AIRSPEED_BUG 60UINT32 airspeed = 0; //Reset airspeed bug set---// MOUSE Airspeed Bug UP SetBOOL FSAPI asi_speed_up_set( PPIXPOINT relative_point, FLAGS32 mouse_flags ){ lookup_var(&airspeed_bug); airspeed = (int)((double)airspeed_bug.var_value.n); if (airspeed < 60) airspeed = 60; trigger_key_event (KEY_AP_SPD_VAR_INC,1); return FALSE;}// MOUSE Airspeed Bug DOWN SetBOOL FSAPI asi_speed_down_set( PPIXPOINT relative_point, FLAGS32 mouse_flags ){ lookup_var(&airspeed_bug); airspeed = (int)((double)airspeed_bug.var_value.n); if (airspeed > 250) airspeed = 250; trigger_key_event (KEY_AP_SPD_VAR_DEC,1); return FALSE;}// Airspeed bug needle dayFLOAT64 FSAPI asi_speedbug_src_cb_day (PELEMENT_NEEDLE pelement){ lookup_var(&airspeed_bug); airspeed = (int)((double)airspeed_bug.var_value.n); if ( airspeed > GAUGE_MAX_AIRSPEED_BUG ) airspeed = GAUGE_MAX_AIRSPEED_BUG; if ( airspeed < GAUGE_MIN_AIRSPEED_BUG ) airspeed = GAUGE_MIN_AIRSPEED_BUG; if ( airspeed > 250 ) airspeed = 250; else if ( airspeed < 60 ) airspeed = 60; return airspeed;}//-- end -->The airspeed bug needle works fine, but mouse values is starting from 0 up to 990 knots as monitored by the FSlook program. Help on this one is appreciated!Best regardsJan H. Sorensenhttp://www.jspanels.com/images/logo_small.gifHomepage: http://www.jspanels.com
Create an account or sign in to comment