-
Notifications
You must be signed in to change notification settings - Fork 6
/
kb_clevo.cs
351 lines (336 loc) · 9.28 KB
/
kb_clevo.cs
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
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
using Microsoft.Win32;
using System;
using System.Windows.Forms;
using System.Diagnostics;
using System.ServiceProcess;
using System.Threading;
public class Clevo
{
private EventLog eventLog1 = new EventLog();
private EventLog outlog = new EventLog();
private ServiceController serviceController1 = new ServiceController();
private bool bIsNew = true;
private bool bEnableSave;
public Clevo()
{
this.serviceController1.ServiceName = "PowerBiosServer";
this.eventLog1.Source = "PowerBiosServerSource";
this.eventLog1.Log = "PowerBiosServerLog";
this.outlog.Source = "PowerBIOSServer_Out";
this.outlog.Log = "OutLog";
if (this.serviceController1.Status != ServiceControllerStatus.Running || !EventLog.Exists(this.eventLog1.Log)) {
MessageBox.Show("CLEVO HotKey driver not found");
Application.Exit();
}
this.bEnableSave = true;
}
public int get_number_of_zones() {
return 4;
}
public void set_zone_color(int zone, int r, int g, int b) {
SetColor(r, g, b, zone + 1);
}
public void SetColor(int _iR, int _iG, int _iB, int iKbPart)
{
if (!this.bEnableSave)
return;
long data = (long) ((_iB << 16) + _iG + (_iR << 8));
if (iKbPart == 1)
data |= 4026531840L;
else if (iKbPart == 2)
data |= 4043309056L;
else if (iKbPart == 3)
data |= 4060086272L;
else if (iKbPart == 4)
data |= 4076863488L;
if (this.bIsNew)
{
this.SetWmi(103, data);
if (iKbPart == 4 && _iR == 0 && (_iG == 0 && _iB == 0))
{
this.SetLEDKBOnOff(true);
}
else
{
if (iKbPart != 4 || (_iR == 0 || _iG == 0) && _iB == 0)
return;
this.SetLEDKBOnOff(false);
}
}
else
{
this.eventLog1.WriteEntry(Convert.ToString(data));
Thread.Sleep(50);
this.serviceController1.ExecuteCommand(231);
Thread.Sleep(100);
}
}
public void SetLEDKBOn()
{
int num1 = 1;
int num2 = (int) Convert.ToInt16(Registry.GetValue("HKEY_CURRENT_USER\\Software\\hotkey\\LEDKB", "LedVolStatus", (object) "1"));
int num3 = (int) Convert.ToInt16(Registry.GetValue("HKEY_CURRENT_USER\\Software\\hotkey\\LEDKB", "KbLeftStatus", (object) "1"));
int num4 = (int) Convert.ToInt16(Registry.GetValue("HKEY_CURRENT_USER\\Software\\hotkey\\LEDKB", "KbMidStatus", (object) "1"));
int num5 = (int) Convert.ToInt16(Registry.GetValue("HKEY_CURRENT_USER\\Software\\hotkey\\LEDKB", "KbRightStatus", (object) "1"));
int num6 = (int) Convert.ToInt16(Registry.GetValue("HKEY_CURRENT_USER\\Software\\hotkey\\LEDKB", "KbTpStatus", (object) "1"));
uint num7 = 3758096384;
uint num8 = 7;
uint num9 = 0;
uint num10 = 0;
uint num11 = 0;
uint num12 = 1;
uint num13 = 1;
if (num1 == 1)
num7 = (uint) (((int) num7 | (int) num10 | (int) num11 | (int) num8 | (int) num9) + ((int) num12 << 12) + ((int) num13 << 13) + (num2 << 14) + (num6 << 15) + (num3 << 16) + (num4 << 17) + (num5 << 18));
this.SetWmi(103, (long) num7);
}
public void SetLEDKBOnOff(bool bIsBlack)
{
int num1 = (int) Convert.ToInt16(Registry.GetValue("HKEY_CURRENT_USER\\Software\\hotkey\\LEDKB", "KbTpStatus", (object) "1"));
if (num1 == 0 && !bIsBlack)
return;
uint num2 = 3758096384;
uint num3 = 1;
uint num4 = 0;
uint num5 = 0;
uint num6 = 0;
uint num7 = 1;
uint num8 = 1;
int num9 = (int) Convert.ToInt16(Registry.GetValue("HKEY_CURRENT_USER\\Software\\hotkey\\LEDKB", "LEDKB_Status", (object) "1"));
int num10 = (int) Convert.ToInt16(Registry.GetValue("HKEY_CURRENT_USER\\Software\\hotkey\\LEDKB", "LedVolStatus", (object) "1"));
int num11 = (int) Convert.ToInt16(Registry.GetValue("HKEY_CURRENT_USER\\Software\\hotkey\\LEDKB", "KbLeftStatus", (object) "1"));
int num12 = (int) Convert.ToInt16(Registry.GetValue("HKEY_CURRENT_USER\\Software\\hotkey\\LEDKB", "KbMidStatus", (object) "1"));
int num13 = (int) Convert.ToInt16(Registry.GetValue("HKEY_CURRENT_USER\\Software\\hotkey\\LEDKB", "KbRightStatus", (object) "1"));
if (bIsBlack)
num3 = 7U;
uint num14;
if (num9 == 1)
{
uint num15 = 0;
uint num16 = 0;
num14 = (uint) (((int) num2 | (int) num15 | (int) num16 | (int) num3 | (int) num4) + ((int) num7 << 12) + ((int) num8 << 13) + (num10 << 14) + (num1 << 15) + (num11 << 16) + (num12 << 17) + (num13 << 18));
}
else
num14 = (uint) (((int) num2 | (int) num5 | (int) num6 | (int) num3 | (int) num4) + ((int) num7 << 12) + ((int) num8 << 13));
this.SetWmi(103, (long) num14);
}
public void DisKbMode(int mode)
{
if (!this.bEnableSave || mode == 9)
return;
if (this.bIsNew)
{
this.SetWmi(103, 268435456L);
}
else
{
this.eventLog1.WriteEntry(Convert.ToString(268435456));
Thread.Sleep(50);
this.serviceController1.ExecuteCommand(231);
Thread.Sleep(100);
}
}
public void SetKbMode(int mode)
{
if (!this.bEnableSave)
return;
switch (mode)
{
case 0:
if (this.bIsNew)
{
this.SetWmi(103, 1879048192L);
break;
}
this.eventLog1.WriteEntry(Convert.ToString(1879048192));
Thread.Sleep(100);
this.serviceController1.ExecuteCommand(231);
break;
case 2:
int num1 = 0 | 40960 | (2 << 16 | 268435456);
if (this.bIsNew)
{
this.SetWmi(103, (long) num1);
break;
}
this.eventLog1.WriteEntry(Convert.ToString(num1));
Thread.Sleep(100);
this.serviceController1.ExecuteCommand(231);
break;
case 3:
int num2 = 1 << 16 | 3 << 24 | 805306368;
if (this.bIsNew)
{
this.SetWmi(103, (long) num2);
break;
}
this.eventLog1.WriteEntry(Convert.ToString(num2));
Thread.Sleep(100);
this.serviceController1.ExecuteCommand(231);
break;
case 4:
if (this.bIsNew)
{
this.SetWmi(103, 2952790016L);
break;
}
this.eventLog1.WriteEntry(Convert.ToString(2952790016U));
Thread.Sleep(100);
this.serviceController1.ExecuteCommand(231);
break;
case 5:
if (this.bIsNew)
{
this.SetWmi(103, 2147483648L);
break;
}
this.eventLog1.WriteEntry(Convert.ToString(2147483648U));
Thread.Sleep(100);
this.serviceController1.ExecuteCommand(231);
break;
case 6:
if (this.bIsNew)
{
this.SetWmi(103, 2415919104L);
break;
}
this.eventLog1.WriteEntry(Convert.ToString(2415919104U));
Thread.Sleep(100);
this.serviceController1.ExecuteCommand(231);
break;
case 7:
if (this.bIsNew)
{
this.SetWmi(103, 2684354560L);
break;
}
this.eventLog1.WriteEntry(Convert.ToString(2684354560U));
Thread.Sleep(100);
this.serviceController1.ExecuteCommand(231);
break;
}
}
public void SetColorAll(long _iR, long _iG, long _iB)
{
if (!this.bEnableSave)
return;
long data1 = (long) ((_iB << 16) + _iG + (_iR << 8)) | 4026531840L;
if (this.bIsNew)
{
this.SetWmi(103, data1);
}
else
{
this.eventLog1.WriteEntry(Convert.ToString(data1));
Thread.Sleep(50);
this.serviceController1.ExecuteCommand(231);
Thread.Sleep(100);
}
long data2 = (long) ((_iB << 16) + _iG + (_iR << 8)) | 4043309056L;
if (this.bIsNew)
{
this.SetWmi(103, data2);
}
else
{
this.eventLog1.WriteEntry(Convert.ToString(data2));
Thread.Sleep(50);
this.serviceController1.ExecuteCommand(231);
Thread.Sleep(100);
}
long data3 = (long) ((_iB << 16) + _iG + (_iR << 8)) | 4060086272L;
if (this.bIsNew)
{
this.SetWmi(103, data3);
}
else
{
this.eventLog1.WriteEntry(Convert.ToString(data3));
Thread.Sleep(50);
this.serviceController1.ExecuteCommand(231);
Thread.Sleep(100);
}
}
public void SetKbBrightness(int index)
{
long num;
switch (index)
{
case 0:
num = 63;
break;
case 1:
num = 126;
break;
case 2:
num = 189;
break;
case 3:
num = 252;
break;
default:
num = 1;
break;
}
long data = (long) num | 4093640704L;
if (this.bIsNew)
{
this.SetWmi(103, data);
}
else
{
this.eventLog1.WriteEntry(Convert.ToString(data));
Thread.Sleep(50);
this.serviceController1.ExecuteCommand(231);
Thread.Sleep(100);
}
}
public bool SetWmi(int arg, long data)
{
try
{
this.eventLog1.WriteEntry(("w_arg" + arg.ToString() + "^" + data.ToString()).ToLower());
Thread.Sleep(100);
return true;
}
catch
{
return false;
}
}
public bool Notice_KbClose()
{
try
{
this.outlog.WriteEntry("Arg888^0");
Thread.Sleep(100);
return true;
}
catch
{
return false;
}
}
public bool Notice_KbLedChange()
{
try
{
this.outlog.WriteEntry("Arg888^103");
Thread.Sleep(100);
return true;
}
catch
{
return false;
}
}
private enum KbPart
{
all,
left,
mid,
right,
touchpad,
none,
}
}