1 | #include "ListenThread.h"
|
---|
2 |
|
---|
3 | #include <XPLMDefs.h>
|
---|
4 | #include <XPLMUtilities.h>
|
---|
5 | #include <XPLMProcessing.h>
|
---|
6 |
|
---|
7 | #include <cstdio>
|
---|
8 | #include <cstring>
|
---|
9 | #include <cstdarg>
|
---|
10 |
|
---|
11 | //------------------------------------------------------------------------------
|
---|
12 |
|
---|
13 | using xplra::ListenThread;
|
---|
14 |
|
---|
15 | //------------------------------------------------------------------------------
|
---|
16 |
|
---|
17 | static ListenThread* listenThread = 0;
|
---|
18 |
|
---|
19 | //------------------------------------------------------------------------------
|
---|
20 |
|
---|
21 | static void debug(const char* format, ...)
|
---|
22 | {
|
---|
23 | va_list ap;
|
---|
24 | va_start(ap, format);
|
---|
25 |
|
---|
26 | char buf[256];
|
---|
27 | vsnprintf(buf, sizeof(buf), format, ap);
|
---|
28 |
|
---|
29 | va_end(ap);
|
---|
30 |
|
---|
31 | XPLMDebugString(buf);
|
---|
32 | }
|
---|
33 |
|
---|
34 | PLUGIN_API int XPluginStart(char* outName, char* outSignature,
|
---|
35 | char* outDescription)
|
---|
36 | {
|
---|
37 | debug("hu.varadiistvan.xplra called\n");
|
---|
38 |
|
---|
39 | strcpy(outName, "X-Plane Remote Access");
|
---|
40 | strcpy(outSignature, "hu.varadiistvan.xplra");
|
---|
41 | strcpy(outDescription, "Provides remote access to datarefs");
|
---|
42 |
|
---|
43 | return 1;
|
---|
44 | }
|
---|
45 |
|
---|
46 | // float callback(float elapsedSinceLastCall, float elapsedTimeSinceLastFlightLoop,
|
---|
47 | // int counter, void* refcon)
|
---|
48 | // {
|
---|
49 | // debug("hu.varadiistvan.proba.callback called: elapsedSinceLastCall=%f, elapsedTimeSinceLastFlightLoop=%f, counter=%d, refcon=%p\n",
|
---|
50 | // elapsedSinceLastCall, elapsedTimeSinceLastFlightLoop,
|
---|
51 | // counter, refcon);
|
---|
52 | // return 5.0;
|
---|
53 | // }
|
---|
54 |
|
---|
55 | PLUGIN_API void XPluginEnable(void)
|
---|
56 | {
|
---|
57 | debug("hu.varadiistvan.proba.XPluginEnable called\n");
|
---|
58 | // XPLMRegisterFlightLoopCallback(&callback, 5.0, 0);
|
---|
59 | listenThread = new ListenThread();
|
---|
60 | listenThread->start();
|
---|
61 | }
|
---|
62 |
|
---|
63 | PLUGIN_API void XPluginReceiveMessage(XPLMPluginID inFrom, long inMessage,
|
---|
64 | void* inParam)
|
---|
65 | {
|
---|
66 | debug("hu.varadiistvan.proba.XPluginReceiveMessage called, inFrom=%d, inMessage=%ld, inParam=%p\n",
|
---|
67 | inFrom, inMessage, inParam);
|
---|
68 | }
|
---|
69 |
|
---|
70 | PLUGIN_API void XPluginDisable(void)
|
---|
71 | {
|
---|
72 | debug("hu.varadiistvan.proba.XPluginDisable called\n");
|
---|
73 | // XPLMUnregisterFlightLoopCallback(&callback, 0);
|
---|
74 | if (listenThread!=0) {
|
---|
75 | listenThread->quit();
|
---|
76 | listenThread = 0;
|
---|
77 | }
|
---|
78 | }
|
---|
79 |
|
---|
80 | PLUGIN_API void XPluginStop(void)
|
---|
81 | {
|
---|
82 | debug("hu.varadiistvan.proba.XPluginStop called\n");
|
---|
83 | }
|
---|