Jump to content
Sign in to follow this  
jspan_com

C++ Airspeed bug mouse function

Recommended Posts

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

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  

  • Tom Allensworth,
    Founder of AVSIM Online


  • Flight Simulation's Premier Resource!

    AVSIM is a free service to the flight simulation community. AVSIM is staffed completely by volunteers and all funds donated to AVSIM go directly back to supporting the community. Your donation here helps to pay our bandwidth costs, emergency funding, and other general costs that crop up from time to time. Thank you for your support!

    Click here for more information and to see all donations year to date.
×
×
  • Create New...