Commit | Line | Data |
---|---|---|
4ef3b314 LOK |
1 | #pragma once |
2 | /* | |
f9717bcc LOK |
3 | * This file is part of the libCEC(R) library. |
4 | * | |
16f47961 | 5 | * libCEC(R) is Copyright (C) 2011-2013 Pulse-Eight Limited. All rights reserved. |
f9717bcc LOK |
6 | * libCEC(R) is an original work, containing original code. |
7 | * | |
8 | * libCEC(R) is a trademark of Pulse-Eight Limited. | |
9 | * | |
10 | * This program is dual-licensed; you can redistribute it and/or modify | |
11 | * it under the terms of the GNU General Public License as published by | |
12 | * the Free Software Foundation; either version 2 of the License, or | |
13 | * (at your option) any later version. | |
14 | * | |
15 | * This program is distributed in the hope that it will be useful, | |
16 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
17 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
18 | * GNU General Public License for more details. | |
19 | * | |
20 | * You should have received a copy of the GNU General Public License | |
21 | * along with this program; if not, write to the Free Software | |
22 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | |
23 | * | |
24 | * | |
25 | * Alternatively, you can license this library under a commercial license, | |
26 | * please contact Pulse-Eight Licensing for more information. | |
27 | * | |
28 | * For more information contact: | |
29 | * Pulse-Eight Licensing <license@pulse-eight.com> | |
30 | * http://www.pulse-eight.com/ | |
31 | * http://www.pulse-eight.net/ | |
32 | */ | |
4ef3b314 | 33 | |
dc6366e8 | 34 | #include "../lib/platform/threads/mutex.h" |
4ef3b314 LOK |
35 | #include <vcclr.h> |
36 | #include <msclr/marshal.h> | |
37 | #include "../../include/cec.h" | |
dc6366e8 | 38 | #include <vector> |
4ef3b314 LOK |
39 | |
40 | #using <System.dll> | |
41 | ||
1c7cd8f8 LOK |
42 | /// <summary> |
43 | /// LibCecSharp namespace | |
44 | /// </summary> | |
45 | /// <see cref="LibCecSharp" /> | |
4ef3b314 LOK |
46 | namespace CecSharp |
47 | { | |
8438c41f LOK |
48 | /// <summary> |
49 | /// The device type. For client applications, libCEC only supports RecordingDevice, PlaybackDevice or Tuner. | |
50 | /// libCEC uses RecordingDevice by default. | |
51 | /// </summary> | |
f9717bcc LOK |
52 | public enum class CecDeviceType |
53 | { | |
8438c41f LOK |
54 | /// <summary> |
55 | /// Television | |
56 | /// </summary> | |
f9717bcc | 57 | Tv = 0, |
8438c41f LOK |
58 | /// <summary> |
59 | /// Recording device | |
60 | /// </summary> | |
f9717bcc | 61 | RecordingDevice = 1, |
8438c41f LOK |
62 | /// <summary> |
63 | /// Reserved / do not use | |
64 | /// </summary> | |
f9717bcc | 65 | Reserved = 2, |
8438c41f LOK |
66 | /// <summary> |
67 | /// Tuner | |
68 | /// </summary> | |
f9717bcc | 69 | Tuner = 3, |
8438c41f LOK |
70 | /// <summary> |
71 | /// Playback device | |
72 | /// </summary> | |
f9717bcc | 73 | PlaybackDevice = 4, |
8438c41f LOK |
74 | /// <summary> |
75 | /// Audio system / AVR | |
76 | /// </summary> | |
f9717bcc LOK |
77 | AudioSystem = 5 |
78 | }; | |
79 | ||
8438c41f LOK |
80 | /// <summary> |
81 | /// Log level that can be used by the logging callback method to filter messages from libCEC. | |
82 | /// </summary> | |
f9717bcc LOK |
83 | public enum class CecLogLevel |
84 | { | |
8438c41f LOK |
85 | /// <summary> |
86 | /// No logging | |
87 | /// </summary> | |
f9717bcc | 88 | None = 0, |
8438c41f LOK |
89 | /// <summary> |
90 | /// libCEC encountered a serious problem, and couldn't complete an action. | |
91 | /// </summary> | |
f9717bcc | 92 | Error = 1, |
8438c41f LOK |
93 | /// <summary> |
94 | /// libCEC warns that it encountered a problem, but recovered. | |
95 | /// </summary> | |
f9717bcc | 96 | Warning = 2, |
8438c41f LOK |
97 | /// <summary> |
98 | /// libCEC informs the client about a CEC state change. | |
99 | /// </summary> | |
f9717bcc | 100 | Notice = 4, |
8438c41f LOK |
101 | /// <summary> |
102 | /// Raw CEC data traffic | |
103 | /// </summary> | |
f9717bcc | 104 | Traffic = 8, |
8438c41f LOK |
105 | /// <summary> |
106 | /// Debugging messages | |
107 | /// </summary> | |
f9717bcc | 108 | Debug = 16, |
8438c41f LOK |
109 | /// <summary> |
110 | /// Display all messages | |
111 | /// </summary> | |
f9717bcc LOK |
112 | All = 31 |
113 | }; | |
114 | ||
8438c41f LOK |
115 | /// <summary> |
116 | /// A logical address on the CEC bus | |
117 | /// </summary> | |
f9717bcc LOK |
118 | public enum class CecLogicalAddress |
119 | { | |
8438c41f LOK |
120 | /// <summary> |
121 | /// Not a valid logical address | |
122 | /// </summary> | |
123 | Unknown = -1, | |
124 | /// <summary> | |
125 | /// Television | |
126 | /// </summary> | |
f9717bcc | 127 | Tv = 0, |
8438c41f LOK |
128 | /// <summary> |
129 | /// Recording device 1 | |
130 | /// </summary> | |
f9717bcc | 131 | RecordingDevice1 = 1, |
8438c41f LOK |
132 | /// <summary> |
133 | /// Recording device 2 | |
134 | /// </summary> | |
f9717bcc | 135 | RecordingDevice2 = 2, |
8438c41f LOK |
136 | /// <summary> |
137 | /// Tuner 1 | |
138 | /// </summary> | |
f9717bcc | 139 | Tuner1 = 3, |
8438c41f LOK |
140 | /// <summary> |
141 | /// Playback device 1 | |
142 | /// </summary> | |
f9717bcc | 143 | PlaybackDevice1 = 4, |
8438c41f LOK |
144 | /// <summary> |
145 | /// Audio system / AVR | |
146 | /// </summary> | |
f9717bcc | 147 | AudioSystem = 5, |
8438c41f LOK |
148 | /// <summary> |
149 | /// Tuner 2 | |
150 | /// </summary> | |
f9717bcc | 151 | Tuner2 = 6, |
8438c41f LOK |
152 | /// <summary> |
153 | /// Tuner 3 | |
154 | /// </summary> | |
f9717bcc | 155 | Tuner3 = 7, |
8438c41f LOK |
156 | /// <summary> |
157 | /// Playback device 2 | |
158 | /// </summary> | |
f9717bcc | 159 | PlaybackDevice2 = 8, |
8438c41f LOK |
160 | /// <summary> |
161 | /// Recording device 3 | |
162 | /// </summary> | |
f9717bcc | 163 | RecordingDevice3 = 9, |
8438c41f LOK |
164 | /// <summary> |
165 | /// Tuner 4 | |
166 | /// </summary> | |
f9717bcc | 167 | Tuner4 = 10, |
8438c41f LOK |
168 | /// <summary> |
169 | /// Playback device 3 | |
170 | /// </summary> | |
f9717bcc | 171 | PlaybackDevice3 = 11, |
8438c41f LOK |
172 | /// <summary> |
173 | /// Reserved address 1 | |
174 | /// </summary> | |
f9717bcc | 175 | Reserved1 = 12, |
8438c41f LOK |
176 | /// <summary> |
177 | /// Reserved address 2 | |
178 | /// </summary> | |
f9717bcc | 179 | Reserved2 = 13, |
8438c41f LOK |
180 | /// <summary> |
181 | /// Free to use | |
182 | /// </summary> | |
f9717bcc | 183 | FreeUse = 14, |
8438c41f LOK |
184 | /// <summary> |
185 | /// Unregistered / new device | |
186 | /// </summary> | |
f9717bcc | 187 | Unregistered = 15, |
8438c41f LOK |
188 | /// <summary> |
189 | /// Broadcast address | |
190 | /// </summary> | |
f9717bcc LOK |
191 | Broadcast = 15 |
192 | }; | |
193 | ||
8438c41f LOK |
194 | /// <summary> |
195 | /// The type of alert when libCEC calls the CecAlert callback | |
196 | /// </summary> | |
f9717bcc LOK |
197 | public enum class CecAlert |
198 | { | |
8438c41f LOK |
199 | /// <summary> |
200 | /// The device needs servicing. This is set when the firmware can be upgraded, or when a problem with the firmware is detected. | |
201 | /// The latest firmware flash tool can be downloaded from http://packages.pulse-eight.net/ | |
202 | /// </summary> | |
5b431288 LOK |
203 | ServiceDevice = 0, |
204 | /// <summary> | |
205 | /// The connection to the adapter was lost, probably because the device got unplugged. | |
206 | /// </summary> | |
207 | ConnectionLost, | |
208 | /// <summary> | |
209 | /// No permission from the OS to access the adapter. | |
210 | /// </summary> | |
211 | PermissionError, | |
212 | /// <summary> | |
213 | /// The device is being used by another program. | |
214 | /// </summary> | |
215 | PortBusy, | |
216 | /// <summary> | |
217 | /// The physical address that is assigned to the adapter is already being used. | |
218 | /// </summary> | |
219 | PhysicalAddressError, | |
220 | /// <summary> | |
221 | /// The TV does not respond to polls. | |
222 | /// </summary> | |
223 | TVPollFailed | |
f9717bcc LOK |
224 | }; |
225 | ||
8438c41f LOK |
226 | /// <summary> |
227 | /// The type of parameter that is sent with the CecAlert callback | |
228 | /// </summary> | |
f9717bcc LOK |
229 | public enum class CecParameterType |
230 | { | |
8438c41f LOK |
231 | /// <summary> |
232 | /// The parameter is a string | |
233 | /// </summary> | |
f9717bcc LOK |
234 | ParameterTypeString = 1 |
235 | }; | |
236 | ||
8438c41f LOK |
237 | /// <summary> |
238 | /// A parameter for the CecAlert callback | |
239 | /// </summary> | |
f9717bcc LOK |
240 | public ref class CecParameter |
241 | { | |
242 | public: | |
8438c41f LOK |
243 | /// <summary> |
244 | /// Create a new parameter | |
245 | /// </summary> | |
246 | /// <param name="type">The type of this parameter.</param> | |
247 | /// <param name="data">The value of this parameter.</param> | |
248 | CecParameter(CecParameterType type, System::String ^ data) | |
f9717bcc LOK |
249 | { |
250 | Type = type; | |
8438c41f | 251 | Data = data; |
f9717bcc LOK |
252 | } |
253 | ||
8438c41f LOK |
254 | /// <summary> |
255 | /// The type of this parameter | |
256 | /// </summary> | |
f9717bcc | 257 | property CecParameterType Type; |
8438c41f LOK |
258 | /// <summary> |
259 | /// The value of this parameter | |
260 | /// </summary> | |
f9717bcc LOK |
261 | property System::String ^ Data; |
262 | }; | |
263 | ||
8438c41f LOK |
264 | /// <summary> |
265 | /// The power status of a CEC device | |
266 | /// </summary> | |
f9717bcc LOK |
267 | public enum class CecPowerStatus |
268 | { | |
8438c41f LOK |
269 | /// <summary> |
270 | /// Powered on | |
271 | /// </summary> | |
f9717bcc | 272 | On = 0x00, |
8438c41f LOK |
273 | /// <summary> |
274 | /// In standby mode | |
275 | /// </summary> | |
f9717bcc | 276 | Standby = 0x01, |
8438c41f LOK |
277 | /// <summary> |
278 | /// In transition from standby to on | |
279 | /// </summary> | |
f9717bcc | 280 | InTransitionStandbyToOn = 0x02, |
8438c41f LOK |
281 | /// <summary> |
282 | /// In transition from on to standby | |
283 | /// </summary> | |
f9717bcc | 284 | InTransitionOnToStandby = 0x03, |
8438c41f LOK |
285 | /// <summary> |
286 | /// Unknown status | |
287 | /// </summary> | |
f9717bcc LOK |
288 | Unknown = 0x99 |
289 | }; | |
290 | ||
8438c41f LOK |
291 | /// <summary> |
292 | /// The CEC version of a CEC device | |
293 | /// </summary> | |
f9717bcc LOK |
294 | public enum class CecVersion |
295 | { | |
8438c41f LOK |
296 | /// <summary> |
297 | /// Unknown version | |
298 | /// </summary> | |
f9717bcc | 299 | Unknown = 0x00, |
8438c41f LOK |
300 | /// <summary> |
301 | /// Version 1.2 | |
302 | /// </summary> | |
f9717bcc | 303 | V1_2 = 0x01, |
8438c41f LOK |
304 | /// <summary> |
305 | /// Version 1.2a | |
306 | /// </summary> | |
f9717bcc | 307 | V1_2A = 0x02, |
8438c41f LOK |
308 | /// <summary> |
309 | /// Version 1.3 | |
310 | /// </summary> | |
f9717bcc | 311 | V1_3 = 0x03, |
8438c41f LOK |
312 | /// <summary> |
313 | /// Version 1.3a | |
314 | /// </summary> | |
f9717bcc | 315 | V1_3A = 0x04, |
8438c41f LOK |
316 | /// <summary> |
317 | /// Version 1.4 | |
318 | /// </summary> | |
f9717bcc LOK |
319 | V1_4 = 0x05 |
320 | }; | |
321 | ||
8438c41f LOK |
322 | /// <summary> |
323 | /// Parameter for OSD string display, that controls how to display the string | |
324 | /// </summary> | |
f9717bcc LOK |
325 | public enum class CecDisplayControl |
326 | { | |
8438c41f LOK |
327 | /// <summary> |
328 | /// Display for the default time | |
329 | /// </summary> | |
f9717bcc | 330 | DisplayForDefaultTime = 0x00, |
8438c41f LOK |
331 | /// <summary> |
332 | /// Display until it is cleared by ClearPreviousMessage | |
333 | /// </summary> | |
f9717bcc | 334 | DisplayUntilCleared = 0x40, |
8438c41f LOK |
335 | /// <summary> |
336 | /// Clear message displayed by DisplayUntilCleared | |
337 | /// </summary> | |
f9717bcc | 338 | ClearPreviousMessage = 0x80, |
8438c41f LOK |
339 | /// <summary> |
340 | /// Reserved / do not use | |
341 | /// </summary> | |
f9717bcc LOK |
342 | ReservedForFutureUse = 0xC0 |
343 | }; | |
344 | ||
8438c41f LOK |
345 | /// <summary> |
346 | /// The menu state of a CEC device | |
347 | /// </summary> | |
f9717bcc LOK |
348 | public enum class CecMenuState |
349 | { | |
8438c41f LOK |
350 | /// <summary> |
351 | /// Menu active | |
352 | /// </summary> | |
f9717bcc | 353 | Activated = 0, |
8438c41f LOK |
354 | /// <summary> |
355 | /// Menu not active | |
356 | /// </summary> | |
f9717bcc LOK |
357 | Deactivated = 1 |
358 | }; | |
359 | ||
8438c41f LOK |
360 | /// <summary> |
361 | /// Deck control mode for playback and recording devices | |
362 | /// </summary> | |
f9717bcc LOK |
363 | public enum class CecDeckControlMode |
364 | { | |
8438c41f LOK |
365 | /// <summary> |
366 | /// Skip forward / wind | |
367 | /// </summary> | |
f9717bcc | 368 | SkipForwardWind = 1, |
8438c41f LOK |
369 | /// <summary> |
370 | /// Skip reverse / rewind | |
371 | /// </summary> | |
f9717bcc | 372 | SkipReverseRewind = 2, |
8438c41f LOK |
373 | /// <summary> |
374 | /// Stop | |
375 | /// </summary> | |
f9717bcc | 376 | Stop = 3, |
8438c41f LOK |
377 | /// <summary> |
378 | /// Eject | |
379 | /// </summary> | |
f9717bcc LOK |
380 | Eject = 4 |
381 | }; | |
382 | ||
8438c41f LOK |
383 | /// <summary> |
384 | /// Deck status for playback and recording devices | |
385 | /// </summary> | |
f9717bcc LOK |
386 | public enum class CecDeckInfo |
387 | { | |
8438c41f LOK |
388 | /// <summary> |
389 | /// Playing | |
390 | /// </summary> | |
f9717bcc | 391 | Play = 0x11, |
8438c41f LOK |
392 | /// <summary> |
393 | /// Recording | |
394 | /// </summary> | |
f9717bcc | 395 | Record = 0x12, |
8438c41f LOK |
396 | /// <summary> |
397 | /// Reverse | |
398 | /// </summary> | |
f9717bcc | 399 | Reverse = 0x13, |
8438c41f LOK |
400 | /// <summary> |
401 | /// Showing still frame | |
402 | /// </summary> | |
f9717bcc | 403 | Still = 0x14, |
8438c41f LOK |
404 | /// <summary> |
405 | /// Playing slow | |
406 | /// </summary> | |
f9717bcc | 407 | Slow = 0x15, |
8438c41f LOK |
408 | /// <summary> |
409 | /// Playing slow reverse | |
410 | /// </summary> | |
f9717bcc | 411 | SlowReverse = 0x16, |
8438c41f LOK |
412 | /// <summary> |
413 | /// Fast forward | |
414 | /// </summary> | |
f9717bcc | 415 | FastForward = 0x17, |
8438c41f LOK |
416 | /// <summary> |
417 | /// Fast reverse | |
418 | /// </summary> | |
f9717bcc | 419 | FastReverse = 0x18, |
8438c41f LOK |
420 | /// <summary> |
421 | /// No media detected | |
422 | /// </summary> | |
f9717bcc | 423 | NoMedia = 0x19, |
8438c41f LOK |
424 | /// <summary> |
425 | /// Stop / not playing | |
426 | /// </summary> | |
f9717bcc | 427 | Stop = 0x1A, |
8438c41f LOK |
428 | /// <summary> |
429 | /// Skip forward / wind | |
430 | /// </summary> | |
f9717bcc | 431 | SkipForwardWind = 0x1B, |
8438c41f LOK |
432 | /// <summary> |
433 | /// Skip reverse / rewind | |
434 | /// </summary> | |
f9717bcc | 435 | SkipReverseRewind = 0x1C, |
8438c41f LOK |
436 | /// <summary> |
437 | /// Index search forward | |
438 | /// </summary> | |
f9717bcc | 439 | IndexSearchForward = 0x1D, |
8438c41f LOK |
440 | /// <summary> |
441 | /// Index search reverse | |
442 | /// </summary> | |
f9717bcc | 443 | IndexSearchReverse = 0x1E, |
8438c41f LOK |
444 | /// <summary> |
445 | /// Other / unknown status | |
446 | /// </summary> | |
f9717bcc LOK |
447 | OtherStatus = 0x1F |
448 | }; | |
449 | ||
8438c41f LOK |
450 | /// <summary> |
451 | /// User control code, the key code when the user presses or releases a button on the remote. | |
1c7cd8f8 | 452 | /// Used by SendKeypress() and the CecKey callback. |
8438c41f | 453 | /// </summary> |
f9717bcc LOK |
454 | public enum class CecUserControlCode |
455 | { | |
8438c41f LOK |
456 | /// <summary> |
457 | /// Select / OK | |
458 | /// </summary> | |
f9717bcc | 459 | Select = 0x00, |
8438c41f LOK |
460 | /// <summary> |
461 | /// Direction up | |
462 | /// </summary> | |
f9717bcc | 463 | Up = 0x01, |
8438c41f LOK |
464 | /// <summary> |
465 | /// Direction down | |
466 | /// </summary> | |
f9717bcc | 467 | Down = 0x02, |
8438c41f LOK |
468 | /// <summary> |
469 | /// Direction left | |
470 | /// </summary> | |
f9717bcc | 471 | Left = 0x03, |
8438c41f LOK |
472 | /// <summary> |
473 | /// Direction right | |
474 | /// </summary> | |
f9717bcc | 475 | Right = 0x04, |
8438c41f LOK |
476 | /// <summary> |
477 | /// Direction right + up | |
478 | /// </summary> | |
f9717bcc | 479 | RightUp = 0x05, |
8438c41f LOK |
480 | /// <summary> |
481 | /// Direction right + down | |
482 | /// </summary> | |
f9717bcc | 483 | RightDown = 0x06, |
8438c41f LOK |
484 | /// <summary> |
485 | /// Direction left + up | |
486 | /// </summary> | |
f9717bcc | 487 | LeftUp = 0x07, |
8438c41f LOK |
488 | /// <summary> |
489 | /// Direction left + down | |
490 | /// </summary> | |
f9717bcc | 491 | LeftDown = 0x08, |
8438c41f LOK |
492 | /// <summary> |
493 | /// Root menu | |
494 | /// </summary> | |
f9717bcc | 495 | RootMenu = 0x09, |
8438c41f LOK |
496 | /// <summary> |
497 | /// Setup menu | |
498 | /// </summary> | |
f9717bcc | 499 | SetupMenu = 0x0A, |
8438c41f LOK |
500 | /// <summary> |
501 | /// Contents menu | |
502 | /// </summary> | |
f9717bcc | 503 | ContentsMenu = 0x0B, |
8438c41f LOK |
504 | /// <summary> |
505 | /// Favourite menu | |
506 | /// </summary> | |
f9717bcc | 507 | FavoriteMenu = 0x0C, |
8438c41f LOK |
508 | /// <summary> |
509 | /// Exit / back | |
510 | /// </summary> | |
f9717bcc | 511 | Exit = 0x0D, |
8438c41f LOK |
512 | /// <summary> |
513 | /// Number 0 | |
514 | /// </summary> | |
f9717bcc | 515 | Number0 = 0x20, |
8438c41f LOK |
516 | /// <summary> |
517 | /// Number 1 | |
518 | /// </summary> | |
f9717bcc | 519 | Number1 = 0x21, |
8438c41f LOK |
520 | /// <summary> |
521 | /// Number 2 | |
522 | /// </summary> | |
f9717bcc | 523 | Number2 = 0x22, |
8438c41f LOK |
524 | /// <summary> |
525 | /// Number 3 | |
526 | /// </summary> | |
f9717bcc | 527 | Number3 = 0x23, |
8438c41f LOK |
528 | /// <summary> |
529 | /// Number 4 | |
530 | /// </summary> | |
f9717bcc | 531 | Number4 = 0x24, |
8438c41f LOK |
532 | /// <summary> |
533 | /// Number 5 | |
534 | /// </summary> | |
f9717bcc | 535 | Number5 = 0x25, |
8438c41f LOK |
536 | /// <summary> |
537 | /// Number 6 | |
538 | /// </summary> | |
f9717bcc | 539 | Number6 = 0x26, |
8438c41f LOK |
540 | /// <summary> |
541 | /// Number 7 | |
542 | /// </summary> | |
f9717bcc | 543 | Number7 = 0x27, |
8438c41f LOK |
544 | /// <summary> |
545 | /// Number 8 | |
546 | /// </summary> | |
f9717bcc | 547 | Number8 = 0x28, |
8438c41f LOK |
548 | /// <summary> |
549 | /// Number 9 | |
550 | /// </summary> | |
f9717bcc | 551 | Number9 = 0x29, |
8438c41f LOK |
552 | /// <summary> |
553 | /// . | |
554 | /// </summary> | |
f9717bcc | 555 | Dot = 0x2A, |
8438c41f LOK |
556 | /// <summary> |
557 | /// Enter input | |
558 | /// </summary> | |
f9717bcc | 559 | Enter = 0x2B, |
8438c41f LOK |
560 | /// <summary> |
561 | /// Clear input | |
562 | /// </summary> | |
f9717bcc | 563 | Clear = 0x2C, |
8438c41f LOK |
564 | /// <summary> |
565 | /// Next favourite | |
566 | /// </summary> | |
f9717bcc | 567 | NextFavorite = 0x2F, |
8438c41f LOK |
568 | /// <summary> |
569 | /// Channel up | |
570 | /// </summary> | |
f9717bcc | 571 | ChannelUp = 0x30, |
8438c41f LOK |
572 | /// <summary> |
573 | /// Channel down | |
574 | /// </summary> | |
f9717bcc | 575 | ChannelDown = 0x31, |
8438c41f LOK |
576 | /// <summary> |
577 | /// Previous channel | |
578 | /// </summary> | |
f9717bcc | 579 | PreviousChannel = 0x32, |
8438c41f LOK |
580 | /// <summary> |
581 | /// Select sound track | |
582 | /// </summary> | |
f9717bcc | 583 | SoundSelect = 0x33, |
8438c41f LOK |
584 | /// <summary> |
585 | /// Select input | |
586 | /// </summary> | |
f9717bcc | 587 | InputSelect = 0x34, |
8438c41f LOK |
588 | /// <summary> |
589 | /// Display information | |
590 | /// </summary> | |
f9717bcc | 591 | DisplayInformation = 0x35, |
8438c41f LOK |
592 | /// <summary> |
593 | /// Show help | |
594 | /// </summary> | |
f9717bcc | 595 | Help = 0x36, |
8438c41f LOK |
596 | /// <summary> |
597 | /// Page up | |
598 | /// </summary> | |
f9717bcc | 599 | PageUp = 0x37, |
8438c41f LOK |
600 | /// <summary> |
601 | /// Page down | |
602 | /// </summary> | |
f9717bcc | 603 | PageDown = 0x38, |
8438c41f LOK |
604 | /// <summary> |
605 | /// Toggle powered on / standby | |
606 | /// </summary> | |
f9717bcc | 607 | Power = 0x40, |
8438c41f LOK |
608 | /// <summary> |
609 | /// Volume up | |
610 | /// </summary> | |
f9717bcc | 611 | VolumeUp = 0x41, |
8438c41f LOK |
612 | /// <summary> |
613 | /// Volume down | |
614 | /// </summary> | |
f9717bcc | 615 | VolumeDown = 0x42, |
8438c41f LOK |
616 | /// <summary> |
617 | /// Mute audio | |
618 | /// </summary> | |
f9717bcc | 619 | Mute = 0x43, |
8438c41f LOK |
620 | /// <summary> |
621 | /// Start playback | |
622 | /// </summary> | |
f9717bcc | 623 | Play = 0x44, |
8438c41f LOK |
624 | /// <summary> |
625 | /// Stop playback | |
626 | /// </summary> | |
f9717bcc | 627 | Stop = 0x45, |
8438c41f LOK |
628 | /// <summary> |
629 | /// Pause playback | |
630 | /// </summary> | |
f9717bcc | 631 | Pause = 0x46, |
8438c41f LOK |
632 | /// <summary> |
633 | /// Toggle recording | |
634 | /// </summary> | |
f9717bcc | 635 | Record = 0x47, |
8438c41f LOK |
636 | /// <summary> |
637 | /// Rewind | |
638 | /// </summary> | |
f9717bcc | 639 | Rewind = 0x48, |
8438c41f LOK |
640 | /// <summary> |
641 | /// Fast forward | |
642 | /// </summary> | |
f9717bcc | 643 | FastForward = 0x49, |
8438c41f LOK |
644 | /// <summary> |
645 | /// Eject media | |
646 | /// </summary> | |
f9717bcc | 647 | Eject = 0x4A, |
8438c41f LOK |
648 | /// <summary> |
649 | /// Forward | |
650 | /// </summary> | |
f9717bcc | 651 | Forward = 0x4B, |
8438c41f LOK |
652 | /// <summary> |
653 | /// Backward | |
654 | /// </summary> | |
f9717bcc | 655 | Backward = 0x4C, |
8438c41f LOK |
656 | /// <summary> |
657 | /// Stop recording | |
658 | /// </summary> | |
f9717bcc | 659 | StopRecord = 0x4D, |
8438c41f LOK |
660 | /// <summary> |
661 | /// Pause recording | |
662 | /// </summary> | |
f9717bcc | 663 | PauseRecord = 0x4E, |
8438c41f LOK |
664 | /// <summary> |
665 | /// Change angle | |
666 | /// </summary> | |
f9717bcc | 667 | Angle = 0x50, |
8438c41f LOK |
668 | /// <summary> |
669 | /// Toggle sub picture | |
670 | /// </summary> | |
f9717bcc | 671 | SubPicture = 0x51, |
8438c41f LOK |
672 | /// <summary> |
673 | /// Toggle video on demand | |
674 | /// </summary> | |
f9717bcc | 675 | VideoOnDemand = 0x52, |
8438c41f LOK |
676 | /// <summary> |
677 | /// Toggle electronic program guide (EPG) | |
678 | /// </summary> | |
f9717bcc | 679 | ElectronicProgramGuide = 0x53, |
8438c41f LOK |
680 | /// <summary> |
681 | /// Toggle timer programming | |
682 | /// </summary> | |
f9717bcc | 683 | TimerProgramming = 0x54, |
8438c41f LOK |
684 | /// <summary> |
685 | /// Set initial configuration | |
686 | /// </summary> | |
f9717bcc | 687 | InitialConfiguration = 0x55, |
8438c41f LOK |
688 | /// <summary> |
689 | /// Start playback function | |
690 | /// </summary> | |
f9717bcc | 691 | PlayFunction = 0x60, |
8438c41f LOK |
692 | /// <summary> |
693 | /// Pause playback function | |
694 | /// </summary> | |
f9717bcc | 695 | PausePlayFunction = 0x61, |
8438c41f LOK |
696 | /// <summary> |
697 | /// Toggle recording function | |
698 | /// </summary> | |
f9717bcc | 699 | RecordFunction = 0x62, |
8438c41f LOK |
700 | /// <summary> |
701 | /// Pause recording function | |
702 | /// </summary> | |
f9717bcc | 703 | PauseRecordFunction = 0x63, |
8438c41f LOK |
704 | /// <summary> |
705 | /// Stop playback function | |
706 | /// </summary> | |
f9717bcc | 707 | StopFunction = 0x64, |
8438c41f LOK |
708 | /// <summary> |
709 | /// Mute audio function | |
710 | /// </summary> | |
f9717bcc | 711 | MuteFunction = 0x65, |
8438c41f LOK |
712 | /// <summary> |
713 | /// Restore volume function | |
714 | /// </summary> | |
f9717bcc | 715 | RestoreVolumeFunction = 0x66, |
8438c41f LOK |
716 | /// <summary> |
717 | /// Tune function | |
718 | /// </summary> | |
f9717bcc | 719 | TuneFunction = 0x67, |
8438c41f LOK |
720 | /// <summary> |
721 | /// Select media function | |
722 | /// </summary> | |
f9717bcc | 723 | SelectMediaFunction = 0x68, |
8438c41f LOK |
724 | /// <summary> |
725 | /// Select AV input function | |
726 | /// </summary> | |
f9717bcc | 727 | SelectAVInputFunction = 0x69, |
8438c41f LOK |
728 | /// <summary> |
729 | /// Select audio input function | |
730 | /// </summary> | |
f9717bcc | 731 | SelectAudioInputFunction = 0x6A, |
8438c41f LOK |
732 | /// <summary> |
733 | /// Toggle powered on / standby function | |
734 | /// </summary> | |
f9717bcc | 735 | PowerToggleFunction = 0x6B, |
8438c41f LOK |
736 | /// <summary> |
737 | /// Power off function | |
738 | /// </summary> | |
f9717bcc | 739 | PowerOffFunction = 0x6C, |
8438c41f LOK |
740 | /// <summary> |
741 | /// Power on function | |
742 | /// </summary> | |
f9717bcc | 743 | PowerOnFunction = 0x6D, |
8438c41f LOK |
744 | /// <summary> |
745 | /// F1 / blue button | |
746 | /// </summary> | |
f9717bcc | 747 | F1Blue = 0x71, |
8438c41f LOK |
748 | /// <summary> |
749 | /// F2 / red button | |
750 | /// </summary> | |
f9717bcc | 751 | F2Red = 0X72, |
8438c41f LOK |
752 | /// <summary> |
753 | /// F3 / green button | |
754 | /// </summary> | |
f9717bcc | 755 | F3Green = 0x73, |
8438c41f LOK |
756 | /// <summary> |
757 | /// F4 / yellow button | |
758 | /// </summary> | |
f9717bcc | 759 | F4Yellow = 0x74, |
8438c41f LOK |
760 | /// <summary> |
761 | /// F5 | |
762 | /// </summary> | |
f9717bcc | 763 | F5 = 0x75, |
8438c41f LOK |
764 | /// <summary> |
765 | /// Data / teletext | |
766 | /// </summary> | |
f9717bcc | 767 | Data = 0x76, |
8438c41f LOK |
768 | /// <summary> |
769 | /// Max. valid key code for standard buttons | |
770 | /// </summary> | |
f9717bcc | 771 | Max = 0x76, |
8438c41f LOK |
772 | /// <summary> |
773 | /// Extra return button on Samsung remotes | |
774 | /// </summary> | |
f9717bcc | 775 | SamsungReturn = 0x91, |
8438c41f LOK |
776 | /// <summary> |
777 | /// Unknown / invalid key code | |
778 | /// </summary> | |
f9717bcc LOK |
779 | Unknown |
780 | }; | |
781 | ||
8438c41f LOK |
782 | /// <summary> |
783 | /// Vendor IDs for CEC devices | |
784 | /// </summary> | |
f9717bcc LOK |
785 | public enum class CecVendorId |
786 | { | |
3b3b5fc1 LOK |
787 | Toshiba = 0x000039, |
788 | Samsung = 0x0000F0, | |
789 | Denon = 0x0005CD, | |
790 | Marantz = 0x000678, | |
791 | Loewe = 0x000982, | |
792 | Onkyo = 0x0009B0, | |
793 | Medion = 0x000CB8, | |
794 | Toshiba2 = 0x000CE7, | |
795 | Akai = 0x0020C7, | |
796 | AOC = 0x002467, | |
797 | Panasonic = 0x008045, | |
798 | Philips = 0x00903E, | |
799 | Daewoo = 0x009053, | |
800 | Yamaha = 0x00A0DE, | |
801 | Grundig = 0x00D0D5, | |
802 | Pioneer = 0x00E036, | |
803 | LG = 0x00E091, | |
804 | Sharp = 0x08001F, | |
805 | Sony = 0x080046, | |
806 | Broadcom = 0x18C086, | |
807 | Vizio = 0x6B746D, | |
808 | Benq = 0x8065E9, | |
ac03cf27 | 809 | HarmanKardon = 0x9C645E, |
3b3b5fc1 | 810 | Unknown = 0 |
f9717bcc LOK |
811 | }; |
812 | ||
8438c41f LOK |
813 | /// <summary> |
814 | /// Audio status of audio system / AVR devices | |
815 | /// </summary> | |
f9717bcc LOK |
816 | public enum class CecAudioStatus |
817 | { | |
8438c41f LOK |
818 | /// <summary> |
819 | /// Muted | |
820 | /// </summary> | |
f9717bcc | 821 | MuteStatusMask = 0x80, |
8438c41f LOK |
822 | /// <summary> |
823 | /// Not muted, volume status mask | |
824 | /// </summary> | |
f9717bcc | 825 | VolumeStatusMask = 0x7F, |
8438c41f LOK |
826 | /// <summary> |
827 | /// Minumum volume | |
828 | /// </summary> | |
f9717bcc | 829 | VolumeMin = 0x00, |
8438c41f LOK |
830 | /// <summary> |
831 | /// Maximum volume | |
832 | /// </summary> | |
f9717bcc | 833 | VolumeMax = 0x64, |
8438c41f LOK |
834 | /// <summary> |
835 | /// Unknown status | |
836 | /// </summary> | |
f9717bcc LOK |
837 | VolumeStatusUnknown = 0x7F |
838 | }; | |
839 | ||
8438c41f LOK |
840 | /// <summary> |
841 | /// CEC opcodes, as described in the HDMI CEC specification | |
842 | /// </summary> | |
f9717bcc LOK |
843 | public enum class CecOpcode |
844 | { | |
8438c41f LOK |
845 | /// <summary> |
846 | /// Active source | |
847 | /// </summary> | |
f9717bcc | 848 | ActiveSource = 0x82, |
8438c41f LOK |
849 | /// <summary> |
850 | /// Image view on: power on display for image display | |
851 | /// </summary> | |
f9717bcc | 852 | ImageViewOn = 0x04, |
8438c41f LOK |
853 | /// <summary> |
854 | /// Text view on: power on display for text display | |
855 | /// </summary> | |
f9717bcc | 856 | TextViewOn = 0x0D, |
8438c41f LOK |
857 | /// <summary> |
858 | /// Device no longer is the active source | |
859 | /// </summary> | |
f9717bcc | 860 | InactiveSource = 0x9D, |
8438c41f LOK |
861 | /// <summary> |
862 | /// Request which device has the active source status | |
863 | /// </summary> | |
f9717bcc | 864 | RequestActiveSource = 0x85, |
8438c41f LOK |
865 | /// <summary> |
866 | /// Routing change for HDMI switches | |
867 | /// </summary> | |
f9717bcc | 868 | RoutingChange = 0x80, |
8438c41f LOK |
869 | /// <summary> |
870 | /// Routing information for HDMI switches | |
871 | /// </summary> | |
f9717bcc | 872 | RoutingInformation = 0x81, |
8438c41f LOK |
873 | /// <summary> |
874 | /// Change the stream path to the given physical address | |
875 | /// </summary> | |
f9717bcc | 876 | SetStreamPath = 0x86, |
8438c41f LOK |
877 | /// <summary> |
878 | /// Inform that a device went into standby mode | |
879 | /// </summary> | |
f9717bcc | 880 | Standby = 0x36, |
8438c41f LOK |
881 | /// <summary> |
882 | /// Stop recording | |
883 | /// </summary> | |
f9717bcc | 884 | RecordOff = 0x0B, |
8438c41f LOK |
885 | /// <summary> |
886 | /// Start recording | |
887 | /// </summary> | |
f9717bcc | 888 | RecordOn = 0x09, |
8438c41f LOK |
889 | /// <summary> |
890 | /// Recording status information | |
891 | /// </summary> | |
f9717bcc | 892 | RecordStatus = 0x0A, |
8438c41f LOK |
893 | /// <summary> |
894 | /// Record current display | |
895 | /// </summary> | |
f9717bcc | 896 | RecordTvScreen = 0x0F, |
8438c41f LOK |
897 | /// <summary> |
898 | /// Clear analogue timer | |
899 | /// </summary> | |
f9717bcc | 900 | ClearAnalogueTimer = 0x33, |
8438c41f LOK |
901 | /// <summary> |
902 | /// Clear digital timer | |
903 | /// </summary> | |
f9717bcc | 904 | ClearDigitalTimer = 0x99, |
8438c41f LOK |
905 | /// <summary> |
906 | /// Clear external timer | |
907 | /// </summary> | |
f9717bcc | 908 | ClearExternalTimer = 0xA1, |
8438c41f LOK |
909 | /// <summary> |
910 | /// Set analogue timer | |
911 | /// </summary> | |
f9717bcc | 912 | SetAnalogueTimer = 0x34, |
8438c41f LOK |
913 | /// <summary> |
914 | /// Set digital timer | |
915 | /// </summary> | |
f9717bcc | 916 | SetDigitalTimer = 0x97, |
8438c41f LOK |
917 | /// <summary> |
918 | /// Set external timer | |
919 | /// </summary> | |
f9717bcc | 920 | SetExternalTimer = 0xA2, |
8438c41f LOK |
921 | /// <summary> |
922 | /// Set program title of a timer | |
923 | /// </summary> | |
f9717bcc | 924 | SetTimerProgramTitle = 0x67, |
8438c41f LOK |
925 | /// <summary> |
926 | /// Timer status cleared | |
927 | /// </summary> | |
f9717bcc | 928 | TimerClearedStatus = 0x43, |
8438c41f LOK |
929 | /// <summary> |
930 | /// Timer status information | |
931 | /// </summary> | |
f9717bcc | 932 | TimerStatus = 0x35, |
8438c41f LOK |
933 | /// <summary> |
934 | /// CEC version used by a device | |
935 | /// </summary> | |
f9717bcc | 936 | CecVersion = 0x9E, |
8438c41f LOK |
937 | /// <summary> |
938 | /// Request CEC version of a device | |
939 | /// </summary> | |
f9717bcc | 940 | GetCecVersion = 0x9F, |
8438c41f LOK |
941 | /// <summary> |
942 | /// Request physical address of a device | |
943 | /// </summary> | |
f9717bcc | 944 | GivePhysicalAddress = 0x83, |
8438c41f LOK |
945 | /// <summary> |
946 | /// Request language code of the menu language of a device | |
f81c0652 | 947 | /// 3 character ISO 639-2 country code. see http://http://www.loc.gov/standards/iso639-2/ |
8438c41f | 948 | /// </summary> |
f9717bcc | 949 | GetMenuLanguage = 0x91, |
8438c41f LOK |
950 | /// <summary> |
951 | /// Report the physical address | |
952 | /// </summary> | |
f9717bcc | 953 | ReportPhysicalAddress = 0x84, |
8438c41f LOK |
954 | /// <summary> |
955 | /// Report the language code of the menu language | |
f81c0652 | 956 | /// 3 character ISO 639-2 country code. see http://http://www.loc.gov/standards/iso639-2/ |
8438c41f | 957 | /// </summary> |
f9717bcc | 958 | SetMenuLanguage = 0x32, |
8438c41f LOK |
959 | /// <summary> |
960 | /// Deck control for playback and recording devices | |
961 | /// </summary> | |
f9717bcc | 962 | DeckControl = 0x42, |
8438c41f LOK |
963 | /// <summary> |
964 | /// Deck status for playback and recording devices | |
965 | /// </summary> | |
f9717bcc | 966 | DeckStatus = 0x1B, |
8438c41f LOK |
967 | /// <summary> |
968 | /// Request deck status from playback and recording devices | |
969 | /// </summary> | |
f9717bcc | 970 | GiveDeckStatus = 0x1A, |
8438c41f LOK |
971 | /// <summary> |
972 | /// Start playback on playback and recording devices | |
973 | /// </summary> | |
f9717bcc | 974 | Play = 0x41, |
8438c41f LOK |
975 | /// <summary> |
976 | /// Request tuner status | |
977 | /// </summary> | |
f9717bcc | 978 | GiveTunerDeviceStatus = 0x08, |
8438c41f LOK |
979 | /// <summary> |
980 | /// Select analogue service on a tuner | |
981 | /// </summary> | |
f9717bcc | 982 | SelectAnalogueService = 0x92, |
8438c41f LOK |
983 | /// <summary> |
984 | /// Select digital service on a tuner | |
985 | /// </summary> | |
f9717bcc | 986 | SelectDigtalService = 0x93, |
8438c41f LOK |
987 | /// <summary> |
988 | /// Report tuner device status | |
989 | /// </summary> | |
f9717bcc | 990 | TunerDeviceStatus = 0x07, |
8438c41f LOK |
991 | /// <summary> |
992 | /// Tuner step decrement | |
993 | /// </summary> | |
f9717bcc | 994 | TunerStepDecrement = 0x06, |
8438c41f LOK |
995 | /// <summary> |
996 | /// Tuner step increment | |
997 | /// </summary> | |
f9717bcc | 998 | TunerStepIncrement = 0x05, |
8438c41f LOK |
999 | /// <summary> |
1000 | /// Report device vendor ID | |
1001 | /// </summary> | |
f9717bcc | 1002 | DeviceVendorId = 0x87, |
8438c41f LOK |
1003 | /// <summary> |
1004 | /// Request device vendor ID | |
1005 | /// </summary> | |
f9717bcc | 1006 | GiveDeviceVendorId = 0x8C, |
8438c41f LOK |
1007 | /// <summary> |
1008 | /// Vendor specific command | |
1009 | /// </summary> | |
f9717bcc | 1010 | VendorCommand = 0x89, |
8438c41f LOK |
1011 | /// <summary> |
1012 | /// Vendor specific command with vendor ID | |
1013 | /// </summary> | |
f9717bcc | 1014 | VendorCommandWithId = 0xA0, |
8438c41f LOK |
1015 | /// <summary> |
1016 | /// Vendor specific remote button pressed | |
1017 | /// </summary> | |
f9717bcc | 1018 | VendorRemoteButtonDown = 0x8A, |
8438c41f LOK |
1019 | /// <summary> |
1020 | /// Vendor specific remote button released | |
1021 | /// </summary> | |
f9717bcc | 1022 | VendorRemoteButtonUp = 0x8B, |
8438c41f LOK |
1023 | /// <summary> |
1024 | /// Display / clear OSD string | |
1025 | /// </summary> | |
f9717bcc | 1026 | SetOsdString = 0x64, |
8438c41f LOK |
1027 | /// <summary> |
1028 | /// Request device OSD name | |
1029 | /// </summary> | |
f9717bcc | 1030 | GiveOsdName = 0x46, |
8438c41f LOK |
1031 | /// <summary> |
1032 | /// Report device OSD name | |
1033 | /// </summary> | |
f9717bcc | 1034 | SetOsdName = 0x47, |
8438c41f LOK |
1035 | /// <summary> |
1036 | /// Request device menu status | |
1037 | /// </summary> | |
f9717bcc | 1038 | MenuRequest = 0x8D, |
8438c41f LOK |
1039 | /// <summary> |
1040 | /// Report device menu status | |
1041 | /// </summary> | |
f9717bcc | 1042 | MenuStatus = 0x8E, |
8438c41f LOK |
1043 | /// <summary> |
1044 | /// Remote button pressed | |
1045 | /// </summary> | |
f9717bcc | 1046 | UserControlPressed = 0x44, |
8438c41f LOK |
1047 | /// <summary> |
1048 | /// Remote button released | |
1049 | /// </summary> | |
f9717bcc | 1050 | UserControlRelease = 0x45, |
8438c41f LOK |
1051 | /// <summary> |
1052 | /// Request device power status | |
1053 | /// </summary> | |
f9717bcc | 1054 | GiveDevicePowerStatus = 0x8F, |
8438c41f LOK |
1055 | /// <summary> |
1056 | /// Report device power status | |
1057 | /// </summary> | |
f9717bcc | 1058 | ReportPowerStatus = 0x90, |
8438c41f LOK |
1059 | /// <summary> |
1060 | /// Feature abort / unsupported command | |
1061 | /// </summary> | |
f9717bcc | 1062 | FeatureAbort = 0x00, |
8438c41f LOK |
1063 | /// <summary> |
1064 | /// Abort command | |
1065 | /// </summary> | |
f9717bcc | 1066 | Abort = 0xFF, |
8438c41f LOK |
1067 | /// <summary> |
1068 | /// Give audio status | |
1069 | /// </summary> | |
f9717bcc | 1070 | GiveAudioStatus = 0x71, |
8438c41f LOK |
1071 | /// <summary> |
1072 | /// Give audiosystem mode | |
1073 | /// </summary> | |
f9717bcc | 1074 | GiveSystemAudioMode = 0x7D, |
8438c41f LOK |
1075 | /// <summary> |
1076 | /// Report device audio status | |
1077 | /// </summary> | |
f9717bcc | 1078 | ReportAudioStatus = 0x7A, |
8438c41f LOK |
1079 | /// <summary> |
1080 | /// Set audiosystem mode | |
1081 | /// </summary> | |
f9717bcc | 1082 | SetSystemAudioMode = 0x72, |
8438c41f LOK |
1083 | /// <summary> |
1084 | /// Request audiosystem mode | |
1085 | /// </summary> | |
f9717bcc | 1086 | SystemAudioModeRequest = 0x70, |
8438c41f LOK |
1087 | /// <summary> |
1088 | /// Report audiosystem mode | |
1089 | /// </summary> | |
f9717bcc | 1090 | SystemAudioModeStatus = 0x7E, |
8438c41f LOK |
1091 | /// <summary> |
1092 | /// Set audio bitrate | |
1093 | /// </summary> | |
f9717bcc | 1094 | SetAudioRate = 0x9A, |
8438c41f LOK |
1095 | /// <summary> |
1096 | /// When this opcode is set, no opcode will be sent to the device / poll message | |
1097 | /// This is one of the reserved numbers | |
1098 | /// </summary> | |
f9717bcc LOK |
1099 | None = 0xFD |
1100 | }; | |
1101 | ||
8438c41f LOK |
1102 | /// <summary> |
1103 | /// Audiosystem status | |
1104 | /// </summary> | |
f9717bcc LOK |
1105 | public enum class CecSystemAudioStatus |
1106 | { | |
8438c41f LOK |
1107 | /// <summary> |
1108 | /// Turned off | |
1109 | /// </summary> | |
f9717bcc | 1110 | Off = 0, |
8438c41f LOK |
1111 | /// <summary> |
1112 | /// Turned on | |
1113 | /// </summary> | |
f9717bcc LOK |
1114 | On = 1 |
1115 | }; | |
1116 | ||
8438c41f LOK |
1117 | /// <summary> |
1118 | /// libCEC client application version | |
1119 | /// </summary> | |
f9717bcc LOK |
1120 | public enum class CecClientVersion |
1121 | { | |
8438c41f LOK |
1122 | /// <summary> |
1123 | /// before v1.5.0 | |
1124 | /// </summary> | |
f9717bcc | 1125 | VersionPre1_5 = 0, |
8438c41f LOK |
1126 | /// <summary> |
1127 | /// v1.5.0 | |
1128 | /// </summary> | |
f9717bcc | 1129 | Version1_5_0 = 0x1500, |
8438c41f LOK |
1130 | /// <summary> |
1131 | /// v1.5.1 | |
1132 | /// </summary> | |
f9717bcc | 1133 | Version1_5_1 = 0x1501, |
8438c41f LOK |
1134 | /// <summary> |
1135 | /// v1.5.2 | |
1136 | /// </summary> | |
f9717bcc | 1137 | Version1_5_2 = 0x1502, |
8438c41f LOK |
1138 | /// <summary> |
1139 | /// v1.5.3 | |
1140 | /// </summary> | |
f9717bcc | 1141 | Version1_5_3 = 0x1503, |
8438c41f LOK |
1142 | /// <summary> |
1143 | /// v1.6.0 | |
1144 | /// </summary> | |
f9717bcc | 1145 | Version1_6_0 = 0x1600, |
8438c41f LOK |
1146 | /// <summary> |
1147 | /// v1.6.1 | |
1148 | /// </summary> | |
f9717bcc | 1149 | Version1_6_1 = 0x1601, |
8438c41f LOK |
1150 | /// <summary> |
1151 | /// v1.6.2 | |
1152 | /// </summary> | |
f9717bcc | 1153 | Version1_6_2 = 0x1602, |
8438c41f LOK |
1154 | /// <summary> |
1155 | /// v1.6.3 | |
1156 | /// </summary> | |
f9717bcc | 1157 | Version1_6_3 = 0x1603, |
8438c41f LOK |
1158 | /// <summary> |
1159 | /// v1.7.0 | |
1160 | /// </summary> | |
f9717bcc | 1161 | Version1_7_0 = 0x1700, |
8438c41f LOK |
1162 | /// <summary> |
1163 | /// v1.7.1 | |
1164 | /// </summary> | |
f9717bcc | 1165 | Version1_7_1 = 0x1701, |
8438c41f LOK |
1166 | /// <summary> |
1167 | /// v1.7.2 | |
1168 | /// </summary> | |
f9717bcc | 1169 | Version1_7_2 = 0x1702, |
8438c41f LOK |
1170 | /// <summary> |
1171 | /// v1.8.0 | |
1172 | /// </summary> | |
f9717bcc | 1173 | Version1_8_0 = 0x1800, |
8438c41f LOK |
1174 | /// <summary> |
1175 | /// v1.8.1 | |
1176 | /// </summary> | |
f9717bcc | 1177 | Version1_8_1 = 0x1801, |
8438c41f LOK |
1178 | /// <summary> |
1179 | /// v1.8.2 | |
1180 | /// </summary> | |
f9717bcc | 1181 | Version1_8_2 = 0x1802, |
8438c41f LOK |
1182 | /// <summary> |
1183 | /// v1.9.0 | |
1184 | /// </summary> | |
f81c0652 LOK |
1185 | Version1_9_0 = 0x1900, |
1186 | /// <summary> | |
1187 | /// v2.0.0-pre | |
1188 | /// </summary> | |
999665e3 LOK |
1189 | Version1_99_0 = 0x1990, |
1190 | /// <summary> | |
1191 | /// v2.0.0 | |
1192 | /// </summary> | |
20fd14a9 LOK |
1193 | Version2_0_0 = 0x2000, |
1194 | /// <summary> | |
1195 | /// v2.0.1 | |
1196 | /// </summary> | |
784a6a79 LOK |
1197 | Version2_0_1 = 0x2001, |
1198 | /// <summary> | |
1199 | /// v2.0.2 | |
1200 | /// </summary> | |
83715833 LOK |
1201 | Version2_0_2 = 0x2002, |
1202 | /// <summary> | |
1203 | /// v2.0.3 | |
1204 | /// </summary> | |
0c271bd0 LOK |
1205 | Version2_0_3 = 0x2003, |
1206 | /// <summary> | |
1207 | /// v2.0.4 | |
1208 | /// </summary> | |
6fb1aefd LOK |
1209 | Version2_0_4 = 0x2004, |
1210 | /// <summary> | |
1211 | /// v2.0.5 | |
1212 | /// </summary> | |
9b56a19a LOK |
1213 | Version2_0_5 = 0x2005, |
1214 | /// <summary> | |
1215 | /// v2.1.0 | |
1216 | /// </summary> | |
331d659e LOK |
1217 | Version2_1_0 = 0x2100, |
1218 | /// <summary> | |
1219 | /// v2.1.1 | |
1220 | /// </summary> | |
f6db051e LOK |
1221 | Version2_1_1 = 0x2101, |
1222 | /// <summary> | |
b53bfc2d LOK |
1223 | /// v2.1.2 |
1224 | /// </summary> | |
1225 | Version2_1_2 = 0x2102, | |
1226 | /// <summary> | |
1227 | /// v2.1.3 | |
1228 | /// </summary> | |
1229 | Version2_1_3 = 0x2103, | |
1230 | /// <summary> | |
f6db051e LOK |
1231 | /// The current version |
1232 | /// </summary> | |
b53bfc2d | 1233 | CurrentVersion = 0x2103 |
f9717bcc LOK |
1234 | }; |
1235 | ||
8438c41f LOK |
1236 | /// <summary> |
1237 | /// libCEC version | |
1238 | /// </summary> | |
f9717bcc LOK |
1239 | public enum class CecServerVersion |
1240 | { | |
8438c41f LOK |
1241 | /// <summary> |
1242 | /// before v1.5.0 | |
1243 | /// </summary> | |
f9717bcc | 1244 | VersionPre1_5 = 0, |
8438c41f LOK |
1245 | /// <summary> |
1246 | /// v1.5.0 | |
1247 | /// </summary> | |
f9717bcc | 1248 | Version1_5_0 = 0x1500, |
8438c41f LOK |
1249 | /// <summary> |
1250 | /// v1.5.1 | |
1251 | /// </summary> | |
f9717bcc | 1252 | Version1_5_1 = 0x1501, |
8438c41f LOK |
1253 | /// <summary> |
1254 | /// v1.5.2 | |
1255 | /// </summary> | |
f9717bcc | 1256 | Version1_5_2 = 0x1502, |
8438c41f LOK |
1257 | /// <summary> |
1258 | /// v1.5.3 | |
1259 | /// </summary> | |
f9717bcc | 1260 | Version1_5_3 = 0x1503, |
8438c41f LOK |
1261 | /// <summary> |
1262 | /// v1.6.0 | |
1263 | /// </summary> | |
f9717bcc | 1264 | Version1_6_0 = 0x1600, |
8438c41f LOK |
1265 | /// <summary> |
1266 | /// v1.6.1 | |
1267 | /// </summary> | |
f9717bcc | 1268 | Version1_6_1 = 0x1601, |
8438c41f LOK |
1269 | /// <summary> |
1270 | /// v1.6.2 | |
1271 | /// </summary> | |
f9717bcc | 1272 | Version1_6_2 = 0x1602, |
8438c41f LOK |
1273 | /// <summary> |
1274 | /// v1.6.3 | |
1275 | /// </summary> | |
f9717bcc | 1276 | Version1_6_3 = 0x1603, |
8438c41f LOK |
1277 | /// <summary> |
1278 | /// v1.7.0 | |
1279 | /// </summary> | |
f9717bcc | 1280 | Version1_7_0 = 0x1700, |
8438c41f LOK |
1281 | /// <summary> |
1282 | /// v1.7.1 | |
1283 | /// </summary> | |
f9717bcc | 1284 | Version1_7_1 = 0x1701, |
8438c41f LOK |
1285 | /// <summary> |
1286 | /// v1.7.2 | |
1287 | /// </summary> | |
f9717bcc | 1288 | Version1_7_2 = 0x1702, |
8438c41f LOK |
1289 | /// <summary> |
1290 | /// v1.8.0 | |
1291 | /// </summary> | |
f9717bcc | 1292 | Version1_8_0 = 0x1800, |
8438c41f LOK |
1293 | /// <summary> |
1294 | /// v1.8.1 | |
1295 | /// </summary> | |
f9717bcc | 1296 | Version1_8_1 = 0x1801, |
8438c41f LOK |
1297 | /// <summary> |
1298 | /// v1.8.2 | |
1299 | /// </summary> | |
f9717bcc | 1300 | Version1_8_2 = 0x1802, |
8438c41f LOK |
1301 | /// <summary> |
1302 | /// v1.9.0 | |
1303 | /// </summary> | |
f81c0652 LOK |
1304 | Version1_9_0 = 0x1900, |
1305 | /// <summary> | |
1306 | /// v2.0.0-pre | |
1307 | /// </summary> | |
999665e3 LOK |
1308 | Version1_99_0 = 0x1990, |
1309 | /// <summary> | |
1310 | /// v2.0.0 | |
1311 | /// </summary> | |
20fd14a9 LOK |
1312 | Version2_0_0 = 0x2000, |
1313 | /// <summary> | |
1314 | /// v2.0.1 | |
1315 | /// </summary> | |
784a6a79 LOK |
1316 | Version2_0_1 = 0x2001, |
1317 | /// <summary> | |
1318 | /// v2.0.2 | |
1319 | /// </summary> | |
83715833 LOK |
1320 | Version2_0_2 = 0x2002, |
1321 | /// <summary> | |
1322 | /// v2.0.3 | |
1323 | /// </summary> | |
0c271bd0 LOK |
1324 | Version2_0_3 = 0x2003, |
1325 | /// <summary> | |
1326 | /// v2.0.4 | |
1327 | /// </summary> | |
6fb1aefd LOK |
1328 | Version2_0_4 = 0x2004, |
1329 | /// <summary> | |
1330 | /// v2.0.5 | |
1331 | /// </summary> | |
9b56a19a LOK |
1332 | Version2_0_5 = 0x2005, |
1333 | /// <summary> | |
1334 | /// v2.1.0 | |
1335 | /// </summary> | |
331d659e LOK |
1336 | Version2_1_0 = 0x2100, |
1337 | /// <summary> | |
1338 | /// v2.1.1 | |
1339 | /// </summary> | |
f6db051e LOK |
1340 | Version2_1_1 = 0x2101, |
1341 | /// <summary> | |
b53bfc2d LOK |
1342 | /// v2.1.2 |
1343 | /// </summary> | |
1344 | Version2_1_2 = 0x2102, | |
1345 | /// <summary> | |
1346 | /// v2.1.3 | |
1347 | /// </summary> | |
1348 | Version2_1_3 = 0x2103, | |
1349 | /// <summary> | |
f6db051e LOK |
1350 | /// The current version |
1351 | /// </summary> | |
b53bfc2d | 1352 | CurrentVersion = 0x2103 |
f9717bcc LOK |
1353 | }; |
1354 | ||
8438c41f LOK |
1355 | /// <summary> |
1356 | /// Type of adapter to which libCEC is connected | |
1357 | /// </summary> | |
22190f06 LOK |
1358 | public enum class CecAdapterType |
1359 | { | |
8438c41f LOK |
1360 | /// <summary> |
1361 | /// Unknown adapter type | |
1362 | /// </summary> | |
22190f06 | 1363 | Unknown = 0, |
8438c41f LOK |
1364 | /// <summary> |
1365 | /// Pulse-Eight USB-CEC adapter | |
1366 | /// </summary> | |
22190f06 | 1367 | PulseEightExternal = 0x1, |
8438c41f LOK |
1368 | /// <summary> |
1369 | /// Pulse-Eight CEC daughterboard | |
1370 | /// </summary> | |
22190f06 | 1371 | PulseEightDaughterboard = 0x2, |
8438c41f LOK |
1372 | /// <summary> |
1373 | /// Raspberry Pi | |
1374 | /// </summary> | |
9b56a19a LOK |
1375 | RaspberryPi = 0x100, |
1376 | /// <summary> | |
1377 | /// TDA995x | |
1378 | /// </summary> | |
1379 | TDA995x = 0x200 | |
22190f06 LOK |
1380 | }; |
1381 | ||
f9717bcc | 1382 | /// <summary> |
8438c41f | 1383 | /// Descriptor of a CEC adapter, returned when scanning for adapters that are connected to the system |
f9717bcc LOK |
1384 | /// </summary> |
1385 | public ref class CecAdapter | |
1386 | { | |
1387 | public: | |
1388 | /// <summary> | |
1389 | /// Create a new CEC adapter descriptor | |
1390 | /// </summary> | |
1391 | /// <param name="path"> The path descriptor for this CEC adapter</param> | |
1392 | /// <param name="comPort">The COM port of this CEC adapter</param> | |
1393 | CecAdapter(System::String ^ path, System::String ^ comPort) | |
1394 | { | |
1395 | Path = path; | |
1396 | ComPort = comPort; | |
1397 | } | |
1398 | ||
1399 | /// <summary> | |
1400 | /// The path descriptor for this CEC adapter | |
1401 | /// </summary> | |
1402 | property System::String ^ Path; | |
1403 | ||
1404 | /// <summary> | |
1405 | /// The COM port of this CEC adapter | |
1406 | /// </summary> | |
1407 | property System::String ^ ComPort; | |
1408 | }; | |
1409 | ||
1410 | /// <summary> | |
1411 | /// A list of CEC device types | |
1412 | /// </summary> | |
1413 | public ref class CecDeviceTypeList | |
1414 | { | |
1415 | public: | |
1416 | /// <summary> | |
1417 | /// Create a new empty list of CEC device types | |
1418 | /// </summary> | |
1419 | CecDeviceTypeList(void) | |
1420 | { | |
1421 | Types = gcnew array<CecDeviceType>(5); | |
1422 | for (unsigned int iPtr = 0; iPtr < 5; iPtr++) | |
1423 | Types[iPtr] = CecDeviceType::Reserved; | |
1424 | } | |
1425 | ||
1426 | /// <summary> | |
1427 | /// The array with CecDeviceType instances in this list. | |
1428 | /// </summary> | |
1429 | property array<CecDeviceType> ^ Types; | |
1430 | }; | |
1431 | ||
1432 | /// <summary> | |
1433 | /// A list of logical addresses | |
1434 | /// </summary> | |
1435 | public ref class CecLogicalAddresses | |
1436 | { | |
1437 | public: | |
1438 | /// <summary> | |
1439 | /// Create a new empty list of logical addresses | |
1440 | /// </summary> | |
1441 | CecLogicalAddresses(void) | |
1442 | { | |
1443 | Addresses = gcnew array<CecLogicalAddress>(16); | |
1444 | Clear(); | |
1445 | } | |
1446 | ||
1447 | /// <summary> | |
1448 | /// Clears this list | |
1449 | /// </summary> | |
1450 | void Clear(void) | |
1451 | { | |
1452 | Primary = CecLogicalAddress::Unknown; | |
1453 | for (unsigned int iPtr = 0; iPtr < 16; iPtr++) | |
1454 | Addresses[iPtr] = CecLogicalAddress::Unknown; | |
1455 | } | |
1456 | ||
1457 | /// <summary> | |
1458 | /// Checks whether a logical address is set in this list. | |
1459 | /// </summary> | |
1460 | /// <param name="address">The address to check.</param> | |
1461 | /// <returns>True when set, false otherwise</returns> | |
1462 | bool IsSet(CecLogicalAddress address) | |
1463 | { | |
1464 | return Addresses[(unsigned int)address] != CecLogicalAddress::Unknown; | |
1465 | } | |
1466 | ||
1467 | /// <summary> | |
1468 | /// Add a logical address to this list (if it's not set already) | |
1469 | /// </summary> | |
1470 | /// <param name="address">The address to add.</param> | |
1471 | void Set(CecLogicalAddress address) | |
1472 | { | |
1473 | Addresses[(unsigned int)address] = address; | |
1474 | if (Primary == CecLogicalAddress::Unknown) | |
1475 | Primary = address; | |
1476 | } | |
1477 | ||
1478 | /// <summary> | |
1479 | /// The primary (first) address in this list | |
1480 | /// </summary> | |
1481 | property CecLogicalAddress Primary; | |
1482 | ||
1483 | /// <summary> | |
1484 | /// The list of addresses | |
1485 | /// </summary> | |
1486 | property array<CecLogicalAddress> ^ Addresses; | |
1487 | }; | |
1488 | ||
1489 | ||
1490 | /// <summary> | |
1491 | /// Byte array used for CEC command parameters | |
1492 | /// </summary> | |
1493 | public ref class CecDatapacket | |
1494 | { | |
1495 | public: | |
1496 | /// <summary> | |
1497 | /// Create a new byte array with maximum size 100 | |
1498 | /// </summary> | |
1499 | CecDatapacket(void) | |
1500 | { | |
1501 | Data = gcnew array<uint8_t>(100); | |
1502 | Size = 0; | |
1503 | } | |
1504 | ||
1505 | /// <summary> | |
1506 | /// Adds a byte to this byte array | |
1507 | /// </summary> | |
1508 | /// <param name="data">The byte to add.</param> | |
1509 | void PushBack(uint8_t data) | |
1510 | { | |
1511 | if (Size < 100) | |
1512 | { | |
1513 | Data[Size] = data; | |
1514 | Size++; | |
1515 | } | |
1516 | } | |
1517 | ||
1518 | /// <summary> | |
1519 | /// Array data | |
1520 | /// </summary> | |
1521 | property array<uint8_t> ^ Data; | |
1522 | ||
1523 | /// <summary> | |
1524 | /// Current data size | |
1525 | /// </summary> | |
1526 | property uint8_t Size; | |
1527 | }; | |
1528 | ||
1529 | /// <summary> | |
1530 | /// A CEC command that is received or transmitted over the CEC bus | |
1531 | /// </summary> | |
1532 | public ref class CecCommand | |
1533 | { | |
1534 | public: | |
1535 | /// <summary> | |
1536 | /// Create a new CEC command instance | |
1537 | /// </summary> | |
1538 | /// <param name="initiator">The initiator of the command</param> | |
1539 | /// <param name="destination">The receiver of the command</param> | |
1540 | /// <param name="ack">True when the ack bit is set, false otherwise</param> | |
1541 | /// <param name="eom">True when the eom bit is set, false otherwise</param> | |
1542 | /// <param name="opcode">The CEC opcode of this command</param> | |
1543 | /// <param name="transmitTimeout">The timeout to use when transmitting a command</param> | |
1544 | CecCommand(CecLogicalAddress initiator, CecLogicalAddress destination, bool ack, bool eom, CecOpcode opcode, int32_t transmitTimeout) | |
1545 | { | |
1546 | Initiator = initiator; | |
1547 | Destination = destination; | |
1548 | Ack = ack; | |
1549 | Eom = eom; | |
1550 | Opcode = opcode; | |
1551 | OpcodeSet = true; | |
1552 | TransmitTimeout = transmitTimeout; | |
1553 | Parameters = gcnew CecDatapacket; | |
1554 | Empty = false; | |
1555 | } | |
1556 | ||
1557 | /// <summary> | |
1558 | /// Create a new empty CEC command instance | |
1559 | /// </summary> | |
1560 | CecCommand(void) | |
1561 | { | |
1562 | Initiator = CecLogicalAddress::Unknown; | |
1563 | Destination = CecLogicalAddress::Unknown; | |
1564 | Ack = false; | |
1565 | Eom = false; | |
1566 | Opcode = CecOpcode::None; | |
1567 | OpcodeSet = false; | |
1568 | TransmitTimeout = 0; | |
1569 | Parameters = gcnew CecDatapacket; | |
1570 | Empty = true; | |
1571 | } | |
1572 | ||
1573 | /// <summary> | |
1574 | /// Pushes a byte of data to this CEC command | |
1575 | /// </summary> | |
1576 | /// <param name="data">The byte to add</param> | |
1577 | void PushBack(uint8_t data) | |
1578 | { | |
1579 | if (Initiator == CecLogicalAddress::Unknown && Destination == CecLogicalAddress::Unknown) | |
1580 | { | |
1581 | Initiator = (CecLogicalAddress) (data >> 4); | |
1582 | Destination = (CecLogicalAddress) (data & 0xF); | |
1583 | } | |
1584 | else if (!OpcodeSet) | |
1585 | { | |
1586 | OpcodeSet = true; | |
1587 | Opcode = (CecOpcode)data; | |
1588 | } | |
1589 | else | |
1590 | { | |
1591 | Parameters->PushBack(data); | |
1592 | } | |
1593 | } | |
1594 | ||
1595 | /// <summary> | |
1596 | /// True when this command is empty, false otherwise. | |
1597 | /// </summary> | |
1598 | property bool Empty; | |
1599 | /// <summary> | |
1600 | /// The initiator of the command | |
1601 | /// </summary> | |
1602 | property CecLogicalAddress Initiator; | |
1603 | /// <summary> | |
1604 | /// The destination of the command | |
1605 | /// </summary> | |
1606 | property CecLogicalAddress Destination; | |
1607 | /// <summary> | |
1608 | /// True when the ack bit is set, false otherwise | |
1609 | /// </summary> | |
1610 | property bool Ack; | |
1611 | /// <summary> | |
1612 | /// True when the eom bit is set, false otherwise | |
1613 | /// </summary> | |
1614 | property bool Eom; | |
1615 | /// <summary> | |
1616 | /// The CEC opcode of the command | |
1617 | /// </summary> | |
1618 | property CecOpcode Opcode; | |
1619 | /// <summary> | |
1620 | /// The parameters of this command | |
1621 | /// </summary> | |
1622 | property CecDatapacket ^ Parameters; | |
1623 | /// <summary> | |
1624 | /// True when an opcode is set, false otherwise (poll message) | |
1625 | /// </summary> | |
1626 | property bool OpcodeSet; | |
1627 | /// <summary> | |
1628 | /// The timeout to use when transmitting a command | |
1629 | /// </summary> | |
1630 | property int32_t TransmitTimeout; | |
1631 | }; | |
1632 | ||
1633 | /// <summary> | |
1634 | /// A key press that was received | |
1635 | /// </summary> | |
1636 | public ref class CecKeypress | |
1637 | { | |
1638 | public: | |
1639 | /// <summary> | |
1640 | /// Create a new key press instance | |
1641 | /// </summary> | |
1642 | /// <param name="keycode">The key code of this key press</param> | |
1643 | /// <param name="duration">The duration of this key press in milliseconds</param> | |
1644 | CecKeypress(CecUserControlCode keycode, unsigned int duration) | |
1645 | { | |
1646 | Keycode = keycode; | |
1647 | Duration = duration; | |
1648 | Empty = false; | |
1649 | } | |
1650 | ||
1651 | /// <summary> | |
1652 | /// Create a new empty key press instance | |
1653 | /// </summary> | |
1654 | CecKeypress(void) | |
1655 | { | |
1656 | Keycode = CecUserControlCode::Unknown; | |
1657 | Duration = 0; | |
1658 | Empty = true; | |
1659 | } | |
1660 | ||
1661 | /// <summary> | |
1662 | /// True when empty, false otherwise | |
1663 | /// </summary> | |
1664 | property bool Empty; | |
1665 | /// <summary> | |
1666 | /// The key code of this key press | |
1667 | /// </summary> | |
1668 | property CecUserControlCode Keycode; | |
1669 | /// <summary> | |
1670 | /// The duration of this key press in milliseconds | |
1671 | /// </summary> | |
1672 | property unsigned int Duration; | |
1673 | }; | |
1674 | ||
1675 | /// <summary> | |
1676 | /// A log message that libCEC generated | |
1677 | /// </summary> | |
1678 | public ref class CecLogMessage | |
1679 | { | |
1680 | public: | |
1681 | /// <summary> | |
1682 | /// Create a new log message | |
1683 | /// </summary> | |
1684 | /// <param name="message">The actual message</param> | |
1685 | /// <param name="level">The log level, so the application can choose what type information to display</param> | |
1686 | /// <param name="time">The timestamp of this message, in milliseconds after connecting</param> | |
1687 | CecLogMessage(System::String ^ message, CecLogLevel level, int64_t time) | |
1688 | { | |
1689 | Message = message; | |
1690 | Level = level; | |
1691 | Time = time; | |
1692 | Empty = false; | |
1693 | } | |
1694 | ||
1695 | /// <summary> | |
1696 | /// Create a new empty log message | |
1697 | /// </summary> | |
1698 | CecLogMessage(void) | |
1699 | { | |
1700 | Message = ""; | |
1701 | Level = CecLogLevel::None; | |
1702 | Time = 0; | |
1703 | Empty = true; | |
1704 | } | |
1705 | ||
1706 | /// <summary> | |
1707 | /// True when empty, false otherwise. | |
1708 | /// </summary> | |
1709 | property bool Empty; | |
1710 | /// <summary> | |
1711 | /// The actual message | |
1712 | /// </summary> | |
1713 | property System::String ^Message; | |
1714 | /// <summary> | |
1715 | /// The log level, so the application can choose what type information to display | |
1716 | /// </summary> | |
1717 | property CecLogLevel Level; | |
1718 | /// <summary> | |
1719 | /// The timestamp of this message, in milliseconds after connecting | |
1720 | /// </summary> | |
1721 | property int64_t Time; | |
1722 | }; | |
1723 | ||
1724 | ref class CecCallbackMethods; //forward declaration | |
1725 | ||
1726 | /// <summary> | |
1727 | /// The configuration that libCEC uses. | |
1728 | /// </summary> | |
1729 | public ref class LibCECConfiguration | |
1730 | { | |
1731 | public: | |
1732 | /// <summary> | |
1733 | /// Create a new configuration instance with default settings. | |
1734 | /// </summary> | |
1735 | LibCECConfiguration(void) | |
1736 | { | |
1737 | DeviceName = ""; | |
1738 | DeviceTypes = gcnew CecDeviceTypeList(); | |
1739 | AutodetectAddress = true; | |
1740 | PhysicalAddress = CEC_DEFAULT_PHYSICAL_ADDRESS; | |
1741 | BaseDevice = (CecLogicalAddress)CEC_DEFAULT_BASE_DEVICE; | |
1742 | HDMIPort = CEC_DEFAULT_HDMI_PORT; | |
b53bfc2d LOK |
1743 | ClientVersion = CecClientVersion::CurrentVersion; |
1744 | ServerVersion = CecServerVersion::CurrentVersion; | |
f9717bcc LOK |
1745 | TvVendor = CecVendorId::Unknown; |
1746 | ||
1747 | GetSettingsFromROM = false; | |
1748 | UseTVMenuLanguage = CEC_DEFAULT_SETTING_USE_TV_MENU_LANGUAGE == 1; | |
1749 | ActivateSource = CEC_DEFAULT_SETTING_ACTIVATE_SOURCE == 1; | |
1750 | ||
1751 | WakeDevices = gcnew CecLogicalAddresses(); | |
1752 | if (CEC_DEFAULT_SETTING_ACTIVATE_SOURCE == 1) | |
1753 | WakeDevices->Set(CecLogicalAddress::Tv); | |
1754 | ||
1755 | PowerOffDevices = gcnew CecLogicalAddresses(); | |
1756 | if (CEC_DEFAULT_SETTING_POWER_OFF_SHUTDOWN == 1) | |
1757 | PowerOffDevices->Set(CecLogicalAddress::Broadcast); | |
1758 | ||
1759 | PowerOffScreensaver = CEC_DEFAULT_SETTING_POWER_OFF_SCREENSAVER == 1; | |
1760 | PowerOffOnStandby = CEC_DEFAULT_SETTING_POWER_OFF_ON_STANDBY == 1; | |
1761 | ||
1762 | SendInactiveSource = CEC_DEFAULT_SETTING_SEND_INACTIVE_SOURCE == 1; | |
1763 | LogicalAddresses = gcnew CecLogicalAddresses(); | |
1764 | FirmwareVersion = 1; | |
1765 | PowerOffDevicesOnStandby = CEC_DEFAULT_SETTING_POWER_OFF_DEVICES_STANDBY == 1; | |
1766 | ShutdownOnStandby = CEC_DEFAULT_SETTING_SHUTDOWN_ON_STANDBY == 1; | |
1767 | DeviceLanguage = ""; | |
22190f06 LOK |
1768 | FirmwareBuildDate = gcnew System::DateTime(1970,1,1,0,0,0,0); |
1769 | CECVersion = (CecVersion)CEC_DEFAULT_SETTING_CEC_VERSION; | |
1770 | AdapterType = CecAdapterType::Unknown; | |
f9717bcc LOK |
1771 | } |
1772 | ||
1773 | /// <summary> | |
1774 | /// Change the callback method pointers in this configuration instance. | |
1775 | /// </summary> | |
1776 | /// <param name="callbacks">The new callbacks</param> | |
1777 | void SetCallbacks(CecCallbackMethods ^callbacks) | |
1778 | { | |
1779 | Callbacks = callbacks; | |
1780 | } | |
1781 | ||
1782 | /// <summary> | |
1783 | /// Update this configuration with data received from libCEC | |
1784 | /// </summary> | |
1785 | /// <param name="config">The configuration that was received from libCEC</param> | |
1786 | void Update(const CEC::libcec_configuration &config) | |
1787 | { | |
1788 | DeviceName = gcnew System::String(config.strDeviceName); | |
1789 | ||
1790 | for (unsigned int iPtr = 0; iPtr < 5; iPtr++) | |
1791 | DeviceTypes->Types[iPtr] = (CecDeviceType)config.deviceTypes.types[iPtr]; | |
1792 | ||
1793 | AutodetectAddress = config.bAutodetectAddress == 1; | |
1794 | PhysicalAddress = config.iPhysicalAddress; | |
1795 | BaseDevice = (CecLogicalAddress)config.baseDevice; | |
1796 | HDMIPort = config.iHDMIPort; | |
1797 | ClientVersion = (CecClientVersion)config.clientVersion; | |
1798 | ServerVersion = (CecServerVersion)config.serverVersion; | |
1799 | TvVendor = (CecVendorId)config.tvVendor; | |
1800 | ||
1801 | // player specific settings | |
1802 | GetSettingsFromROM = config.bGetSettingsFromROM == 1; | |
1803 | UseTVMenuLanguage = config.bUseTVMenuLanguage == 1; | |
1804 | ActivateSource = config.bActivateSource == 1; | |
1805 | ||
1806 | WakeDevices->Clear(); | |
1807 | for (uint8_t iPtr = 0; iPtr <= 16; iPtr++) | |
1808 | if (config.wakeDevices[iPtr]) | |
1809 | WakeDevices->Set((CecLogicalAddress)iPtr); | |
1810 | ||
1811 | PowerOffDevices->Clear(); | |
1812 | for (uint8_t iPtr = 0; iPtr <= 16; iPtr++) | |
1813 | if (config.powerOffDevices[iPtr]) | |
1814 | PowerOffDevices->Set((CecLogicalAddress)iPtr); | |
1815 | ||
1816 | PowerOffScreensaver = config.bPowerOffScreensaver == 1; | |
1817 | PowerOffOnStandby = config.bPowerOffOnStandby == 1; | |
1818 | ||
1819 | if (ServerVersion >= CecServerVersion::Version1_5_1) | |
1820 | SendInactiveSource = config.bSendInactiveSource == 1; | |
1821 | ||
1822 | if (ServerVersion >= CecServerVersion::Version1_5_3) | |
1823 | { | |
1824 | LogicalAddresses->Clear(); | |
1825 | for (uint8_t iPtr = 0; iPtr <= 16; iPtr++) | |
1826 | if (config.logicalAddresses[iPtr]) | |
1827 | LogicalAddresses->Set((CecLogicalAddress)iPtr); | |
1828 | } | |
1829 | ||
1830 | if (ServerVersion >= CecServerVersion::Version1_6_0) | |
1831 | { | |
1832 | FirmwareVersion = config.iFirmwareVersion; | |
1833 | PowerOffDevicesOnStandby = config.bPowerOffDevicesOnStandby == 1; | |
1834 | ShutdownOnStandby = config.bShutdownOnStandby == 1; | |
1835 | } | |
1836 | ||
1837 | if (ServerVersion >= CecServerVersion::Version1_6_2) | |
22190f06 | 1838 | { |
f9717bcc | 1839 | DeviceLanguage = gcnew System::String(config.strDeviceLanguage); |
22190f06 LOK |
1840 | FirmwareBuildDate = gcnew System::DateTime(1970,1,1,0,0,0,0); |
1841 | FirmwareBuildDate = FirmwareBuildDate->AddSeconds(config.iFirmwareBuildDate); | |
1842 | } | |
f9717bcc LOK |
1843 | |
1844 | if (ServerVersion >= CecServerVersion::Version1_6_3) | |
1845 | MonitorOnlyClient = config.bMonitorOnly == 1; | |
22190f06 LOK |
1846 | |
1847 | if (ServerVersion >= CecServerVersion::Version1_8_0) | |
1848 | CECVersion = (CecVersion)config.cecVersion; | |
1849 | ||
1850 | if (ServerVersion >= CecServerVersion::Version1_8_2) | |
1851 | AdapterType = (CecAdapterType)config.adapterType; | |
d18ea27b JM |
1852 | |
1853 | if (ServerVersion >= CecServerVersion::Version2_1_0) | |
1854 | PowerOnScreensaver = config.bPowerOnScreensaver == 1; | |
f9717bcc LOK |
1855 | } |
1856 | ||
1857 | /// <summary> | |
1858 | /// The device name to use on the CEC bus | |
1859 | /// </summary> | |
1860 | property System::String ^ DeviceName; | |
1861 | ||
1862 | /// <summary> | |
1863 | /// The device type(s) to use on the CEC bus for libCEC | |
1864 | /// </summary> | |
1865 | property CecDeviceTypeList ^ DeviceTypes; | |
1866 | ||
1867 | /// <summary> | |
f81c0652 | 1868 | /// (read only) set to true by libCEC when the physical address was autodetected |
f9717bcc LOK |
1869 | /// </summary> |
1870 | property bool AutodetectAddress; | |
1871 | ||
1872 | /// <summary> | |
f81c0652 | 1873 | /// The physical address of the CEC adapter |
f9717bcc LOK |
1874 | /// </summary> |
1875 | property uint16_t PhysicalAddress; | |
1876 | ||
1877 | /// <summary> | |
f81c0652 | 1878 | /// The logical address of the device to which the adapter is connected. Only used when PhysicalAddress = 0 or when the adapter doesn't support autodetection |
f9717bcc LOK |
1879 | /// </summary> |
1880 | property CecLogicalAddress BaseDevice; | |
1881 | ||
1882 | /// <summary> | |
f81c0652 | 1883 | /// The HDMI port to which the adapter is connected. Only used when iPhysicalAddress = 0 or when the adapter doesn't support autodetection |
f9717bcc LOK |
1884 | /// </summary> |
1885 | property uint8_t HDMIPort; | |
1886 | ||
1887 | /// <summary> | |
1888 | /// The client API version to use | |
1889 | /// </summary> | |
1890 | property CecClientVersion ClientVersion; | |
1891 | ||
1892 | /// <summary> | |
1893 | /// The version of libCEC | |
1894 | /// </summary> | |
1895 | property CecServerVersion ServerVersion; | |
1896 | ||
1897 | /// <summary> | |
f81c0652 | 1898 | /// Override the vendor ID of the TV. Leave this untouched to autodetect |
f9717bcc LOK |
1899 | /// </summary> |
1900 | property CecVendorId TvVendor; | |
1901 | ||
1902 | /// <summary> | |
1903 | /// True to read the settings from the EEPROM, which possibly override the settings passed here | |
1904 | /// </summary> | |
1905 | property bool GetSettingsFromROM; | |
1906 | ||
1907 | /// <summary> | |
1908 | /// Use the language setting of the TV in the client application. Must be implemented by the client application. | |
f81c0652 | 1909 | /// 3 character ISO 639-2 country code. see http://http://www.loc.gov/standards/iso639-2/ |
f9717bcc LOK |
1910 | /// </summary> |
1911 | property bool UseTVMenuLanguage; | |
1912 | ||
1913 | /// <summary> | |
1914 | /// Make libCEC the active source when starting the client application | |
1915 | /// </summary> | |
1916 | property bool ActivateSource; | |
1917 | ||
1918 | /// <summary> | |
f81c0652 | 1919 | /// List of devices to wake when initialising libCEC or when calling PowerOnDevices() without any parameter. |
f9717bcc LOK |
1920 | /// </summary> |
1921 | property CecLogicalAddresses ^WakeDevices; | |
1922 | ||
1923 | /// <summary> | |
f81c0652 | 1924 | /// List of devices to power off when calling StandbyDevices() without any parameter. |
f9717bcc LOK |
1925 | /// </summary> |
1926 | property CecLogicalAddresses ^PowerOffDevices; | |
1927 | ||
1928 | /// <summary> | |
1929 | /// Send standby commands when the client application activates the screensaver. Must be implemented by the client application. | |
1930 | /// </summary> | |
1931 | property bool PowerOffScreensaver; | |
1932 | ||
1933 | /// <summary> | |
1934 | /// Power off the PC when the TV powers off. Must be implemented by the client application. | |
1935 | /// </summary> | |
1936 | property bool PowerOffOnStandby; | |
1937 | ||
1938 | /// <summary> | |
1939 | /// Send an inactive source message when exiting the client application. | |
1940 | /// </summary> | |
1941 | property bool SendInactiveSource; | |
1942 | ||
1943 | /// <summary> | |
1944 | /// The list of logical addresses that libCEC is using | |
1945 | /// </summary> | |
1946 | property CecLogicalAddresses ^LogicalAddresses; | |
1947 | ||
1948 | /// <summary> | |
1949 | /// The firmware version of the adapter to which libCEC is connected | |
1950 | /// </summary> | |
1951 | property uint16_t FirmwareVersion; | |
1952 | ||
1953 | /// <summary> | |
1954 | /// Send standby commands when the client application activates standby mode (S3). Must be implemented by the client application. | |
1955 | /// </summary> | |
1956 | property bool PowerOffDevicesOnStandby; | |
f81c0652 LOK |
1957 | |
1958 | /// <summary> | |
1959 | /// Shutdown this PC when the TV is switched off. only used when PowerOffOnStandby = false | |
1960 | /// </summary> | |
f9717bcc LOK |
1961 | property bool ShutdownOnStandby; |
1962 | ||
1963 | /// <summary> | |
1964 | /// True to start a monitor-only client, false to start a standard client. | |
1965 | /// </summary> | |
1966 | property bool MonitorOnlyClient; | |
1967 | ||
1968 | /// <summary> | |
1969 | /// The language code of the menu language that libCEC reports to other devices. | |
f81c0652 | 1970 | /// 3 character ISO 639-2 country code. see http://http://www.loc.gov/standards/iso639-2/ |
f9717bcc LOK |
1971 | /// </summary> |
1972 | property System::String ^ DeviceLanguage; | |
1973 | ||
1974 | /// <summary> | |
1975 | /// The callback methods to use. | |
1976 | /// </summary> | |
1977 | property CecCallbackMethods ^ Callbacks; | |
22190f06 LOK |
1978 | |
1979 | /// <summary> | |
1980 | /// The build date of the firmware. | |
1981 | /// </summary> | |
1982 | property System::DateTime ^ FirmwareBuildDate; | |
1983 | ||
1984 | /// <summary> | |
1985 | /// The CEC version that libCEC uses. | |
1986 | /// </summary> | |
1987 | property CecVersion CECVersion; | |
1988 | ||
1989 | /// <summary> | |
1990 | /// The type of adapter that libCEC is connected to. | |
1991 | /// </summary> | |
1992 | property CecAdapterType AdapterType; | |
f2658b50 LOK |
1993 | |
1994 | /// <summary> | |
1995 | /// True to power on when quitting the screensaver. | |
1996 | /// </summary> | |
1997 | property bool PowerOnScreensaver; | |
f9717bcc LOK |
1998 | }; |
1999 | ||
2000 | // the callback methods are called by unmanaged code, so we need some delegates for this | |
2001 | #pragma unmanaged | |
2002 | // unmanaged callback methods | |
2003 | typedef int (__stdcall *LOGCB) (const CEC::cec_log_message &message); | |
2004 | typedef int (__stdcall *KEYCB) (const CEC::cec_keypress &key); | |
2005 | typedef int (__stdcall *COMMANDCB)(const CEC::cec_command &command); | |
2006 | typedef int (__stdcall *CONFIGCB) (const CEC::libcec_configuration &config); | |
2007 | typedef int (__stdcall *ALERTCB) (const CEC::libcec_alert, const CEC::libcec_parameter &data); | |
2008 | typedef int (__stdcall *MENUCB) (const CEC::cec_menu_state newVal); | |
2009 | typedef void (__stdcall *ACTICB) (const CEC::cec_logical_address logicalAddress, const uint8_t bActivated); | |
2010 | ||
8438c41f LOK |
2011 | /// <summary> |
2012 | /// libCEC callback methods. Unmanaged code. | |
2013 | /// </summary> | |
f9717bcc LOK |
2014 | typedef struct |
2015 | { | |
8438c41f LOK |
2016 | /// <summary> |
2017 | /// Log message callback | |
2018 | /// </summary> | |
f9717bcc | 2019 | LOGCB logCB; |
8438c41f LOK |
2020 | /// <summary> |
2021 | /// Key press/release callback | |
2022 | /// </summary> | |
f9717bcc | 2023 | KEYCB keyCB; |
8438c41f LOK |
2024 | /// <summary> |
2025 | /// Raw CEC data callback | |
2026 | /// </summary> | |
f9717bcc | 2027 | COMMANDCB commandCB; |
8438c41f LOK |
2028 | /// <summary> |
2029 | /// Updated configuration callback | |
2030 | /// </summary> | |
f9717bcc | 2031 | CONFIGCB configCB; |
8438c41f LOK |
2032 | /// <summary> |
2033 | /// Alert message callback | |
2034 | /// </summary> | |
f9717bcc | 2035 | ALERTCB alertCB; |
8438c41f LOK |
2036 | /// <summary> |
2037 | /// Menu status change callback | |
2038 | /// </summary> | |
f9717bcc | 2039 | MENUCB menuCB; |
8438c41f LOK |
2040 | /// <summary> |
2041 | /// Source (de)activated callback | |
2042 | /// </summary> | |
f9717bcc LOK |
2043 | ACTICB sourceActivatedCB; |
2044 | } UnmanagedCecCallbacks; | |
2045 | ||
2046 | static PLATFORM::CMutex g_callbackMutex; | |
2047 | static std::vector<UnmanagedCecCallbacks> g_unmanagedCallbacks; | |
dc6366e8 | 2048 | static CEC::ICECCallbacks g_cecCallbacks; |
4ef3b314 | 2049 | |
8438c41f LOK |
2050 | /// <summary> |
2051 | /// Called by libCEC to send back a log message to the application | |
2052 | /// </summary> | |
2053 | /// <param name="cbParam">Pointer to the callback struct</param> | |
2054 | /// <param name="message">The log message</param> | |
2055 | /// <return>1 when handled, 0 otherwise</return> | |
ecc38cdd | 2056 | int CecLogMessageCB(void *cbParam, const CEC::cec_log_message message) |
f9717bcc LOK |
2057 | { |
2058 | if (cbParam) | |
2059 | { | |
2060 | size_t iPtr = (size_t)cbParam; | |
2061 | PLATFORM::CLockObject lock(g_callbackMutex); | |
2062 | if (iPtr >= 0 && iPtr < g_unmanagedCallbacks.size()) | |
2063 | return g_unmanagedCallbacks[iPtr].logCB(message); | |
2064 | } | |
2065 | return 0; | |
2066 | } | |
2067 | ||
8438c41f LOK |
2068 | /// <summary> |
2069 | /// Called by libCEC to send back a key press or release to the application | |
2070 | /// </summary> | |
2071 | /// <param name="cbParam">Pointer to the callback struct</param> | |
2072 | /// <param name="key">The key press command that libCEC received</param> | |
2073 | /// <return>1 when handled, 0 otherwise</return> | |
ecc38cdd | 2074 | int CecKeyPressCB(void *cbParam, const CEC::cec_keypress key) |
f9717bcc LOK |
2075 | { |
2076 | if (cbParam) | |
2077 | { | |
2078 | size_t iPtr = (size_t)cbParam; | |
2079 | PLATFORM::CLockObject lock(g_callbackMutex); | |
2080 | if (iPtr >= 0 && iPtr < g_unmanagedCallbacks.size()) | |
2081 | return g_unmanagedCallbacks[iPtr].keyCB(key); | |
2082 | } | |
2083 | return 0; | |
2084 | } | |
2085 | ||
8438c41f LOK |
2086 | /// <summary> |
2087 | /// Called by libCEC to send back raw CEC data to the application | |
2088 | /// </summary> | |
2089 | /// <param name="cbParam">Pointer to the callback struct</param> | |
2090 | /// <param name="command">The raw CEC data</param> | |
2091 | /// <return>1 when handled, 0 otherwise</return> | |
ecc38cdd | 2092 | int CecCommandCB(void *cbParam, const CEC::cec_command command) |
f9717bcc LOK |
2093 | { |
2094 | if (cbParam) | |
2095 | { | |
2096 | size_t iPtr = (size_t)cbParam; | |
2097 | PLATFORM::CLockObject lock(g_callbackMutex); | |
2098 | if (iPtr >= 0 && iPtr < g_unmanagedCallbacks.size()) | |
2099 | return g_unmanagedCallbacks[iPtr].commandCB(command); | |
2100 | } | |
2101 | return 0; | |
2102 | } | |
4ef3b314 | 2103 | |
8438c41f LOK |
2104 | /// <summary> |
2105 | /// Called by libCEC to send back an updated configuration to the application | |
2106 | /// </summary> | |
2107 | /// <param name="cbParam">Pointer to the callback struct</param> | |
2108 | /// <param name="config">The new configuration</param> | |
2109 | /// <return>1 when handled, 0 otherwise</return> | |
ecc38cdd | 2110 | int CecConfigCB(void *cbParam, const CEC::libcec_configuration config) |
f9717bcc LOK |
2111 | { |
2112 | if (cbParam) | |
2113 | { | |
2114 | size_t iPtr = (size_t)cbParam; | |
2115 | PLATFORM::CLockObject lock(g_callbackMutex); | |
2116 | if (iPtr >= 0 && iPtr < g_unmanagedCallbacks.size()) | |
2117 | return g_unmanagedCallbacks[iPtr].configCB(config); | |
2118 | } | |
2119 | return 0; | |
2120 | } | |
2121 | ||
8438c41f LOK |
2122 | /// <summary> |
2123 | /// Called by libCEC to send back an alert message to the application | |
2124 | /// </summary> | |
2125 | /// <param name="cbParam">Pointer to the callback struct</param> | |
2126 | /// <param name="data">The alert message</param> | |
2127 | /// <return>1 when handled, 0 otherwise</return> | |
ecc38cdd | 2128 | int CecAlertCB(void *cbParam, const CEC::libcec_alert alert, const CEC::libcec_parameter data) |
f9717bcc LOK |
2129 | { |
2130 | if (cbParam) | |
2131 | { | |
2132 | size_t iPtr = (size_t)cbParam; | |
2133 | PLATFORM::CLockObject lock(g_callbackMutex); | |
2134 | if (iPtr >= 0 && iPtr < g_unmanagedCallbacks.size()) | |
2135 | return g_unmanagedCallbacks[iPtr].alertCB(alert, data); | |
2136 | } | |
2137 | return 0; | |
2138 | } | |
2139 | ||
8438c41f LOK |
2140 | /// <summary> |
2141 | /// Called by libCEC to send back a menu state change to the application | |
2142 | /// </summary> | |
2143 | /// <param name="cbParam">Pointer to the callback struct</param> | |
2144 | /// <param name="newVal">The new menu state</param> | |
2145 | /// <return>1 when handled, 0 otherwise</return> | |
f9717bcc LOK |
2146 | int CecMenuCB(void *cbParam, const CEC::cec_menu_state newVal) |
2147 | { | |
2148 | if (cbParam) | |
2149 | { | |
2150 | size_t iPtr = (size_t)cbParam; | |
2151 | PLATFORM::CLockObject lock(g_callbackMutex); | |
2152 | if (iPtr >= 0 && iPtr < g_unmanagedCallbacks.size()) | |
2153 | return g_unmanagedCallbacks[iPtr].menuCB(newVal); | |
2154 | } | |
2155 | return 0; | |
2156 | } | |
dc6366e8 | 2157 | |
8438c41f LOK |
2158 | /// <summary> |
2159 | /// Called by libCEC to notify the application that the source that is handled by libCEC was (de)activated | |
2160 | /// </summary> | |
2161 | /// <param name="cbParam">Pointer to the callback struct</param> | |
2162 | /// <param name="logicalAddress">The logical address that was (de)activated</param> | |
2163 | /// <param name="activated">True when activated, false when deactivated</param> | |
2164 | void CecSourceActivatedCB(void *cbParam, const CEC::cec_logical_address logicalAddress, const uint8_t activated) | |
f9717bcc LOK |
2165 | { |
2166 | if (cbParam) | |
2167 | { | |
2168 | size_t iPtr = (size_t)cbParam; | |
2169 | PLATFORM::CLockObject lock(g_callbackMutex); | |
2170 | if (iPtr >= 0 && iPtr < g_unmanagedCallbacks.size()) | |
8438c41f | 2171 | g_unmanagedCallbacks[iPtr].sourceActivatedCB(logicalAddress, activated); |
f9717bcc LOK |
2172 | } |
2173 | } | |
2174 | ||
2175 | #pragma managed | |
1c7cd8f8 LOK |
2176 | /// <summary> |
2177 | /// Delegate method for the CecLogMessageCB callback in CecCallbackMethods | |
2178 | /// </summary> | |
f9717bcc | 2179 | public delegate int CecLogMessageManagedDelegate(const CEC::cec_log_message &); |
1c7cd8f8 LOK |
2180 | /// <summary> |
2181 | /// Delegate method for the CecKeyPressCB callback in CecCallbackMethods | |
2182 | /// </summary> | |
f9717bcc | 2183 | public delegate int CecKeyPressManagedDelegate(const CEC::cec_keypress &); |
1c7cd8f8 LOK |
2184 | /// <summary> |
2185 | /// Delegate method for the CecCommandCB callback in CecCallbackMethods | |
2186 | /// </summary> | |
f9717bcc | 2187 | public delegate int CecCommandManagedDelegate(const CEC::cec_command &); |
1c7cd8f8 LOK |
2188 | /// <summary> |
2189 | /// Delegate method for the CecConfigCB callback in CecCallbackMethods | |
2190 | /// </summary> | |
f9717bcc | 2191 | public delegate int CecConfigManagedDelegate(const CEC::libcec_configuration &); |
1c7cd8f8 LOK |
2192 | /// <summary> |
2193 | /// Delegate method for the CecAlertCB callback in CecCallbackMethods | |
2194 | /// </summary> | |
f9717bcc | 2195 | public delegate int CecAlertManagedDelegate(const CEC::libcec_alert, const CEC::libcec_parameter &); |
1c7cd8f8 LOK |
2196 | /// <summary> |
2197 | /// Delegate method for the CecMenuCB callback in CecCallbackMethods | |
2198 | /// </summary> | |
2199 | public delegate int CecMenuManagedDelegate(const CEC::cec_menu_state); | |
2200 | /// <summary> | |
2201 | /// Delegate method for the CecSourceActivatedCB callback in CecCallbackMethods | |
2202 | /// </summary> | |
2203 | public delegate void CecSourceActivatedManagedDelegate(const CEC::cec_logical_address, const uint8_t); | |
f9717bcc | 2204 | |
8438c41f LOK |
2205 | /// <summary> |
2206 | /// Assign the callback methods in the g_cecCallbacks struct | |
2207 | /// </summary> | |
f9717bcc LOK |
2208 | void AssignCallbacks() |
2209 | { | |
2210 | g_cecCallbacks.CBCecLogMessage = CecLogMessageCB; | |
2211 | g_cecCallbacks.CBCecKeyPress = CecKeyPressCB; | |
2212 | g_cecCallbacks.CBCecCommand = CecCommandCB; | |
2213 | g_cecCallbacks.CBCecConfigurationChanged = CecConfigCB; | |
2214 | g_cecCallbacks.CBCecAlert = CecAlertCB; | |
2215 | g_cecCallbacks.CBCecMenuStateChanged = CecMenuCB; | |
2216 | g_cecCallbacks.CBCecSourceActivated = CecSourceActivatedCB; | |
2217 | } | |
2218 | ||
2219 | /// <summary> | |
2220 | /// The callback methods that libCEC uses | |
2221 | /// </summary> | |
2222 | public ref class CecCallbackMethods | |
2223 | { | |
2224 | public: | |
11fea069 LOK |
2225 | CecCallbackMethods(void) |
2226 | { | |
f9717bcc LOK |
2227 | m_iCallbackPtr = -1; |
2228 | AssignCallbacks(); | |
11fea069 LOK |
2229 | m_bHasCallbacks = false; |
2230 | m_bDelegatesCreated = false; | |
2231 | } | |
4ef3b314 | 2232 | |
f9717bcc | 2233 | ~CecCallbackMethods(void) |
dc6366e8 LOK |
2234 | { |
2235 | DestroyDelegates(); | |
2236 | } | |
2237 | ||
8438c41f LOK |
2238 | /// <summary> |
2239 | /// Pointer to the callbacks struct entry | |
2240 | /// </summary> | |
f9717bcc LOK |
2241 | size_t GetCallbackPtr(void) |
2242 | { | |
2243 | PLATFORM::CLockObject lock(g_callbackMutex); | |
2244 | return m_iCallbackPtr; | |
2245 | } | |
2246 | ||
2247 | protected: | |
2248 | !CecCallbackMethods(void) | |
2249 | { | |
2250 | DestroyDelegates(); | |
2251 | } | |
2252 | ||
2253 | public: | |
8438c41f LOK |
2254 | /// <summary> |
2255 | /// Disable callback methods | |
2256 | /// </summary> | |
f9717bcc LOK |
2257 | virtual void DisableCallbacks(void) |
2258 | { | |
2259 | DestroyDelegates(); | |
2260 | } | |
2261 | ||
8438c41f LOK |
2262 | /// <summary> |
2263 | /// Enable callback methods | |
2264 | /// </summary> | |
2265 | /// <param name="callbacks">Callback methods to activate</param> | |
2266 | /// <return>true when handled, false otherwise</return> | |
f9717bcc LOK |
2267 | virtual bool EnableCallbacks(CecCallbackMethods ^ callbacks) |
2268 | { | |
11fea069 | 2269 | CreateDelegates(); |
f9717bcc LOK |
2270 | if (!m_bHasCallbacks) |
2271 | { | |
2272 | m_bHasCallbacks = true; | |
2273 | m_callbacks = callbacks; | |
2274 | return true; | |
2275 | } | |
2276 | ||
2277 | return false; | |
2278 | } | |
2279 | ||
2280 | /// <summary> | |
8438c41f LOK |
2281 | /// Called by libCEC to send back a log message to the application. |
2282 | /// Override in the application to handle this callback. | |
f9717bcc LOK |
2283 | /// </summary> |
2284 | /// <param name="message">The log message</param> | |
8438c41f | 2285 | /// <return>1 when handled, 0 otherwise</return> |
f9717bcc LOK |
2286 | virtual int ReceiveLogMessage(CecLogMessage ^ message) |
2287 | { | |
2288 | return 0; | |
2289 | } | |
2290 | ||
2291 | /// <summary> | |
8438c41f LOK |
2292 | /// Called by libCEC to send back a key press or release to the application. |
2293 | /// Override in the application to handle this callback. | |
f9717bcc LOK |
2294 | /// </summary> |
2295 | /// <param name="key">The key press command that libCEC received</param> | |
8438c41f | 2296 | /// <return>1 when handled, 0 otherwise</return> |
f9717bcc LOK |
2297 | virtual int ReceiveKeypress(CecKeypress ^ key) |
2298 | { | |
2299 | return 0; | |
2300 | } | |
2301 | ||
2302 | /// <summary> | |
8438c41f LOK |
2303 | /// Called by libCEC to send back raw CEC data to the application. |
2304 | /// Override in the application to handle this callback. | |
f9717bcc LOK |
2305 | /// </summary> |
2306 | /// <param name="command">The raw CEC data</param> | |
8438c41f | 2307 | /// <return>1 when handled, 0 otherwise</return> |
f9717bcc LOK |
2308 | virtual int ReceiveCommand(CecCommand ^ command) |
2309 | { | |
2310 | return 0; | |
2311 | } | |
2312 | ||
2313 | /// <summary> | |
8438c41f LOK |
2314 | /// Called by libCEC to send back an updated configuration to the application. |
2315 | /// Override in the application to handle this callback. | |
f9717bcc LOK |
2316 | /// </summary> |
2317 | /// <param name="config">The new configuration</param> | |
8438c41f | 2318 | /// <return>1 when handled, 0 otherwise</return> |
f9717bcc LOK |
2319 | virtual int ConfigurationChanged(LibCECConfiguration ^ config) |
2320 | { | |
2321 | return 0; | |
2322 | } | |
2323 | ||
2324 | /// <summary> | |
8438c41f LOK |
2325 | /// Called by libCEC to send back an alert message to the application. |
2326 | /// Override in the application to handle this callback. | |
f9717bcc LOK |
2327 | /// </summary> |
2328 | /// <param name="data">The alert message</param> | |
8438c41f | 2329 | /// <return>1 when handled, 0 otherwise</return> |
f9717bcc LOK |
2330 | virtual int ReceiveAlert(CecAlert alert, CecParameter ^ data) |
2331 | { | |
2332 | return 0; | |
2333 | } | |
2334 | ||
2335 | /// <summary> | |
8438c41f LOK |
2336 | /// Called by libCEC to send back a menu state change to the application. |
2337 | /// Override in the application to handle this callback. | |
f9717bcc LOK |
2338 | /// </summary> |
2339 | /// <param name="newVal">The new menu state</param> | |
8438c41f | 2340 | /// <return>1 when handled, 0 otherwise</return> |
f9717bcc LOK |
2341 | virtual int ReceiveMenuStateChange(CecMenuState newVal) |
2342 | { | |
2343 | return 0; | |
2344 | } | |
2345 | ||
2346 | /// <summary> | |
8438c41f LOK |
2347 | /// Called by libCEC to notify the application that the source that is handled by libCEC was (de)activated. |
2348 | /// Override in the application to handle this callback. | |
f9717bcc LOK |
2349 | /// </summary> |
2350 | /// <param name="logicalAddress">The logical address that was (de)activated</param> | |
2351 | /// <param name="activated">True when activated, false when deactivated</param> | |
2352 | virtual void SourceActivated(CecLogicalAddress logicalAddress, bool activated) | |
2353 | { | |
2354 | } | |
2355 | ||
2356 | protected: | |
2357 | // managed callback methods | |
2358 | int CecLogMessageManaged(const CEC::cec_log_message &message) | |
2359 | { | |
2360 | int iReturn(0); | |
2361 | if (m_bHasCallbacks) | |
2362 | iReturn = m_callbacks->ReceiveLogMessage(gcnew CecLogMessage(gcnew System::String(message.message), (CecLogLevel)message.level, message.time)); | |
2363 | return iReturn; | |
2364 | } | |
2365 | ||
2366 | int CecKeyPressManaged(const CEC::cec_keypress &key) | |
2367 | { | |
2368 | int iReturn(0); | |
2369 | if (m_bHasCallbacks) | |
2370 | iReturn = m_callbacks->ReceiveKeypress(gcnew CecKeypress((CecUserControlCode)key.keycode, key.duration)); | |
2371 | return iReturn; | |
2372 | } | |
2373 | ||
2374 | int CecCommandManaged(const CEC::cec_command &command) | |
2375 | { | |
2376 | int iReturn(0); | |
2377 | if (m_bHasCallbacks) | |
2378 | { | |
2379 | CecCommand ^ newCommand = gcnew CecCommand((CecLogicalAddress)command.initiator, (CecLogicalAddress)command.destination, command.ack == 1 ? true : false, command.eom == 1 ? true : false, (CecOpcode)command.opcode, command.transmit_timeout); | |
2380 | for (uint8_t iPtr = 0; iPtr < command.parameters.size; iPtr++) | |
2381 | newCommand->Parameters->PushBack(command.parameters[iPtr]); | |
2382 | iReturn = m_callbacks->ReceiveCommand(newCommand); | |
2383 | } | |
2384 | return iReturn; | |
2385 | } | |
2386 | ||
2387 | int CecConfigManaged(const CEC::libcec_configuration &config) | |
2388 | { | |
2389 | int iReturn(0); | |
2390 | if (m_bHasCallbacks) | |
2391 | { | |
2392 | LibCECConfiguration ^netConfig = gcnew LibCECConfiguration(); | |
2393 | netConfig->Update(config); | |
2394 | iReturn = m_callbacks->ConfigurationChanged(netConfig); | |
2395 | } | |
2396 | return iReturn; | |
2397 | } | |
2398 | ||
2399 | int CecAlertManaged(const CEC::libcec_alert alert, const CEC::libcec_parameter &data) | |
2400 | { | |
2401 | int iReturn(0); | |
2402 | if (m_bHasCallbacks) | |
2403 | { | |
2404 | CecParameterType newType = (CecParameterType)data.paramType; | |
2405 | if (newType == CecParameterType::ParameterTypeString) | |
2406 | { | |
2407 | System::String ^ newData = gcnew System::String((const char *)data.paramData, 0, 128); | |
2408 | CecParameter ^ newParam = gcnew CecParameter(newType, newData); | |
2409 | iReturn = m_callbacks->ReceiveAlert((CecAlert)alert, newParam); | |
2410 | } | |
2411 | } | |
2412 | return iReturn; | |
2413 | } | |
2414 | ||
2415 | int CecMenuManaged(const CEC::cec_menu_state newVal) | |
2416 | { | |
2417 | int iReturn(0); | |
2418 | if (m_bHasCallbacks) | |
2419 | { | |
2420 | iReturn = m_callbacks->ReceiveMenuStateChange((CecMenuState)newVal); | |
2421 | } | |
2422 | return iReturn; | |
2423 | } | |
2424 | ||
2425 | void CecSourceActivatedManaged(const CEC::cec_logical_address logicalAddress, const uint8_t bActivated) | |
2426 | { | |
2427 | if (m_bHasCallbacks) | |
2428 | m_callbacks->SourceActivated((CecLogicalAddress)logicalAddress, bActivated == 1); | |
2429 | } | |
2430 | ||
2431 | void DestroyDelegates() | |
2432 | { | |
11fea069 | 2433 | m_bHasCallbacks = false; |
f9717bcc LOK |
2434 | if (m_bDelegatesCreated) |
2435 | { | |
11fea069 | 2436 | m_bDelegatesCreated = false; |
f9717bcc LOK |
2437 | m_logMessageGCHandle.Free(); |
2438 | m_keypressGCHandle.Free(); | |
2439 | m_commandGCHandle.Free(); | |
2440 | m_alertGCHandle.Free(); | |
2441 | m_menuGCHandle.Free(); | |
2442 | m_sourceActivatedGCHandle.Free(); | |
2443 | } | |
2444 | } | |
4ef3b314 | 2445 | |
11fea069 LOK |
2446 | void CreateDelegates() |
2447 | { | |
2448 | DestroyDelegates(); | |
2449 | ||
2450 | if (!m_bDelegatesCreated) | |
2451 | { | |
2452 | msclr::interop::marshal_context ^ context = gcnew msclr::interop::marshal_context(); | |
2453 | ||
2454 | // create the delegate method for the log message callback | |
dc6366e8 LOK |
2455 | m_logMessageDelegate = gcnew CecLogMessageManagedDelegate(this, &CecCallbackMethods::CecLogMessageManaged); |
2456 | m_logMessageGCHandle = System::Runtime::InteropServices::GCHandle::Alloc(m_logMessageDelegate); | |
f9717bcc | 2457 | m_logMessageCallback = static_cast<LOGCB>(System::Runtime::InteropServices::Marshal::GetFunctionPointerForDelegate(m_logMessageDelegate).ToPointer()); |
11fea069 LOK |
2458 | |
2459 | // create the delegate method for the keypress callback | |
dc6366e8 LOK |
2460 | m_keypressDelegate = gcnew CecKeyPressManagedDelegate(this, &CecCallbackMethods::CecKeyPressManaged); |
2461 | m_keypressGCHandle = System::Runtime::InteropServices::GCHandle::Alloc(m_keypressDelegate); | |
f9717bcc | 2462 | m_keypressCallback = static_cast<KEYCB>(System::Runtime::InteropServices::Marshal::GetFunctionPointerForDelegate(m_keypressDelegate).ToPointer()); |
11fea069 LOK |
2463 | |
2464 | // create the delegate method for the command callback | |
dc6366e8 LOK |
2465 | m_commandDelegate = gcnew CecCommandManagedDelegate(this, &CecCallbackMethods::CecCommandManaged); |
2466 | m_commandGCHandle = System::Runtime::InteropServices::GCHandle::Alloc(m_commandDelegate); | |
f9717bcc | 2467 | m_commandCallback = static_cast<COMMANDCB>(System::Runtime::InteropServices::Marshal::GetFunctionPointerForDelegate(m_commandDelegate).ToPointer()); |
11fea069 LOK |
2468 | |
2469 | // create the delegate method for the configuration change callback | |
dc6366e8 LOK |
2470 | m_configDelegate = gcnew CecConfigManagedDelegate(this, &CecCallbackMethods::CecConfigManaged); |
2471 | m_configGCHandle = System::Runtime::InteropServices::GCHandle::Alloc(m_configDelegate); | |
f9717bcc | 2472 | m_configCallback = static_cast<CONFIGCB>(System::Runtime::InteropServices::Marshal::GetFunctionPointerForDelegate(m_configDelegate).ToPointer()); |
11fea069 | 2473 | |
5ee37222 | 2474 | // create the delegate method for the alert callback |
dc6366e8 LOK |
2475 | m_alertDelegate = gcnew CecAlertManagedDelegate(this, &CecCallbackMethods::CecAlertManaged); |
2476 | m_alertGCHandle = System::Runtime::InteropServices::GCHandle::Alloc(m_alertDelegate); | |
f9717bcc | 2477 | m_alertCallback = static_cast<ALERTCB>(System::Runtime::InteropServices::Marshal::GetFunctionPointerForDelegate(m_alertDelegate).ToPointer()); |
5ee37222 | 2478 | |
c3a20edb | 2479 | // create the delegate method for the menu callback |
dc6366e8 LOK |
2480 | m_menuDelegate = gcnew CecMenuManagedDelegate(this, &CecCallbackMethods::CecMenuManaged); |
2481 | m_menuGCHandle = System::Runtime::InteropServices::GCHandle::Alloc(m_menuDelegate); | |
f9717bcc | 2482 | m_menuCallback = static_cast<MENUCB>(System::Runtime::InteropServices::Marshal::GetFunctionPointerForDelegate(m_menuDelegate).ToPointer()); |
c3a20edb | 2483 | |
f9717bcc | 2484 | // create the delegate method for the source activated callback |
dc6366e8 LOK |
2485 | m_sourceActivatedDelegate = gcnew CecSourceActivatedManagedDelegate(this, &CecCallbackMethods::CecSourceActivatedManaged); |
2486 | m_sourceActivatedGCHandle = System::Runtime::InteropServices::GCHandle::Alloc(m_sourceActivatedDelegate); | |
f9717bcc | 2487 | m_sourceActivatedCallback = static_cast<ACTICB>(System::Runtime::InteropServices::Marshal::GetFunctionPointerForDelegate(m_sourceActivatedDelegate).ToPointer()); |
29d5198c | 2488 | |
11fea069 | 2489 | delete context; |
dc6366e8 | 2490 | |
f9717bcc LOK |
2491 | UnmanagedCecCallbacks unmanagedCallbacks; |
2492 | unmanagedCallbacks.logCB = m_logMessageCallback; | |
2493 | unmanagedCallbacks.keyCB = m_keypressCallback; | |
2494 | unmanagedCallbacks.commandCB = m_commandCallback; | |
2495 | unmanagedCallbacks.configCB = m_configCallback; | |
2496 | unmanagedCallbacks.alertCB = m_alertCallback; | |
2497 | unmanagedCallbacks.menuCB = m_menuCallback; | |
2498 | unmanagedCallbacks.sourceActivatedCB = m_sourceActivatedCallback; | |
2499 | ||
2500 | PLATFORM::CLockObject lock(g_callbackMutex); | |
2501 | g_unmanagedCallbacks.push_back(unmanagedCallbacks); | |
2502 | m_iCallbackPtr = g_unmanagedCallbacks.size() - 1; | |
2503 | m_bDelegatesCreated = true; | |
11fea069 LOK |
2504 | } |
2505 | } | |
2506 | ||
f9717bcc LOK |
2507 | CecLogMessageManagedDelegate ^ m_logMessageDelegate; |
2508 | static System::Runtime::InteropServices::GCHandle m_logMessageGCHandle; | |
2509 | LOGCB m_logMessageCallback; | |
4ef3b314 | 2510 | |
f9717bcc LOK |
2511 | CecKeyPressManagedDelegate ^ m_keypressDelegate; |
2512 | static System::Runtime::InteropServices::GCHandle m_keypressGCHandle; | |
2513 | KEYCB m_keypressCallback; | |
4ef3b314 | 2514 | |
f9717bcc LOK |
2515 | CecCommandManagedDelegate ^ m_commandDelegate; |
2516 | static System::Runtime::InteropServices::GCHandle m_commandGCHandle; | |
2517 | COMMANDCB m_commandCallback; | |
4ef3b314 | 2518 | |
f9717bcc LOK |
2519 | CecConfigManagedDelegate ^ m_configDelegate; |
2520 | static System::Runtime::InteropServices::GCHandle m_configGCHandle; | |
2521 | CONFIGCB m_configCallback; | |
32403cc3 | 2522 | |
f9717bcc LOK |
2523 | CecAlertManagedDelegate ^ m_alertDelegate; |
2524 | static System::Runtime::InteropServices::GCHandle m_alertGCHandle; | |
2525 | ALERTCB m_alertCallback; | |
5ee37222 | 2526 | |
f9717bcc LOK |
2527 | CecMenuManagedDelegate ^ m_menuDelegate; |
2528 | static System::Runtime::InteropServices::GCHandle m_menuGCHandle; | |
2529 | MENUCB m_menuCallback; | |
c3a20edb | 2530 | |
f9717bcc LOK |
2531 | CecSourceActivatedManagedDelegate ^ m_sourceActivatedDelegate; |
2532 | static System::Runtime::InteropServices::GCHandle m_sourceActivatedGCHandle; | |
2533 | ACTICB m_sourceActivatedCallback; | |
29d5198c | 2534 | |
f9717bcc LOK |
2535 | CecCallbackMethods ^ m_callbacks; |
2536 | bool m_bHasCallbacks; | |
11fea069 | 2537 | bool m_bDelegatesCreated; |
f9717bcc LOK |
2538 | size_t m_iCallbackPtr; |
2539 | }; | |
4ef3b314 | 2540 | } |