Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
LogitechKeyboard.cs
Go to the documentation of this file.
3using Microsoft.Xna.Framework.Input;
4
6
8{
9 private readonly byte[] _colors;
10
11 private readonly KeyName[] _excludedKeys = new KeyName[126];
12
14 {
15 {
16 (Keys)27,
17 KeyName.ESC
18 },
19 {
20 (Keys)112,
21 KeyName.F1
22 },
23 {
24 (Keys)113,
25 KeyName.F2
26 },
27 {
28 (Keys)114,
29 KeyName.F3
30 },
31 {
32 (Keys)115,
33 KeyName.F4
34 },
35 {
36 (Keys)116,
37 KeyName.F5
38 },
39 {
40 (Keys)117,
41 KeyName.F6
42 },
43 {
44 (Keys)118,
45 KeyName.F7
46 },
47 {
48 (Keys)119,
49 KeyName.F8
50 },
51 {
52 (Keys)120,
53 KeyName.F9
54 },
55 {
56 (Keys)121,
57 KeyName.F10
58 },
59 {
60 (Keys)122,
61 KeyName.F11
62 },
63 {
64 (Keys)123,
65 KeyName.F12
66 },
67 {
68 (Keys)44,
69 KeyName.PRINT_SCREEN
70 },
71 {
72 (Keys)145,
73 KeyName.SCROLL_LOCK
74 },
75 {
76 (Keys)19,
77 KeyName.PAUSE_BREAK
78 },
79 {
80 (Keys)192,
81 KeyName.TILDE
82 },
83 {
84 (Keys)49,
85 KeyName.ONE
86 },
87 {
88 (Keys)50,
89 KeyName.TWO
90 },
91 {
92 (Keys)51,
93 KeyName.THREE
94 },
95 {
96 (Keys)52,
97 KeyName.FOUR
98 },
99 {
100 (Keys)53,
101 KeyName.FIVE
102 },
103 {
104 (Keys)54,
105 KeyName.SIX
106 },
107 {
108 (Keys)55,
109 KeyName.SEVEN
110 },
111 {
112 (Keys)56,
113 KeyName.EIGHT
114 },
115 {
116 (Keys)57,
117 KeyName.NINE
118 },
119 {
120 (Keys)48,
121 KeyName.ZERO
122 },
123 {
124 (Keys)189,
125 KeyName.MINUS
126 },
127 {
128 (Keys)187,
129 KeyName.EQUALS
130 },
131 {
132 (Keys)8,
133 KeyName.BACKSPACE
134 },
135 {
136 (Keys)45,
137 KeyName.INSERT
138 },
139 {
140 (Keys)36,
141 KeyName.HOME
142 },
143 {
144 (Keys)33,
145 KeyName.PAGE_UP
146 },
147 {
148 (Keys)144,
149 KeyName.NUM_LOCK
150 },
151 {
152 (Keys)111,
153 KeyName.NUM_SLASH
154 },
155 {
156 (Keys)106,
157 KeyName.NUM_ASTERISK
158 },
159 {
160 (Keys)109,
161 KeyName.NUM_MINUS
162 },
163 {
164 (Keys)9,
165 KeyName.TAB
166 },
167 {
168 (Keys)81,
169 KeyName.Q
170 },
171 {
172 (Keys)87,
173 KeyName.W
174 },
175 {
176 (Keys)69,
177 KeyName.E
178 },
179 {
180 (Keys)82,
181 KeyName.R
182 },
183 {
184 (Keys)84,
185 KeyName.T
186 },
187 {
188 (Keys)89,
189 KeyName.Y
190 },
191 {
192 (Keys)85,
193 KeyName.U
194 },
195 {
196 (Keys)73,
197 KeyName.I
198 },
199 {
200 (Keys)79,
201 KeyName.O
202 },
203 {
204 (Keys)80,
205 KeyName.P
206 },
207 {
208 (Keys)219,
209 KeyName.OPEN_BRACKET
210 },
211 {
212 (Keys)221,
213 KeyName.CLOSE_BRACKET
214 },
215 {
216 (Keys)226,
217 KeyName.BACKSLASH
218 },
219 {
220 (Keys)46,
221 KeyName.KEYBOARD_DELETE
222 },
223 {
224 (Keys)35,
225 KeyName.END
226 },
227 {
228 (Keys)34,
229 KeyName.PAGE_DOWN
230 },
231 {
232 (Keys)103,
233 KeyName.NUM_SEVEN
234 },
235 {
236 (Keys)104,
237 KeyName.NUM_EIGHT
238 },
239 {
240 (Keys)105,
241 KeyName.NUM_NINE
242 },
243 {
244 (Keys)107,
245 KeyName.NUM_PLUS
246 },
247 {
248 (Keys)20,
249 KeyName.CAPS_LOCK
250 },
251 {
252 (Keys)65,
253 KeyName.A
254 },
255 {
256 (Keys)83,
257 KeyName.S
258 },
259 {
260 (Keys)68,
261 KeyName.D
262 },
263 {
264 (Keys)70,
265 KeyName.F
266 },
267 {
268 (Keys)71,
269 KeyName.G
270 },
271 {
272 (Keys)72,
273 KeyName.H
274 },
275 {
276 (Keys)74,
277 KeyName.J
278 },
279 {
280 (Keys)75,
281 KeyName.K
282 },
283 {
284 (Keys)76,
285 KeyName.L
286 },
287 {
288 (Keys)186,
289 KeyName.SEMICOLON
290 },
291 {
292 (Keys)222,
293 KeyName.APOSTROPHE
294 },
295 {
296 (Keys)13,
297 KeyName.ENTER
298 },
299 {
300 (Keys)100,
301 KeyName.NUM_FOUR
302 },
303 {
304 (Keys)101,
305 KeyName.NUM_FIVE
306 },
307 {
308 (Keys)102,
309 KeyName.NUM_SIX
310 },
311 {
312 (Keys)160,
313 KeyName.LEFT_SHIFT
314 },
315 {
316 (Keys)90,
317 KeyName.Z
318 },
319 {
320 (Keys)88,
321 KeyName.X
322 },
323 {
324 (Keys)67,
325 KeyName.C
326 },
327 {
328 (Keys)86,
329 KeyName.V
330 },
331 {
332 (Keys)66,
333 KeyName.B
334 },
335 {
336 (Keys)78,
337 KeyName.N
338 },
339 {
340 (Keys)77,
341 KeyName.M
342 },
343 {
344 (Keys)188,
345 KeyName.COMMA
346 },
347 {
348 (Keys)190,
349 KeyName.PERIOD
350 },
351 {
352 (Keys)191,
353 KeyName.FORWARD_SLASH
354 },
355 {
356 (Keys)161,
357 KeyName.RIGHT_SHIFT
358 },
359 {
360 (Keys)38,
361 KeyName.ARROW_UP
362 },
363 {
364 (Keys)97,
365 KeyName.NUM_ONE
366 },
367 {
368 (Keys)98,
369 KeyName.NUM_TWO
370 },
371 {
372 (Keys)99,
373 KeyName.NUM_THREE
374 },
375 {
376 (Keys)162,
377 KeyName.LEFT_CONTROL
378 },
379 {
380 (Keys)91,
381 KeyName.LEFT_WINDOWS
382 },
383 {
384 (Keys)164,
385 KeyName.LEFT_ALT
386 },
387 {
388 (Keys)32,
389 KeyName.SPACE
390 },
391 {
392 (Keys)165,
393 KeyName.RIGHT_ALT
394 },
395 {
396 (Keys)92,
397 KeyName.RIGHT_WINDOWS
398 },
399 {
400 (Keys)93,
401 KeyName.APPLICATION_SELECT
402 },
403 {
404 (Keys)163,
405 KeyName.RIGHT_CONTROL
406 },
407 {
408 (Keys)37,
409 KeyName.ARROW_LEFT
410 },
411 {
412 (Keys)40,
413 KeyName.ARROW_DOWN
414 },
415 {
416 (Keys)39,
417 KeyName.ARROW_RIGHT
418 },
419 {
420 (Keys)96,
421 KeyName.NUM_ZERO
422 }
423 };
424
426 : base(RgbDeviceVendor.Logitech, Fragment.FromGrid(new Rectangle(0, 0, 21, 6)), colorProfile)
427 {
428 //IL_0014: Unknown result type (might be due to invalid IL or missing references)
429 _colors = new byte[base.LedCount * 4];
430 }
431
432 public override void Present()
433 {
434 //IL_000e: Unknown result type (might be due to invalid IL or missing references)
435 //IL_0013: Unknown result type (might be due to invalid IL or missing references)
436 //IL_001f: Unknown result type (might be due to invalid IL or missing references)
437 //IL_0038: Unknown result type (might be due to invalid IL or missing references)
438 //IL_004f: Unknown result type (might be due to invalid IL or missing references)
440 {
441 for (int i = 0; i < base.LedCount; i++)
442 {
444 _colors[i * 4 + 2] = (byte)(processedLedColor.X * 255f);
445 _colors[i * 4 + 1] = (byte)(processedLedColor.Y * 255f);
446 _colors[i * 4] = (byte)(processedLedColor.Z * 255f);
447 _colors[i * 4 + 3] = byte.MaxValue;
448 }
450 }
451 }
452
453 public override void Render(IEnumerable<RgbKey> keys)
454 {
455 //IL_0018: Unknown result type (might be due to invalid IL or missing references)
456 //IL_0028: Unknown result type (might be due to invalid IL or missing references)
457 //IL_002d: Unknown result type (might be due to invalid IL or missing references)
458 //IL_0032: Unknown result type (might be due to invalid IL or missing references)
459 int listCount = 0;
460 foreach (RgbKey key in keys)
461 {
462 if (XnaToLogitechKeys.TryGetValue(key.Key, out var value))
463 {
464 Color color = ProcessLedColor(key.CurrentColor);
465 _excludedKeys[listCount++] = value;
466 NativeMethods.LogiLedSetLightingForKeyWithKeyName(value, ((Color)(ref color)).R * 100 / 255, ((Color)(ref color)).G * 100 / 255, ((Color)(ref color)).B * 100 / 255);
467 }
468 }
470 }
471}
static readonly Dictionary< Keys, KeyName > XnaToLogitechKeys
LogitechKeyboard(DeviceColorProfile colorProfile)
override void Render(IEnumerable< RgbKey > keys)
static bool LogiLedSetLightingFromBitmap(byte[] bitmap)
static bool LogiLedSetTargetDevice(int targetDevice)
static bool LogiLedExcludeKeysFromBitmap(KeyName[] keyList, int listCount)
static bool LogiLedSetLightingForKeyWithKeyName(KeyName keyCode, int redPercentage, int greenPercentage, int bluePercentage)
Color ProcessLedColor(Color color)
Definition RgbDevice.cs:53
Vector4 GetProcessedLedColor(int index)
Definition RgbDevice.cs:37