-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathmain.cpp
More file actions
92 lines (81 loc) · 1.92 KB
/
main.cpp
File metadata and controls
92 lines (81 loc) · 1.92 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
89
90
91
92
#include <string.h>
#include <string>
#include <stdio.h>
#include <stdlib.h>
#include "include/SDK/XPLMDefs.h"
#include "include/session.h"
#include "include/version.h"
const char* plugin_version = "1.1.0";
#if IBM
#include <windows.h>
#ifdef __cplusplus
extern "C"
{
#endif
PLUGIN_API int XPluginStart(char* name, char* signature, char* description);
PLUGIN_API int XPluginEnable(void);
PLUGIN_API void XPluginDisable(void);
PLUGIN_API void XPluginStop(void);
PLUGIN_API void XPluginReceiveMessage(XPLMPluginID inFromWho, long inMessage, void* inParam);
#ifdef __cplusplus
}
#endif
BOOL APIENTRY DllMain( HMODULE hModule,
DWORD ul_reason_for_call,
LPVOID lpReserved
)
{
switch (ul_reason_for_call)
{
case DLL_PROCESS_ATTACH:
case DLL_THREAD_ATTACH:
case DLL_THREAD_DETACH:
case DLL_PROCESS_DETACH:
break;
}
return TRUE;
}
#endif
static session_t* session = 0;
PLUGIN_API int XPluginStart(char* name, char* signature, char* description)
{
strcpy(name, "xcontrol (");
strcat(name, plugin_version);
strcat(name, ")");
strcpy(signature, "copai.equipment.control");
strcpy(description, "provides enhanced features covering Saitek products, compiled on ");
strcat(description, __DATE__);
try
{
session = new session_t();
}
catch (const char* e)
{
if (!strcmp(e, "control.nonfatal"))
return 0;
else
abort();
}
return 1;
}
PLUGIN_API int XPluginEnable(void)
{
if (!session) return 0;
return session->enable();
return 0;
}
PLUGIN_API void XPluginDisable(void)
{
if (!session) return;
session->disable();
return;
}
PLUGIN_API void XPluginStop(void)
{
if (session) delete session;
return;
}
PLUGIN_API void XPluginReceiveMessage(XPLMPluginID inFromWho, long inMessage, void* inParam)
{
return;
}