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