forked from WolfspiritM/Chrode
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Chroma.cc
108 lines (79 loc) · 3.63 KB
/
Chroma.cc
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
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
#include "SDK.h"
#include "NodeKeyboard.h"
#include <iostream>
using namespace std;
using v8::FunctionTemplate;
SDK SDKInstance;
NAN_METHOD(InitChroma) {
if(SDKInstance.m_ChromaSDKModule == NULL)
{
SDKInstance.m_ChromaSDKModule = LoadLibrary("RzChromaSDK64.dll");
if(SDKInstance.m_ChromaSDKModule == NULL)
{
SDKInstance.m_ChromaSDKModule = LoadLibrary("RzChromaSDK.dll");
}
}
if(SDKInstance.Init == NULL && SDKInstance.m_ChromaSDKModule!=NULL){
RZRESULT Result = RZRESULT_INVALID;
SDKInstance.Init = (INIT)GetProcAddress(SDKInstance.m_ChromaSDKModule, "Init");
if(SDKInstance.Init)
{
Result = SDKInstance.Init();
if(Result == RZRESULT_SUCCESS)
{
SDKInstance.CreateEffect = (CREATEEFFECT)GetProcAddress (SDKInstance.m_ChromaSDKModule, "CreateEffect");
SDKInstance.CreateKeyboardEffect = (CREATEKEYBOARDEFFECT)GetProcAddress (SDKInstance.m_ChromaSDKModule, "CreateKeyboardEffect");
SDKInstance.CreateMouseEffect = (CREATEMOUSEEFFECT)GetProcAddress (SDKInstance.m_ChromaSDKModule, "CreateMouseEffect");
SDKInstance.CreateHeadsetEffect = (CREATEHEADSETEFFECT)GetProcAddress (SDKInstance.m_ChromaSDKModule, "CreateHeadsetEffect");
SDKInstance.CreateMousepadEffect = (CREATEMOUSEPADEFFECT)GetProcAddress (SDKInstance.m_ChromaSDKModule, "CreateMousepadEffect");
SDKInstance.CreateKeypadEffect = (CREATEKEYPADEFFECT)GetProcAddress (SDKInstance.m_ChromaSDKModule, "CreateKeypadEffect");
SDKInstance.SetEffect = (SETEFFECT)GetProcAddress (SDKInstance.m_ChromaSDKModule, "SetEffect");
SDKInstance.DeleteEffect = (DELETEEFFECT)GetProcAddress (SDKInstance.m_ChromaSDKModule, "DeleteEffect");
SDKInstance.QueryDevice = (QUERYDEVICE)GetProcAddress (SDKInstance.m_ChromaSDKModule, "QueryDevice");
if (SDKInstance.CreateEffect &&
SDKInstance.CreateKeyboardEffect &&
SDKInstance.CreateMouseEffect &&
SDKInstance.CreateHeadsetEffect &&
SDKInstance.CreateMousepadEffect &&
SDKInstance.CreateKeypadEffect &&
SDKInstance.SetEffect &&
SDKInstance.DeleteEffect &&
SDKInstance.QueryDevice)
{
info.GetReturnValue().Set(true);
return;
}
}
}
}
info.GetReturnValue().Set(false);
}
NAN_METHOD(UnInitChroma) {
if(SDKInstance.m_ChromaSDKModule != NULL)
{
RZRESULT Result = RZRESULT_INVALID;
UNINIT UnInit = (UNINIT)GetProcAddress (SDKInstance.m_ChromaSDKModule, "UnInit");
if(UnInit)
{
Result = UnInit();
}
bool success = FreeLibrary (SDKInstance.m_ChromaSDKModule);
SDKInstance.m_ChromaSDKModule = NULL;
info.GetReturnValue().Set(success);
return;
}
info.GetReturnValue().Set(false);
}
NAN_METHOD(SetAll) {
}
NAN_MODULE_INIT(InitAll) {
SDKInstance = SDK();
Nan::Set(target, Nan::New("InitChroma").ToLocalChecked(),
Nan::GetFunction(Nan::New<FunctionTemplate>(InitChroma)).ToLocalChecked());
Nan::Set(target, Nan::New("UnInitChroma").ToLocalChecked(),
Nan::GetFunction(Nan::New<FunctionTemplate>(UnInitChroma)).ToLocalChecked());
Nan::Set(target, Nan::New("SetAll").ToLocalChecked(),
Nan::GetFunction(Nan::New<FunctionTemplate>(SetAll)).ToLocalChecked());
NodeKeyboard::Init(target, &SDKInstance);
}
NODE_MODULE(Chroma, InitAll)