-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
88 lines (64 loc) · 1.72 KB
/
main.cpp
File metadata and controls
88 lines (64 loc) · 1.72 KB
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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
#include "XPLMPlugin.h"
#include "XPLMDataAccess.h"
#include "XPLMUtilities.h"
#include "XPLMMenus.h"
#include <stdio.h>
#include <string.h>
#include <iostream>
#include <vector>
#include "kmlclient.h"
KmlClient *gKmlClient = NULL;
static void PluginsMenuHandler(void * mRef, void * iRef);
PLUGIN_API int XPluginStart(char *outName, char *outSig, char *outDesc) {
strcpy(outName, "XP2KML");
strcpy(outSig, "de.thknz.xp2kml");
strcpy(outDesc, "Write KML file from flight data.");
if (gKmlClient) {
delete gKmlClient;
}
gKmlClient = new KmlClient();
if (gKmlClient) {
XPLMMenuID id;
int item;
item = XPLMAppendMenuItem(XPLMFindPluginsMenu(), "XP2KML", NULL, 1);
id = XPLMCreateMenu("XP2KML", XPLMFindPluginsMenu(), item, PluginsMenuHandler, NULL);
XPLMAppendMenuItem(id, "Start recording", (void *)"START_REC",1);
XPLMAppendMenuItem(id, "Stop recording", (void *)"STOP_REC",1);
return 1;
}
return 0;
}
PLUGIN_API void XPluginStop(void) {
if (gKmlClient) {
delete gKmlClient;
}
gKmlClient = NULL;
}
PLUGIN_API void XPluginDisable(void) {
if (gKmlClient) {
gKmlClient->disable();
}
}
PLUGIN_API int XPluginEnable(void) {
if (gKmlClient) {
gKmlClient->enable();
}
return 1;
}
int main(int argc, char *argv[]) {
XPluginEnable();
return 0;
}
void PluginsMenuHandler(void * mRef, void * iRef)
{
if (!strcmp((char *) iRef, "START_REC"))
{
gKmlClient->start_recording();
}
if (!strcmp((char *) iRef, "STOP_REC"))
{
gKmlClient->stop_recording();
}
}
PLUGIN_API void XPluginReceiveMessage(XPLMPluginID inFromWho, long inMessage, void *inParam) {
}