PLUGIN_API int XPluginStart(
						char *		outName,
						char *		outSig,
						char *		outDesc)
{
	/* First set up our plugin info. */
	strcpy(outName, "KeySniffer");
	strcpy(outSig, "xplanesdk.examples.keysniffer");
	strcpy(outDesc, "A plugin that makes a window.");

	/* Now create a new window.  Pass in our three callbacks. */
	gWindow = XPLMCreateWindow(
					50, 750, 350, 700,			/* Area of the window. */
					1,							/* Start visible. */
					MyDrawWindowCallback,		/* Callbacks */
					MyHandleKeyCallback,
					MyHandleMouseClickCallback,
					NULL);						/* Refcon - not used. */
					
	/* Finally register our key sniffer. */
	XPLMRegisterKeySniffer(
					MyKeySniffer, 				/* Our callback. */
					1, 							/* Receive input before plugin windows. */
					0);							/* Refcon - not used. */
	
	return 1;
}
Пример #2
0
PLUGIN_API int XPluginStart(char* outName,
                            char* outSig,
                            char* outDesc)
{
	szString[0] = '\0';
	strcpy(outName, "UDB HILSIM");
	strcpy(outSig, "UDB.HardwareInLoop");
	strcpy(outDesc, "UDB Hardware-In-Loop Simulator");

	// P, Q, and R are roll, pitch, and yaw rates, degrees per second,
	// in the NED coordinate system, in "flight" (not body) frame of reference
	drP = XPLMFindDataRef("sim/flightmodel/position/P");
	drQ = XPLMFindDataRef("sim/flightmodel/position/Q");
	drR = XPLMFindDataRef("sim/flightmodel/position/R");

	// standard GPS lat, long, and elevation
	drLat  = XPLMFindDataRef("sim/flightmodel/position/latitude");
	drLon  = XPLMFindDataRef("sim/flightmodel/position/longitude");
	drElev = XPLMFindDataRef("sim/flightmodel/position/elevation");

	// acceleration, meters/sec/sec, in OGL frame of reference
	// note: this is NOT the same as what the accelerometers read
	drLocal_ax = XPLMFindDataRef("sim/flightmodel/position/local_ax");
	drLocal_ay = XPLMFindDataRef("sim/flightmodel/position/local_ay"); 
	drLocal_az = XPLMFindDataRef("sim/flightmodel/position/local_az");

	// velocity, meters/sec, in OGL frame of reference
	drLocal_vx = XPLMFindDataRef("sim/flightmodel/position/local_vx");
	drLocal_vy = XPLMFindDataRef("sim/flightmodel/position/local_vy"); 
	drLocal_vz = XPLMFindDataRef("sim/flightmodel/position/local_vz");

	drLocalDays = XPLMFindDataRef("sim/time/local_date_days");
	drLocalSecs = XPLMFindDataRef("sim/time/local_time_sec");

	// 3D true airspeed, meters/second
	drAirSpeedTrue = XPLMFindDataRef("sim/flightmodel/position/true_airspeed");

	// location in OGL frame
	drLocal_x = XPLMFindDataRef("sim/flightmodel/position/local_x");
	drLocal_y = XPLMFindDataRef("sim/flightmodel/position/local_y");
	drLocal_z = XPLMFindDataRef("sim/flightmodel/position/local_z");

	// Euler roll, pitch, and yaw angles, degrees, using NED
	// + phi is roll to the right (CCW around NED_x)
	// + theta is pitch up (CCW around NED_y)
	// + psi is yaw to the right (CCW around NED_z)
	drPhi   = XPLMFindDataRef("sim/flightmodel/position/phi");
	drTheta = XPLMFindDataRef("sim/flightmodel/position/theta");
	drPsi   = XPLMFindDataRef("sim/flightmodel/position/psi");

	// Euler angles of attack and sideslip, degrees, using NED
	// These are angles of body frame with respect to fight path
	// + alpha is pitch up (CCW around NED_y)
	// + beta is yaw right (CCW around NED_z)
	drAlpha = XPLMFindDataRef("sim/flightmodel/position/alpha");
	drBeta  = XPLMFindDataRef("sim/flightmodel/position/beta");

	drThrOverRide = XPLMFindDataRef("sim/operation/override/override_throttles");
	drPitchAxis   = XPLMFindDataRef("sim/joystick/FC_ptch");
	drRollAxis    = XPLMFindDataRef("sim/joystick/FC_roll");
	drYawAxis     = XPLMFindDataRef("sim/joystick/FC_hdng");
	drThro        = XPLMFindDataRef("sim/flightmodel/engine/ENGN_thro_use");

// sim/operation/override/override_gearbrake	int	y	boolean	Override gear and brake staus
// sim/flightmodel/controls/parkbrake	float	y	???	Parking Brake

	drBrakeOverRide = XPLMFindDataRef("sim/operation/override/override_gearbrake");
	drBrake         = XPLMFindDataRef("sim/flightmodel/controls/parkbrake");

	// These are the values that the accelerometers read, in multiples of gravity
	// g_nrml is UDB_z
	// g_axil is UDB_y
	// g_side is UDB_x
	drg_nrml = XPLMFindDataRef("sim/flightmodel/forces/g_nrml");
	drg_axil = XPLMFindDataRef("sim/flightmodel/forces/g_axil");
	drg_side = XPLMFindDataRef("sim/flightmodel/forces/g_side");

	fTextColour[0] = 1.0;
	fTextColour[1] = 1.0;
	fTextColour[2] = 1.0;

	XPLMRegisterFlightLoopCallback(GetBodyRates, 1.0, NULL);
	XPLMRegisterDrawCallback(
	    DrawStrings,
	    xplm_Phase_Window,      // Draw when sim is doing objects
	    0,                      // After objects
	    NULL);                  // No refcon needed

//	XPLMSetDatai(drOverRide, 1);// Now overide surfaces, not yaw, roll, pitch

	// Register our hot key for the new view
	gHotKey = XPLMRegisterHotKey(
	    XPLM_VK_F8,
	    xplm_DownFlag, 
	    "Circling External View",
	    MyHotKeyCallback,
	    NULL);

	XPLMRegisterDrawCallback(
	    MyDrawCallback,
	    xplm_Phase_Objects,     // Draw when sim is doing objects
	    0,                      // After objects
	    NULL);                  // No refcon needed

	XPLMRegisterKeySniffer(
		MyKeySniffer,           // Our callback
		1,                      // Receive input before plugin windows
		0);                     // Refcon - not used

	memset(&CamPath, 0, sizeof(float) * 3 * CamPathLength);
	return 1;
}