forked from vranki/ExtPlane
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.cpp
57 lines (48 loc) · 1.43 KB
/
main.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#include <QDebug>
#include "XPLMPlugin.h"
#include "XPLMDataAccess.h"
#include "XPLMProcessing.h"
#include "xplaneplugin.h"
#include "util/console.h"
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
XPlanePlugin *globalPlugin=0;
PLUGIN_API float MyFlightLoopCallback(
float inElapsedSinceLastCall, float inElapsedTimeSinceLastFlightLoop,
int inCounter, void *inRefcon) {
if(globalPlugin)
return globalPlugin->flightLoop(inElapsedSinceLastCall, inElapsedTimeSinceLastFlightLoop, inCounter, inRefcon);
return 1;
}
PLUGIN_API int XPluginStart(
char * outName, char * outSig, char *outDesc) {
XPLMRegisterFlightLoopCallback(MyFlightLoopCallback, 0.01, NULL);
Q_ASSERT(!globalPlugin);
globalPlugin = new XPlanePlugin();
if(globalPlugin) {
return globalPlugin->pluginStart(outName,outSig,outDesc);
} else {
INFO << "Unable to create plugin";
return 0;
}
}
PLUGIN_API void XPluginStop(void) {
DEBUG;
XPLMUnregisterFlightLoopCallback(MyFlightLoopCallback, 0);
globalPlugin->pluginStop();
delete globalPlugin;
globalPlugin = 0;
}
PLUGIN_API void XPluginDisable(void) {
DEBUG;
}
PLUGIN_API int XPluginEnable(void) {
DEBUG;
return 1;
}
PLUGIN_API void XPluginReceiveMessage(
XPLMPluginID inFromWho, long inMessage, void *inParam) {
if(globalPlugin)
globalPlugin->receiveMessage(inFromWho, inMessage, inParam);
}