From X-Plane SDK
(Redirected from DataRefEditorPlugin)
Jump to: navigation, search

DataRefEditor (DRE) is a plugin that lets you see, explore and edit datarefs inside X-Plane; it is highly recommended for editing.

DataRef Editor comes as a fat plugin for 32 or 64 bits; You can download DRE here.


Mac users: if you are using an OS older than 10.6 (E.g. with an old version of X-Plane) use this version of DRE:


Complete instructions on using DRE are in the README found with the download.

Viewing Your Own Custom DataRefs

When the plugin starts up it will read all the datarefs that are in the Datarefs.txt file.

Once Xplane is up and running you can then tell the DataRefEditor plugin about your custom datarefs. The code to do this should only be called once. One way of doing this is to use a flight loop callback that returns 0. That way the flight loop callback will only be called once.

#define MSG_ADD_DATAREF 0x01000000

float CustomDatarefExampleLoopCB(float elapsedMe, float elapsedSim, int counter, void * refcon);

PLUGIN_API int XPluginStart( char *outName, char *outSig, char *outDesc)
	strcpy(outName, "CustomDatarefExample1");
	strcpy(outSig, "xplanesdk.examples.CustomDatarefExample1");
	strcpy(outDesc, "CustomDatarefExample1");

	// Defer registering for later.
	XPLMRegisterFlightLoopCallback(CustomDatarefExampleLoopCB, 1, NULL);

	return 1;

PLUGIN_API void XPluginStop(void)
	XPLMUnregisterFlightLoopCallback(CustomDatarefExampleLoopCB, NULL);

float CustomDatarefExampleLoopCB(float elapsedMe, float elapsedSim, int counter, void * refcon)
	void *Param = NULL;
	XPLMPluginID PluginID = XPLMFindPluginBySignature("xplanesdk.examples.DataRefEditor");
	if (PluginID != XPLM_NO_PLUGIN_ID){
		XPLMSendMessageToPlugin(PluginID, MSG_ADD_DATAREF, (void*)"xpsdk/example/engine/custom_whatever1");
		XPLMSendMessageToPlugin(PluginID, MSG_ADD_DATAREF, (void*)"xpsdk/example/engine/custom_whatever2");
	// etc
	// etc
	return 0;

How This Works

  • We have to be sure the DataRefEditor plugin is fully loaded before we can tell it about our datarefs. So we register a flight loop callback. This callback will be run once x-plane is fully loaded, after all plugins are loaded and enabled. Our callback returns 0, which will cause it to not run again. (This callback is effectively a one-shot deferred callback.)
  • We find the dataref editor by signature. Note that we will get XPLM_NO_PLUGIN_ID if the dataref editor is not installed.
  • We then send it a custom message, MSG_ADD_DATAREF. The message's parameter is a pointer to a null-terminated C string name of a dataref for it to start editing.
  • Note the high number for the dataref. "commands" and "messages" are partitioned into different numeric spaces to aid plugin interoperability. See XPLMPlugin for more info.