/*
 * MyDrawWindowCallback
 * 
 * This routine draws the window, showing the last keyboard stroke to be 
 * recorded by our sniffer.
 * 
 */
void MyDrawWindowCallback(
                                   XPLMWindowID         inWindowID,
                                   void *               inRefcon)
{
		char	str[50];
		int		left, top, right, bottom;
		float	color[] = { 1.0, 1.0, 1.0 };

	/* First get our window's location. */
	XPLMGetWindowGeometry(inWindowID, &left, &top, &right, &bottom);

	/* Draw a translucent dark box as our window outline. */
	XPLMDrawTranslucentDarkBox(left, top, right, bottom);

	/* Take the last key stroke and form a descriptive string.
	 * Note that ASCII values may be printed directly.  Virtual key
	 * codes are not ASCII and cannot be, but the utility function
	 * XPLMGetVirtualKeyDescription provides a human-readable string
	 * for each key.  These strings may be multicharacter, e.g. 'ENTER'
	 * or 'NUMPAD-0'. */
	sprintf(str,"%d '%c' | %d '%s' (%c %c %c %c %c)",
		gChar,
		(gChar) ? gChar : '0',
		(long) (unsigned char) gVirtualKey,
		XPLMGetVirtualKeyDescription(gVirtualKey),
		(gFlags & xplm_ShiftFlag) ? 'S' : ' ',
		(gFlags & xplm_OptionAltFlag) ? 'A' : ' ',
		(gFlags & xplm_ControlFlag) ? 'C' : ' ',
		(gFlags & xplm_DownFlag) ? 'D' : ' ',
		(gFlags & xplm_UpFlag) ? 'U' : ' ');

	/* Draw the string into the window. */
	XPLMDrawString(color, left + 5, top - 20, str, NULL, xplmFont_Basic);
}
Beispiel #2
0
void MyDrawWindowCallback(
                          XPLMWindowID         inWindowID,
                          void *               inRefcon)
{
	int	left, top, right, bottom;
	float color[] = { 0.0, 0.0, 0.0 };
	
	XPLMGetWindowGeometry(inWindowID, &left, &top, &right, &bottom);
    
    if (getData != NULL) {
        //if (newData)
            parseJSON();
        
        if (message != NULL) {
        
            XPLMDrawTranslucentDarkBox(left, top, right, bottom);
        
            /*char out[512];
            sprintf(out, "SIZE: %d\n", (int) sizeof(message));
            XPLMDebugString(out);
        
            char m[sizeof(message)];
            strcpy(m, message[1], sizeof(message) - 1);
            m[sizeof(message) - 1] = '\0';*/
            
            char *m = strndup(message+29, 29+50);
        
            XPLMDrawString(color, left + 50, top - 20, m, NULL, xplmFont_Basic);
        
            // TODO: start thread to reset getData after x seconds and hide the window
        }
    }
}
Beispiel #3
0
/*
 * MyDrawingWindowCallback
 *
 * This callback does the work of drawing our window once per sim cycle each time
 * it is needed.  It dynamically changes the text depending on the saved mouse
 * status.  Note that we don't have to tell X-Plane to redraw us when our text
 * changes; we are redrawn by the sim continuously.
 *
 */
void MyDrawWindowCallback(
                                   XPLMWindowID         inWindowID,
                                   void *               inRefcon)
{
	int		left, top, right, bottom;
	float	color[] = { 1.0, 1.0, 1.0 }; 	/* RGB White */
    int xpndr_mode;
    float alt_agl, grnd_spd;
    char  buffer[50];

    xpndr_mode  = XPLMGetDatai( ref_xpndr_mode );
    alt_agl     = XPLMGetDataf( ref_alt_agl );
    grnd_spd    = XPLMGetDataf( ref_grnd_spd );

	/* First we get the location of the window passed in to us. */
	XPLMGetWindowGeometry(inWindowID, &left, &top, &right, &bottom);

	/* We now use an XPLMGraphics routine to draw a translucent dark
	 * rectangle that is our window's shape. */
	XPLMDrawTranslucentDarkBox(left, top, right, bottom);

    /* Finally we draw the text into the window, also using XPLMGraphics
	 * routines.  The NULL indicates no word wrapping. */
	sprintf(buffer, "xpndr_mode: %d", xpndr_mode);
    XPLMDrawString(color, left + 5, top - 20, buffer, NULL, xplmFont_Basic);

	sprintf(buffer, "alt_agl: %d", (int)floor(alt_agl));
    XPLMDrawString(color, left + 5, top - 40, buffer, NULL, xplmFont_Basic);

	sprintf(buffer, "grnd_spd: %d", (int)floor(grnd_spd));
    XPLMDrawString(color, left + 5, top - 60, buffer, NULL, xplmFont_Basic);

    XPLMDrawString(color, left + 5, top - 80, debug_string, NULL, xplmFont_Basic);

}
/*
 * MyDrawingWindowCallback
 * 
 * This callback does the work of drawing our window once per sim cycle each time
 * it is needed.  It dynamically changes the text depending on the saved mouse
 * status.  Note that we don't have to tell X-Plane to redraw us when our text
 * changes; we are redrawn by the sim continuously.
 * 
 */
void MyDrawWindowCallback(
                                   XPLMWindowID         inWindowID,    
                                   void *               inRefcon)
{
	int		left, top, right, bottom;
	float	color[] = { 1.0, 1.0, 1.0 }; 	/* RGB White */
	
	/* First we get the location of the window passed in to us. */
	XPLMGetWindowGeometry(inWindowID, &left, &top, &right, &bottom);
	
	/* We now use an XPLMGraphics routine to draw a translucent dark
	 * rectangle that is our window's shape. */
	XPLMDrawTranslucentDarkBox(left, top, right, bottom);

	/* Finally we draw the text into the window, also using XPLMGraphics
	 * routines.  The NULL indicates no word wrapping. */
	XPLMDrawString(color, left + 5, top - 20, 
		(char*)(gClicked ? "I'm a plugin" : "Hello world"), NULL, xplmFont_Basic);
		
}