more missing docs
[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
920 /// </summary>
f9717bcc 921 GetMenuLanguage = 0x91,
8438c41f
LOK
922 /// <summary>
923 /// Report the physical address
924 /// </summary>
f9717bcc 925 ReportPhysicalAddress = 0x84,
8438c41f
LOK
926 /// <summary>
927 /// Report the language code of the menu language
928 /// </summary>
f9717bcc 929 SetMenuLanguage = 0x32,
8438c41f
LOK
930 /// <summary>
931 /// Deck control for playback and recording devices
932 /// </summary>
f9717bcc 933 DeckControl = 0x42,
8438c41f
LOK
934 /// <summary>
935 /// Deck status for playback and recording devices
936 /// </summary>
f9717bcc 937 DeckStatus = 0x1B,
8438c41f
LOK
938 /// <summary>
939 /// Request deck status from playback and recording devices
940 /// </summary>
f9717bcc 941 GiveDeckStatus = 0x1A,
8438c41f
LOK
942 /// <summary>
943 /// Start playback on playback and recording devices
944 /// </summary>
f9717bcc 945 Play = 0x41,
8438c41f
LOK
946 /// <summary>
947 /// Request tuner status
948 /// </summary>
f9717bcc 949 GiveTunerDeviceStatus = 0x08,
8438c41f
LOK
950 /// <summary>
951 /// Select analogue service on a tuner
952 /// </summary>
f9717bcc 953 SelectAnalogueService = 0x92,
8438c41f
LOK
954 /// <summary>
955 /// Select digital service on a tuner
956 /// </summary>
f9717bcc 957 SelectDigtalService = 0x93,
8438c41f
LOK
958 /// <summary>
959 /// Report tuner device status
960 /// </summary>
f9717bcc 961 TunerDeviceStatus = 0x07,
8438c41f
LOK
962 /// <summary>
963 /// Tuner step decrement
964 /// </summary>
f9717bcc 965 TunerStepDecrement = 0x06,
8438c41f
LOK
966 /// <summary>
967 /// Tuner step increment
968 /// </summary>
f9717bcc 969 TunerStepIncrement = 0x05,
8438c41f
LOK
970 /// <summary>
971 /// Report device vendor ID
972 /// </summary>
f9717bcc 973 DeviceVendorId = 0x87,
8438c41f
LOK
974 /// <summary>
975 /// Request device vendor ID
976 /// </summary>
f9717bcc 977 GiveDeviceVendorId = 0x8C,
8438c41f
LOK
978 /// <summary>
979 /// Vendor specific command
980 /// </summary>
f9717bcc 981 VendorCommand = 0x89,
8438c41f
LOK
982 /// <summary>
983 /// Vendor specific command with vendor ID
984 /// </summary>
f9717bcc 985 VendorCommandWithId = 0xA0,
8438c41f
LOK
986 /// <summary>
987 /// Vendor specific remote button pressed
988 /// </summary>
f9717bcc 989 VendorRemoteButtonDown = 0x8A,
8438c41f
LOK
990 /// <summary>
991 /// Vendor specific remote button released
992 /// </summary>
f9717bcc 993 VendorRemoteButtonUp = 0x8B,
8438c41f
LOK
994 /// <summary>
995 /// Display / clear OSD string
996 /// </summary>
f9717bcc 997 SetOsdString = 0x64,
8438c41f
LOK
998 /// <summary>
999 /// Request device OSD name
1000 /// </summary>
f9717bcc 1001 GiveOsdName = 0x46,
8438c41f
LOK
1002 /// <summary>
1003 /// Report device OSD name
1004 /// </summary>
f9717bcc 1005 SetOsdName = 0x47,
8438c41f
LOK
1006 /// <summary>
1007 /// Request device menu status
1008 /// </summary>
f9717bcc 1009 MenuRequest = 0x8D,
8438c41f
LOK
1010 /// <summary>
1011 /// Report device menu status
1012 /// </summary>
f9717bcc 1013 MenuStatus = 0x8E,
8438c41f
LOK
1014 /// <summary>
1015 /// Remote button pressed
1016 /// </summary>
f9717bcc 1017 UserControlPressed = 0x44,
8438c41f
LOK
1018 /// <summary>
1019 /// Remote button released
1020 /// </summary>
f9717bcc 1021 UserControlRelease = 0x45,
8438c41f
LOK
1022 /// <summary>
1023 /// Request device power status
1024 /// </summary>
f9717bcc 1025 GiveDevicePowerStatus = 0x8F,
8438c41f
LOK
1026 /// <summary>
1027 /// Report device power status
1028 /// </summary>
f9717bcc 1029 ReportPowerStatus = 0x90,
8438c41f
LOK
1030 /// <summary>
1031 /// Feature abort / unsupported command
1032 /// </summary>
f9717bcc 1033 FeatureAbort = 0x00,
8438c41f
LOK
1034 /// <summary>
1035 /// Abort command
1036 /// </summary>
f9717bcc 1037 Abort = 0xFF,
8438c41f
LOK
1038 /// <summary>
1039 /// Give audio status
1040 /// </summary>
f9717bcc 1041 GiveAudioStatus = 0x71,
8438c41f
LOK
1042 /// <summary>
1043 /// Give audiosystem mode
1044 /// </summary>
f9717bcc 1045 GiveSystemAudioMode = 0x7D,
8438c41f
LOK
1046 /// <summary>
1047 /// Report device audio status
1048 /// </summary>
f9717bcc 1049 ReportAudioStatus = 0x7A,
8438c41f
LOK
1050 /// <summary>
1051 /// Set audiosystem mode
1052 /// </summary>
f9717bcc 1053 SetSystemAudioMode = 0x72,
8438c41f
LOK
1054 /// <summary>
1055 /// Request audiosystem mode
1056 /// </summary>
f9717bcc 1057 SystemAudioModeRequest = 0x70,
8438c41f
LOK
1058 /// <summary>
1059 /// Report audiosystem mode
1060 /// </summary>
f9717bcc 1061 SystemAudioModeStatus = 0x7E,
8438c41f
LOK
1062 /// <summary>
1063 /// Set audio bitrate
1064 /// </summary>
f9717bcc 1065 SetAudioRate = 0x9A,
8438c41f
LOK
1066 /// <summary>
1067 /// When this opcode is set, no opcode will be sent to the device / poll message
1068 /// This is one of the reserved numbers
1069 /// </summary>
f9717bcc
LOK
1070 None = 0xFD
1071 };
1072
8438c41f
LOK
1073 /// <summary>
1074 /// Audiosystem status
1075 /// </summary>
f9717bcc
LOK
1076 public enum class CecSystemAudioStatus
1077 {
8438c41f
LOK
1078 /// <summary>
1079 /// Turned off
1080 /// </summary>
f9717bcc 1081 Off = 0,
8438c41f
LOK
1082 /// <summary>
1083 /// Turned on
1084 /// </summary>
f9717bcc
LOK
1085 On = 1
1086 };
1087
8438c41f
LOK
1088 /// <summary>
1089 /// libCEC client application version
1090 /// </summary>
f9717bcc
LOK
1091 public enum class CecClientVersion
1092 {
8438c41f
LOK
1093 /// <summary>
1094 /// before v1.5.0
1095 /// </summary>
f9717bcc 1096 VersionPre1_5 = 0,
8438c41f
LOK
1097 /// <summary>
1098 /// v1.5.0
1099 /// </summary>
f9717bcc 1100 Version1_5_0 = 0x1500,
8438c41f
LOK
1101 /// <summary>
1102 /// v1.5.1
1103 /// </summary>
f9717bcc 1104 Version1_5_1 = 0x1501,
8438c41f
LOK
1105 /// <summary>
1106 /// v1.5.2
1107 /// </summary>
f9717bcc 1108 Version1_5_2 = 0x1502,
8438c41f
LOK
1109 /// <summary>
1110 /// v1.5.3
1111 /// </summary>
f9717bcc 1112 Version1_5_3 = 0x1503,
8438c41f
LOK
1113 /// <summary>
1114 /// v1.6.0
1115 /// </summary>
f9717bcc 1116 Version1_6_0 = 0x1600,
8438c41f
LOK
1117 /// <summary>
1118 /// v1.6.1
1119 /// </summary>
f9717bcc 1120 Version1_6_1 = 0x1601,
8438c41f
LOK
1121 /// <summary>
1122 /// v1.6.2
1123 /// </summary>
f9717bcc 1124 Version1_6_2 = 0x1602,
8438c41f
LOK
1125 /// <summary>
1126 /// v1.6.3
1127 /// </summary>
f9717bcc 1128 Version1_6_3 = 0x1603,
8438c41f
LOK
1129 /// <summary>
1130 /// v1.7.0
1131 /// </summary>
f9717bcc 1132 Version1_7_0 = 0x1700,
8438c41f
LOK
1133 /// <summary>
1134 /// v1.7.1
1135 /// </summary>
f9717bcc 1136 Version1_7_1 = 0x1701,
8438c41f
LOK
1137 /// <summary>
1138 /// v1.7.2
1139 /// </summary>
f9717bcc 1140 Version1_7_2 = 0x1702,
8438c41f
LOK
1141 /// <summary>
1142 /// v1.8.0
1143 /// </summary>
f9717bcc 1144 Version1_8_0 = 0x1800,
8438c41f
LOK
1145 /// <summary>
1146 /// v1.8.1
1147 /// </summary>
f9717bcc 1148 Version1_8_1 = 0x1801,
8438c41f
LOK
1149 /// <summary>
1150 /// v1.8.2
1151 /// </summary>
f9717bcc 1152 Version1_8_2 = 0x1802,
8438c41f
LOK
1153 /// <summary>
1154 /// v1.9.0
1155 /// </summary>
f9717bcc
LOK
1156 Version1_9_0 = 0x1900
1157 };
1158
8438c41f
LOK
1159 /// <summary>
1160 /// libCEC version
1161 /// </summary>
f9717bcc
LOK
1162 public enum class CecServerVersion
1163 {
8438c41f
LOK
1164 /// <summary>
1165 /// before v1.5.0
1166 /// </summary>
f9717bcc 1167 VersionPre1_5 = 0,
8438c41f
LOK
1168 /// <summary>
1169 /// v1.5.0
1170 /// </summary>
f9717bcc 1171 Version1_5_0 = 0x1500,
8438c41f
LOK
1172 /// <summary>
1173 /// v1.5.1
1174 /// </summary>
f9717bcc 1175 Version1_5_1 = 0x1501,
8438c41f
LOK
1176 /// <summary>
1177 /// v1.5.2
1178 /// </summary>
f9717bcc 1179 Version1_5_2 = 0x1502,
8438c41f
LOK
1180 /// <summary>
1181 /// v1.5.3
1182 /// </summary>
f9717bcc 1183 Version1_5_3 = 0x1503,
8438c41f
LOK
1184 /// <summary>
1185 /// v1.6.0
1186 /// </summary>
f9717bcc 1187 Version1_6_0 = 0x1600,
8438c41f
LOK
1188 /// <summary>
1189 /// v1.6.1
1190 /// </summary>
f9717bcc 1191 Version1_6_1 = 0x1601,
8438c41f
LOK
1192 /// <summary>
1193 /// v1.6.2
1194 /// </summary>
f9717bcc 1195 Version1_6_2 = 0x1602,
8438c41f
LOK
1196 /// <summary>
1197 /// v1.6.3
1198 /// </summary>
f9717bcc 1199 Version1_6_3 = 0x1603,
8438c41f
LOK
1200 /// <summary>
1201 /// v1.7.0
1202 /// </summary>
f9717bcc 1203 Version1_7_0 = 0x1700,
8438c41f
LOK
1204 /// <summary>
1205 /// v1.7.1
1206 /// </summary>
f9717bcc 1207 Version1_7_1 = 0x1701,
8438c41f
LOK
1208 /// <summary>
1209 /// v1.7.2
1210 /// </summary>
f9717bcc 1211 Version1_7_2 = 0x1702,
8438c41f
LOK
1212 /// <summary>
1213 /// v1.8.0
1214 /// </summary>
f9717bcc 1215 Version1_8_0 = 0x1800,
8438c41f
LOK
1216 /// <summary>
1217 /// v1.8.1
1218 /// </summary>
f9717bcc 1219 Version1_8_1 = 0x1801,
8438c41f
LOK
1220 /// <summary>
1221 /// v1.8.2
1222 /// </summary>
f9717bcc 1223 Version1_8_2 = 0x1802,
8438c41f
LOK
1224 /// <summary>
1225 /// v1.9.0
1226 /// </summary>
f9717bcc
LOK
1227 Version1_9_0 = 0x1900
1228 };
1229
8438c41f
LOK
1230 /// <summary>
1231 /// Type of adapter to which libCEC is connected
1232 /// </summary>
22190f06
LOK
1233 public enum class CecAdapterType
1234 {
8438c41f
LOK
1235 /// <summary>
1236 /// Unknown adapter type
1237 /// </summary>
22190f06 1238 Unknown = 0,
8438c41f
LOK
1239 /// <summary>
1240 /// Pulse-Eight USB-CEC adapter
1241 /// </summary>
22190f06 1242 PulseEightExternal = 0x1,
8438c41f
LOK
1243 /// <summary>
1244 /// Pulse-Eight CEC daughterboard
1245 /// </summary>
22190f06 1246 PulseEightDaughterboard = 0x2,
8438c41f
LOK
1247 /// <summary>
1248 /// Raspberry Pi
1249 /// </summary>
22190f06
LOK
1250 RaspberryPi = 0x100
1251 };
1252
f9717bcc 1253 /// <summary>
8438c41f 1254 /// Descriptor of a CEC adapter, returned when scanning for adapters that are connected to the system
f9717bcc
LOK
1255 /// </summary>
1256 public ref class CecAdapter
1257 {
1258 public:
1259 /// <summary>
1260 /// Create a new CEC adapter descriptor
1261 /// </summary>
1262 /// <param name="path"> The path descriptor for this CEC adapter</param>
1263 /// <param name="comPort">The COM port of this CEC adapter</param>
1264 CecAdapter(System::String ^ path, System::String ^ comPort)
1265 {
1266 Path = path;
1267 ComPort = comPort;
1268 }
1269
1270 /// <summary>
1271 /// The path descriptor for this CEC adapter
1272 /// </summary>
1273 property System::String ^ Path;
1274
1275 /// <summary>
1276 /// The COM port of this CEC adapter
1277 /// </summary>
1278 property System::String ^ ComPort;
1279 };
1280
1281 /// <summary>
1282 /// A list of CEC device types
1283 /// </summary>
1284 public ref class CecDeviceTypeList
1285 {
1286 public:
1287 /// <summary>
1288 /// Create a new empty list of CEC device types
1289 /// </summary>
1290 CecDeviceTypeList(void)
1291 {
1292 Types = gcnew array<CecDeviceType>(5);
1293 for (unsigned int iPtr = 0; iPtr < 5; iPtr++)
1294 Types[iPtr] = CecDeviceType::Reserved;
1295 }
1296
1297 /// <summary>
1298 /// The array with CecDeviceType instances in this list.
1299 /// </summary>
1300 property array<CecDeviceType> ^ Types;
1301 };
1302
1303 /// <summary>
1304 /// A list of logical addresses
1305 /// </summary>
1306 public ref class CecLogicalAddresses
1307 {
1308 public:
1309 /// <summary>
1310 /// Create a new empty list of logical addresses
1311 /// </summary>
1312 CecLogicalAddresses(void)
1313 {
1314 Addresses = gcnew array<CecLogicalAddress>(16);
1315 Clear();
1316 }
1317
1318 /// <summary>
1319 /// Clears this list
1320 /// </summary>
1321 void Clear(void)
1322 {
1323 Primary = CecLogicalAddress::Unknown;
1324 for (unsigned int iPtr = 0; iPtr < 16; iPtr++)
1325 Addresses[iPtr] = CecLogicalAddress::Unknown;
1326 }
1327
1328 /// <summary>
1329 /// Checks whether a logical address is set in this list.
1330 /// </summary>
1331 /// <param name="address">The address to check.</param>
1332 /// <returns>True when set, false otherwise</returns>
1333 bool IsSet(CecLogicalAddress address)
1334 {
1335 return Addresses[(unsigned int)address] != CecLogicalAddress::Unknown;
1336 }
1337
1338 /// <summary>
1339 /// Add a logical address to this list (if it's not set already)
1340 /// </summary>
1341 /// <param name="address">The address to add.</param>
1342 void Set(CecLogicalAddress address)
1343 {
1344 Addresses[(unsigned int)address] = address;
1345 if (Primary == CecLogicalAddress::Unknown)
1346 Primary = address;
1347 }
1348
1349 /// <summary>
1350 /// The primary (first) address in this list
1351 /// </summary>
1352 property CecLogicalAddress Primary;
1353
1354 /// <summary>
1355 /// The list of addresses
1356 /// </summary>
1357 property array<CecLogicalAddress> ^ Addresses;
1358 };
1359
1360
1361 /// <summary>
1362 /// Byte array used for CEC command parameters
1363 /// </summary>
1364 public ref class CecDatapacket
1365 {
1366 public:
1367 /// <summary>
1368 /// Create a new byte array with maximum size 100
1369 /// </summary>
1370 CecDatapacket(void)
1371 {
1372 Data = gcnew array<uint8_t>(100);
1373 Size = 0;
1374 }
1375
1376 /// <summary>
1377 /// Adds a byte to this byte array
1378 /// </summary>
1379 /// <param name="data">The byte to add.</param>
1380 void PushBack(uint8_t data)
1381 {
1382 if (Size < 100)
1383 {
1384 Data[Size] = data;
1385 Size++;
1386 }
1387 }
1388
1389 /// <summary>
1390 /// Array data
1391 /// </summary>
1392 property array<uint8_t> ^ Data;
1393
1394 /// <summary>
1395 /// Current data size
1396 /// </summary>
1397 property uint8_t Size;
1398 };
1399
1400 /// <summary>
1401 /// A CEC command that is received or transmitted over the CEC bus
1402 /// </summary>
1403 public ref class CecCommand
1404 {
1405 public:
1406 /// <summary>
1407 /// Create a new CEC command instance
1408 /// </summary>
1409 /// <param name="initiator">The initiator of the command</param>
1410 /// <param name="destination">The receiver of the command</param>
1411 /// <param name="ack">True when the ack bit is set, false otherwise</param>
1412 /// <param name="eom">True when the eom bit is set, false otherwise</param>
1413 /// <param name="opcode">The CEC opcode of this command</param>
1414 /// <param name="transmitTimeout">The timeout to use when transmitting a command</param>
1415 CecCommand(CecLogicalAddress initiator, CecLogicalAddress destination, bool ack, bool eom, CecOpcode opcode, int32_t transmitTimeout)
1416 {
1417 Initiator = initiator;
1418 Destination = destination;
1419 Ack = ack;
1420 Eom = eom;
1421 Opcode = opcode;
1422 OpcodeSet = true;
1423 TransmitTimeout = transmitTimeout;
1424 Parameters = gcnew CecDatapacket;
1425 Empty = false;
1426 }
1427
1428 /// <summary>
1429 /// Create a new empty CEC command instance
1430 /// </summary>
1431 CecCommand(void)
1432 {
1433 Initiator = CecLogicalAddress::Unknown;
1434 Destination = CecLogicalAddress::Unknown;
1435 Ack = false;
1436 Eom = false;
1437 Opcode = CecOpcode::None;
1438 OpcodeSet = false;
1439 TransmitTimeout = 0;
1440 Parameters = gcnew CecDatapacket;
1441 Empty = true;
1442 }
1443
1444 /// <summary>
1445 /// Pushes a byte of data to this CEC command
1446 /// </summary>
1447 /// <param name="data">The byte to add</param>
1448 void PushBack(uint8_t data)
1449 {
1450 if (Initiator == CecLogicalAddress::Unknown && Destination == CecLogicalAddress::Unknown)
1451 {
1452 Initiator = (CecLogicalAddress) (data >> 4);
1453 Destination = (CecLogicalAddress) (data & 0xF);
1454 }
1455 else if (!OpcodeSet)
1456 {
1457 OpcodeSet = true;
1458 Opcode = (CecOpcode)data;
1459 }
1460 else
1461 {
1462 Parameters->PushBack(data);
1463 }
1464 }
1465
1466 /// <summary>
1467 /// True when this command is empty, false otherwise.
1468 /// </summary>
1469 property bool Empty;
1470 /// <summary>
1471 /// The initiator of the command
1472 /// </summary>
1473 property CecLogicalAddress Initiator;
1474 /// <summary>
1475 /// The destination of the command
1476 /// </summary>
1477 property CecLogicalAddress Destination;
1478 /// <summary>
1479 /// True when the ack bit is set, false otherwise
1480 /// </summary>
1481 property bool Ack;
1482 /// <summary>
1483 /// True when the eom bit is set, false otherwise
1484 /// </summary>
1485 property bool Eom;
1486 /// <summary>
1487 /// The CEC opcode of the command
1488 /// </summary>
1489 property CecOpcode Opcode;
1490 /// <summary>
1491 /// The parameters of this command
1492 /// </summary>
1493 property CecDatapacket ^ Parameters;
1494 /// <summary>
1495 /// True when an opcode is set, false otherwise (poll message)
1496 /// </summary>
1497 property bool OpcodeSet;
1498 /// <summary>
1499 /// The timeout to use when transmitting a command
1500 /// </summary>
1501 property int32_t TransmitTimeout;
1502 };
1503
1504 /// <summary>
1505 /// A key press that was received
1506 /// </summary>
1507 public ref class CecKeypress
1508 {
1509 public:
1510 /// <summary>
1511 /// Create a new key press instance
1512 /// </summary>
1513 /// <param name="keycode">The key code of this key press</param>
1514 /// <param name="duration">The duration of this key press in milliseconds</param>
1515 CecKeypress(CecUserControlCode keycode, unsigned int duration)
1516 {
1517 Keycode = keycode;
1518 Duration = duration;
1519 Empty = false;
1520 }
1521
1522 /// <summary>
1523 /// Create a new empty key press instance
1524 /// </summary>
1525 CecKeypress(void)
1526 {
1527 Keycode = CecUserControlCode::Unknown;
1528 Duration = 0;
1529 Empty = true;
1530 }
1531
1532 /// <summary>
1533 /// True when empty, false otherwise
1534 /// </summary>
1535 property bool Empty;
1536 /// <summary>
1537 /// The key code of this key press
1538 /// </summary>
1539 property CecUserControlCode Keycode;
1540 /// <summary>
1541 /// The duration of this key press in milliseconds
1542 /// </summary>
1543 property unsigned int Duration;
1544 };
1545
1546 /// <summary>
1547 /// A log message that libCEC generated
1548 /// </summary>
1549 public ref class CecLogMessage
1550 {
1551 public:
1552 /// <summary>
1553 /// Create a new log message
1554 /// </summary>
1555 /// <param name="message">The actual message</param>
1556 /// <param name="level">The log level, so the application can choose what type information to display</param>
1557 /// <param name="time">The timestamp of this message, in milliseconds after connecting</param>
1558 CecLogMessage(System::String ^ message, CecLogLevel level, int64_t time)
1559 {
1560 Message = message;
1561 Level = level;
1562 Time = time;
1563 Empty = false;
1564 }
1565
1566 /// <summary>
1567 /// Create a new empty log message
1568 /// </summary>
1569 CecLogMessage(void)
1570 {
1571 Message = "";
1572 Level = CecLogLevel::None;
1573 Time = 0;
1574 Empty = true;
1575 }
1576
1577 /// <summary>
1578 /// True when empty, false otherwise.
1579 /// </summary>
1580 property bool Empty;
1581 /// <summary>
1582 /// The actual message
1583 /// </summary>
1584 property System::String ^Message;
1585 /// <summary>
1586 /// The log level, so the application can choose what type information to display
1587 /// </summary>
1588 property CecLogLevel Level;
1589 /// <summary>
1590 /// The timestamp of this message, in milliseconds after connecting
1591 /// </summary>
1592 property int64_t Time;
1593 };
1594
1595 ref class CecCallbackMethods; //forward declaration
1596
1597 /// <summary>
1598 /// The configuration that libCEC uses.
1599 /// </summary>
1600 public ref class LibCECConfiguration
1601 {
1602 public:
1603 /// <summary>
1604 /// Create a new configuration instance with default settings.
1605 /// </summary>
1606 LibCECConfiguration(void)
1607 {
1608 DeviceName = "";
1609 DeviceTypes = gcnew CecDeviceTypeList();
1610 AutodetectAddress = true;
1611 PhysicalAddress = CEC_DEFAULT_PHYSICAL_ADDRESS;
1612 BaseDevice = (CecLogicalAddress)CEC_DEFAULT_BASE_DEVICE;
1613 HDMIPort = CEC_DEFAULT_HDMI_PORT;
1614 ClientVersion = CecClientVersion::VersionPre1_5;
1615 ServerVersion = CecServerVersion::VersionPre1_5;
1616 TvVendor = CecVendorId::Unknown;
1617
1618 GetSettingsFromROM = false;
1619 UseTVMenuLanguage = CEC_DEFAULT_SETTING_USE_TV_MENU_LANGUAGE == 1;
1620 ActivateSource = CEC_DEFAULT_SETTING_ACTIVATE_SOURCE == 1;
1621
1622 WakeDevices = gcnew CecLogicalAddresses();
1623 if (CEC_DEFAULT_SETTING_ACTIVATE_SOURCE == 1)
1624 WakeDevices->Set(CecLogicalAddress::Tv);
1625
1626 PowerOffDevices = gcnew CecLogicalAddresses();
1627 if (CEC_DEFAULT_SETTING_POWER_OFF_SHUTDOWN == 1)
1628 PowerOffDevices->Set(CecLogicalAddress::Broadcast);
1629
1630 PowerOffScreensaver = CEC_DEFAULT_SETTING_POWER_OFF_SCREENSAVER == 1;
1631 PowerOffOnStandby = CEC_DEFAULT_SETTING_POWER_OFF_ON_STANDBY == 1;
1632
1633 SendInactiveSource = CEC_DEFAULT_SETTING_SEND_INACTIVE_SOURCE == 1;
1634 LogicalAddresses = gcnew CecLogicalAddresses();
1635 FirmwareVersion = 1;
1636 PowerOffDevicesOnStandby = CEC_DEFAULT_SETTING_POWER_OFF_DEVICES_STANDBY == 1;
1637 ShutdownOnStandby = CEC_DEFAULT_SETTING_SHUTDOWN_ON_STANDBY == 1;
1638 DeviceLanguage = "";
22190f06
LOK
1639 FirmwareBuildDate = gcnew System::DateTime(1970,1,1,0,0,0,0);
1640 CECVersion = (CecVersion)CEC_DEFAULT_SETTING_CEC_VERSION;
1641 AdapterType = CecAdapterType::Unknown;
f9717bcc
LOK
1642 }
1643
1644 /// <summary>
1645 /// Change the callback method pointers in this configuration instance.
1646 /// </summary>
1647 /// <param name="callbacks">The new callbacks</param>
1648 void SetCallbacks(CecCallbackMethods ^callbacks)
1649 {
1650 Callbacks = callbacks;
1651 }
1652
1653 /// <summary>
1654 /// Update this configuration with data received from libCEC
1655 /// </summary>
1656 /// <param name="config">The configuration that was received from libCEC</param>
1657 void Update(const CEC::libcec_configuration &config)
1658 {
1659 DeviceName = gcnew System::String(config.strDeviceName);
1660
1661 for (unsigned int iPtr = 0; iPtr < 5; iPtr++)
1662 DeviceTypes->Types[iPtr] = (CecDeviceType)config.deviceTypes.types[iPtr];
1663
1664 AutodetectAddress = config.bAutodetectAddress == 1;
1665 PhysicalAddress = config.iPhysicalAddress;
1666 BaseDevice = (CecLogicalAddress)config.baseDevice;
1667 HDMIPort = config.iHDMIPort;
1668 ClientVersion = (CecClientVersion)config.clientVersion;
1669 ServerVersion = (CecServerVersion)config.serverVersion;
1670 TvVendor = (CecVendorId)config.tvVendor;
1671
1672 // player specific settings
1673 GetSettingsFromROM = config.bGetSettingsFromROM == 1;
1674 UseTVMenuLanguage = config.bUseTVMenuLanguage == 1;
1675 ActivateSource = config.bActivateSource == 1;
1676
1677 WakeDevices->Clear();
1678 for (uint8_t iPtr = 0; iPtr <= 16; iPtr++)
1679 if (config.wakeDevices[iPtr])
1680 WakeDevices->Set((CecLogicalAddress)iPtr);
1681
1682 PowerOffDevices->Clear();
1683 for (uint8_t iPtr = 0; iPtr <= 16; iPtr++)
1684 if (config.powerOffDevices[iPtr])
1685 PowerOffDevices->Set((CecLogicalAddress)iPtr);
1686
1687 PowerOffScreensaver = config.bPowerOffScreensaver == 1;
1688 PowerOffOnStandby = config.bPowerOffOnStandby == 1;
1689
1690 if (ServerVersion >= CecServerVersion::Version1_5_1)
1691 SendInactiveSource = config.bSendInactiveSource == 1;
1692
1693 if (ServerVersion >= CecServerVersion::Version1_5_3)
1694 {
1695 LogicalAddresses->Clear();
1696 for (uint8_t iPtr = 0; iPtr <= 16; iPtr++)
1697 if (config.logicalAddresses[iPtr])
1698 LogicalAddresses->Set((CecLogicalAddress)iPtr);
1699 }
1700
1701 if (ServerVersion >= CecServerVersion::Version1_6_0)
1702 {
1703 FirmwareVersion = config.iFirmwareVersion;
1704 PowerOffDevicesOnStandby = config.bPowerOffDevicesOnStandby == 1;
1705 ShutdownOnStandby = config.bShutdownOnStandby == 1;
1706 }
1707
1708 if (ServerVersion >= CecServerVersion::Version1_6_2)
22190f06 1709 {
f9717bcc 1710 DeviceLanguage = gcnew System::String(config.strDeviceLanguage);
22190f06
LOK
1711 FirmwareBuildDate = gcnew System::DateTime(1970,1,1,0,0,0,0);
1712 FirmwareBuildDate = FirmwareBuildDate->AddSeconds(config.iFirmwareBuildDate);
1713 }
f9717bcc
LOK
1714
1715 if (ServerVersion >= CecServerVersion::Version1_6_3)
1716 MonitorOnlyClient = config.bMonitorOnly == 1;
22190f06
LOK
1717
1718 if (ServerVersion >= CecServerVersion::Version1_8_0)
1719 CECVersion = (CecVersion)config.cecVersion;
1720
1721 if (ServerVersion >= CecServerVersion::Version1_8_2)
1722 AdapterType = (CecAdapterType)config.adapterType;
f9717bcc
LOK
1723 }
1724
1725 /// <summary>
1726 /// The device name to use on the CEC bus
1727 /// </summary>
1728 property System::String ^ DeviceName;
1729
1730 /// <summary>
1731 /// The device type(s) to use on the CEC bus for libCEC
1732 /// </summary>
1733 property CecDeviceTypeList ^ DeviceTypes;
1734
1735 /// <summary>
1736 /// True to try to autodetect the physical address, false otherwise
1737 /// </summary>
1738 property bool AutodetectAddress;
1739
1740 /// <summary>
1741 /// The physical address that libCEC uses on the CEC bus
1742 /// </summary>
1743 property uint16_t PhysicalAddress;
1744
1745 /// <summary>
1746 /// The logical address of the device to which the CEC adapter is connected, only used when PhysicalAddress isn't set
1747 /// </summary>
1748 property CecLogicalAddress BaseDevice;
1749
1750 /// <summary>
1751 /// The hdmi port number on the device to which the CEC adapter is connected, only used when PhysicalAddress isn't set
1752 /// </summary>
1753 property uint8_t HDMIPort;
1754
1755 /// <summary>
1756 /// The client API version to use
1757 /// </summary>
1758 property CecClientVersion ClientVersion;
1759
1760 /// <summary>
1761 /// The version of libCEC
1762 /// </summary>
1763 property CecServerVersion ServerVersion;
1764
1765 /// <summary>
1766 /// Override the vendor ID of the TV when set (for quirks mode)
1767 /// </summary>
1768 property CecVendorId TvVendor;
1769
1770 /// <summary>
1771 /// True to read the settings from the EEPROM, which possibly override the settings passed here
1772 /// </summary>
1773 property bool GetSettingsFromROM;
1774
1775 /// <summary>
1776 /// Use the language setting of the TV in the client application. Must be implemented by the client application.
1777 /// </summary>
1778 property bool UseTVMenuLanguage;
1779
1780 /// <summary>
1781 /// Make libCEC the active source when starting the client application
1782 /// </summary>
1783 property bool ActivateSource;
1784
1785 /// <summary>
1786 /// List of devices to send a power on command to when starting the client application
1787 /// </summary>
1788 property CecLogicalAddresses ^WakeDevices;
1789
1790 /// <summary>
1791 /// List of devices to send a standby command to when exiting the client application
1792 /// </summary>
1793 property CecLogicalAddresses ^PowerOffDevices;
1794
1795 /// <summary>
1796 /// Send standby commands when the client application activates the screensaver. Must be implemented by the client application.
1797 /// </summary>
1798 property bool PowerOffScreensaver;
1799
1800 /// <summary>
1801 /// Power off the PC when the TV powers off. Must be implemented by the client application.
1802 /// </summary>
1803 property bool PowerOffOnStandby;
1804
1805 /// <summary>
1806 /// Send an inactive source message when exiting the client application.
1807 /// </summary>
1808 property bool SendInactiveSource;
1809
1810 /// <summary>
1811 /// The list of logical addresses that libCEC is using
1812 /// </summary>
1813 property CecLogicalAddresses ^LogicalAddresses;
1814
1815 /// <summary>
1816 /// The firmware version of the adapter to which libCEC is connected
1817 /// </summary>
1818 property uint16_t FirmwareVersion;
1819
1820 /// <summary>
1821 /// Send standby commands when the client application activates standby mode (S3). Must be implemented by the client application.
1822 /// </summary>
1823 property bool PowerOffDevicesOnStandby;
1824 property bool ShutdownOnStandby;
1825
1826 /// <summary>
1827 /// True to start a monitor-only client, false to start a standard client.
1828 /// </summary>
1829 property bool MonitorOnlyClient;
1830
1831 /// <summary>
1832 /// The language code of the menu language that libCEC reports to other devices.
1833 /// </summary>
1834 property System::String ^ DeviceLanguage;
1835
1836 /// <summary>
1837 /// The callback methods to use.
1838 /// </summary>
1839 property CecCallbackMethods ^ Callbacks;
22190f06
LOK
1840
1841 /// <summary>
1842 /// The build date of the firmware.
1843 /// </summary>
1844 property System::DateTime ^ FirmwareBuildDate;
1845
1846 /// <summary>
1847 /// The CEC version that libCEC uses.
1848 /// </summary>
1849 property CecVersion CECVersion;
1850
1851 /// <summary>
1852 /// The type of adapter that libCEC is connected to.
1853 /// </summary>
1854 property CecAdapterType AdapterType;
f9717bcc
LOK
1855 };
1856
1857 // the callback methods are called by unmanaged code, so we need some delegates for this
1858#pragma unmanaged
1859 // unmanaged callback methods
1860 typedef int (__stdcall *LOGCB) (const CEC::cec_log_message &message);
1861 typedef int (__stdcall *KEYCB) (const CEC::cec_keypress &key);
1862 typedef int (__stdcall *COMMANDCB)(const CEC::cec_command &command);
1863 typedef int (__stdcall *CONFIGCB) (const CEC::libcec_configuration &config);
1864 typedef int (__stdcall *ALERTCB) (const CEC::libcec_alert, const CEC::libcec_parameter &data);
1865 typedef int (__stdcall *MENUCB) (const CEC::cec_menu_state newVal);
1866 typedef void (__stdcall *ACTICB) (const CEC::cec_logical_address logicalAddress, const uint8_t bActivated);
1867
8438c41f
LOK
1868 /// <summary>
1869 /// libCEC callback methods. Unmanaged code.
1870 /// </summary>
f9717bcc
LOK
1871 typedef struct
1872 {
8438c41f
LOK
1873 /// <summary>
1874 /// Log message callback
1875 /// </summary>
f9717bcc 1876 LOGCB logCB;
8438c41f
LOK
1877 /// <summary>
1878 /// Key press/release callback
1879 /// </summary>
f9717bcc 1880 KEYCB keyCB;
8438c41f
LOK
1881 /// <summary>
1882 /// Raw CEC data callback
1883 /// </summary>
f9717bcc 1884 COMMANDCB commandCB;
8438c41f
LOK
1885 /// <summary>
1886 /// Updated configuration callback
1887 /// </summary>
f9717bcc 1888 CONFIGCB configCB;
8438c41f
LOK
1889 /// <summary>
1890 /// Alert message callback
1891 /// </summary>
f9717bcc 1892 ALERTCB alertCB;
8438c41f
LOK
1893 /// <summary>
1894 /// Menu status change callback
1895 /// </summary>
f9717bcc 1896 MENUCB menuCB;
8438c41f
LOK
1897 /// <summary>
1898 /// Source (de)activated callback
1899 /// </summary>
f9717bcc
LOK
1900 ACTICB sourceActivatedCB;
1901 } UnmanagedCecCallbacks;
1902
1903 static PLATFORM::CMutex g_callbackMutex;
1904 static std::vector<UnmanagedCecCallbacks> g_unmanagedCallbacks;
dc6366e8 1905 static CEC::ICECCallbacks g_cecCallbacks;
4ef3b314 1906
8438c41f
LOK
1907 /// <summary>
1908 /// Called by libCEC to send back a log message to the application
1909 /// </summary>
1910 /// <param name="cbParam">Pointer to the callback struct</param>
1911 /// <param name="message">The log message</param>
1912 /// <return>1 when handled, 0 otherwise</return>
f9717bcc
LOK
1913 int CecLogMessageCB(void *cbParam, const CEC::cec_log_message &message)
1914 {
1915 if (cbParam)
1916 {
1917 size_t iPtr = (size_t)cbParam;
1918 PLATFORM::CLockObject lock(g_callbackMutex);
1919 if (iPtr >= 0 && iPtr < g_unmanagedCallbacks.size())
1920 return g_unmanagedCallbacks[iPtr].logCB(message);
1921 }
1922 return 0;
1923 }
1924
8438c41f
LOK
1925 /// <summary>
1926 /// Called by libCEC to send back a key press or release to the application
1927 /// </summary>
1928 /// <param name="cbParam">Pointer to the callback struct</param>
1929 /// <param name="key">The key press command that libCEC received</param>
1930 /// <return>1 when handled, 0 otherwise</return>
f9717bcc
LOK
1931 int CecKeyPressCB(void *cbParam, const CEC::cec_keypress &key)
1932 {
1933 if (cbParam)
1934 {
1935 size_t iPtr = (size_t)cbParam;
1936 PLATFORM::CLockObject lock(g_callbackMutex);
1937 if (iPtr >= 0 && iPtr < g_unmanagedCallbacks.size())
1938 return g_unmanagedCallbacks[iPtr].keyCB(key);
1939 }
1940 return 0;
1941 }
1942
8438c41f
LOK
1943 /// <summary>
1944 /// Called by libCEC to send back raw CEC data to the application
1945 /// </summary>
1946 /// <param name="cbParam">Pointer to the callback struct</param>
1947 /// <param name="command">The raw CEC data</param>
1948 /// <return>1 when handled, 0 otherwise</return>
f9717bcc
LOK
1949 int CecCommandCB(void *cbParam, const CEC::cec_command &command)
1950 {
1951 if (cbParam)
1952 {
1953 size_t iPtr = (size_t)cbParam;
1954 PLATFORM::CLockObject lock(g_callbackMutex);
1955 if (iPtr >= 0 && iPtr < g_unmanagedCallbacks.size())
1956 return g_unmanagedCallbacks[iPtr].commandCB(command);
1957 }
1958 return 0;
1959 }
4ef3b314 1960
8438c41f
LOK
1961 /// <summary>
1962 /// Called by libCEC to send back an updated configuration to the application
1963 /// </summary>
1964 /// <param name="cbParam">Pointer to the callback struct</param>
1965 /// <param name="config">The new configuration</param>
1966 /// <return>1 when handled, 0 otherwise</return>
32403cc3 1967 int CecConfigCB(void *cbParam, const CEC::libcec_configuration &config)
f9717bcc
LOK
1968 {
1969 if (cbParam)
1970 {
1971 size_t iPtr = (size_t)cbParam;
1972 PLATFORM::CLockObject lock(g_callbackMutex);
1973 if (iPtr >= 0 && iPtr < g_unmanagedCallbacks.size())
1974 return g_unmanagedCallbacks[iPtr].configCB(config);
1975 }
1976 return 0;
1977 }
1978
8438c41f
LOK
1979 /// <summary>
1980 /// Called by libCEC to send back an alert message to the application
1981 /// </summary>
1982 /// <param name="cbParam">Pointer to the callback struct</param>
1983 /// <param name="data">The alert message</param>
1984 /// <return>1 when handled, 0 otherwise</return>
f9717bcc
LOK
1985 int CecAlertCB(void *cbParam, const CEC::libcec_alert alert, const CEC::libcec_parameter &data)
1986 {
1987 if (cbParam)
1988 {
1989 size_t iPtr = (size_t)cbParam;
1990 PLATFORM::CLockObject lock(g_callbackMutex);
1991 if (iPtr >= 0 && iPtr < g_unmanagedCallbacks.size())
1992 return g_unmanagedCallbacks[iPtr].alertCB(alert, data);
1993 }
1994 return 0;
1995 }
1996
8438c41f
LOK
1997 /// <summary>
1998 /// Called by libCEC to send back a menu state change to the application
1999 /// </summary>
2000 /// <param name="cbParam">Pointer to the callback struct</param>
2001 /// <param name="newVal">The new menu state</param>
2002 /// <return>1 when handled, 0 otherwise</return>
f9717bcc
LOK
2003 int CecMenuCB(void *cbParam, const CEC::cec_menu_state newVal)
2004 {
2005 if (cbParam)
2006 {
2007 size_t iPtr = (size_t)cbParam;
2008 PLATFORM::CLockObject lock(g_callbackMutex);
2009 if (iPtr >= 0 && iPtr < g_unmanagedCallbacks.size())
2010 return g_unmanagedCallbacks[iPtr].menuCB(newVal);
2011 }
2012 return 0;
2013 }
dc6366e8 2014
8438c41f
LOK
2015 /// <summary>
2016 /// Called by libCEC to notify the application that the source that is handled by libCEC was (de)activated
2017 /// </summary>
2018 /// <param name="cbParam">Pointer to the callback struct</param>
2019 /// <param name="logicalAddress">The logical address that was (de)activated</param>
2020 /// <param name="activated">True when activated, false when deactivated</param>
2021 void CecSourceActivatedCB(void *cbParam, const CEC::cec_logical_address logicalAddress, const uint8_t activated)
f9717bcc
LOK
2022 {
2023 if (cbParam)
2024 {
2025 size_t iPtr = (size_t)cbParam;
2026 PLATFORM::CLockObject lock(g_callbackMutex);
2027 if (iPtr >= 0 && iPtr < g_unmanagedCallbacks.size())
8438c41f 2028 g_unmanagedCallbacks[iPtr].sourceActivatedCB(logicalAddress, activated);
f9717bcc
LOK
2029 }
2030 }
2031
2032#pragma managed
1c7cd8f8
LOK
2033 /// <summary>
2034 /// Delegate method for the CecLogMessageCB callback in CecCallbackMethods
2035 /// </summary>
f9717bcc 2036 public delegate int CecLogMessageManagedDelegate(const CEC::cec_log_message &);
1c7cd8f8
LOK
2037 /// <summary>
2038 /// Delegate method for the CecKeyPressCB callback in CecCallbackMethods
2039 /// </summary>
f9717bcc 2040 public delegate int CecKeyPressManagedDelegate(const CEC::cec_keypress &);
1c7cd8f8
LOK
2041 /// <summary>
2042 /// Delegate method for the CecCommandCB callback in CecCallbackMethods
2043 /// </summary>
f9717bcc 2044 public delegate int CecCommandManagedDelegate(const CEC::cec_command &);
1c7cd8f8
LOK
2045 /// <summary>
2046 /// Delegate method for the CecConfigCB callback in CecCallbackMethods
2047 /// </summary>
f9717bcc 2048 public delegate int CecConfigManagedDelegate(const CEC::libcec_configuration &);
1c7cd8f8
LOK
2049 /// <summary>
2050 /// Delegate method for the CecAlertCB callback in CecCallbackMethods
2051 /// </summary>
f9717bcc 2052 public delegate int CecAlertManagedDelegate(const CEC::libcec_alert, const CEC::libcec_parameter &);
1c7cd8f8
LOK
2053 /// <summary>
2054 /// Delegate method for the CecMenuCB callback in CecCallbackMethods
2055 /// </summary>
2056 public delegate int CecMenuManagedDelegate(const CEC::cec_menu_state);
2057 /// <summary>
2058 /// Delegate method for the CecSourceActivatedCB callback in CecCallbackMethods
2059 /// </summary>
2060 public delegate void CecSourceActivatedManagedDelegate(const CEC::cec_logical_address, const uint8_t);
f9717bcc 2061
8438c41f
LOK
2062 /// <summary>
2063 /// Assign the callback methods in the g_cecCallbacks struct
2064 /// </summary>
f9717bcc
LOK
2065 void AssignCallbacks()
2066 {
2067 g_cecCallbacks.CBCecLogMessage = CecLogMessageCB;
2068 g_cecCallbacks.CBCecKeyPress = CecKeyPressCB;
2069 g_cecCallbacks.CBCecCommand = CecCommandCB;
2070 g_cecCallbacks.CBCecConfigurationChanged = CecConfigCB;
2071 g_cecCallbacks.CBCecAlert = CecAlertCB;
2072 g_cecCallbacks.CBCecMenuStateChanged = CecMenuCB;
2073 g_cecCallbacks.CBCecSourceActivated = CecSourceActivatedCB;
2074 }
2075
2076 /// <summary>
2077 /// The callback methods that libCEC uses
2078 /// </summary>
2079 public ref class CecCallbackMethods
2080 {
2081 public:
11fea069
LOK
2082 CecCallbackMethods(void)
2083 {
f9717bcc
LOK
2084 m_iCallbackPtr = -1;
2085 AssignCallbacks();
11fea069
LOK
2086 m_bHasCallbacks = false;
2087 m_bDelegatesCreated = false;
2088 }
4ef3b314 2089
f9717bcc 2090 ~CecCallbackMethods(void)
dc6366e8
LOK
2091 {
2092 DestroyDelegates();
2093 }
2094
8438c41f
LOK
2095 /// <summary>
2096 /// Pointer to the callbacks struct entry
2097 /// </summary>
f9717bcc
LOK
2098 size_t GetCallbackPtr(void)
2099 {
2100 PLATFORM::CLockObject lock(g_callbackMutex);
2101 return m_iCallbackPtr;
2102 }
2103
2104 protected:
2105 !CecCallbackMethods(void)
2106 {
2107 DestroyDelegates();
2108 }
2109
2110 public:
8438c41f
LOK
2111 /// <summary>
2112 /// Disable callback methods
2113 /// </summary>
f9717bcc
LOK
2114 virtual void DisableCallbacks(void)
2115 {
2116 DestroyDelegates();
2117 }
2118
8438c41f
LOK
2119 /// <summary>
2120 /// Enable callback methods
2121 /// </summary>
2122 /// <param name="callbacks">Callback methods to activate</param>
2123 /// <return>true when handled, false otherwise</return>
f9717bcc
LOK
2124 virtual bool EnableCallbacks(CecCallbackMethods ^ callbacks)
2125 {
11fea069 2126 CreateDelegates();
f9717bcc
LOK
2127 if (!m_bHasCallbacks)
2128 {
2129 m_bHasCallbacks = true;
2130 m_callbacks = callbacks;
2131 return true;
2132 }
2133
2134 return false;
2135 }
2136
2137 /// <summary>
8438c41f
LOK
2138 /// Called by libCEC to send back a log message to the application.
2139 /// Override in the application to handle this callback.
f9717bcc
LOK
2140 /// </summary>
2141 /// <param name="message">The log message</param>
8438c41f 2142 /// <return>1 when handled, 0 otherwise</return>
f9717bcc
LOK
2143 virtual int ReceiveLogMessage(CecLogMessage ^ message)
2144 {
2145 return 0;
2146 }
2147
2148 /// <summary>
8438c41f
LOK
2149 /// Called by libCEC to send back a key press or release to the application.
2150 /// Override in the application to handle this callback.
f9717bcc
LOK
2151 /// </summary>
2152 /// <param name="key">The key press command that libCEC received</param>
8438c41f 2153 /// <return>1 when handled, 0 otherwise</return>
f9717bcc
LOK
2154 virtual int ReceiveKeypress(CecKeypress ^ key)
2155 {
2156 return 0;
2157 }
2158
2159 /// <summary>
8438c41f
LOK
2160 /// Called by libCEC to send back raw CEC data to the application.
2161 /// Override in the application to handle this callback.
f9717bcc
LOK
2162 /// </summary>
2163 /// <param name="command">The raw CEC data</param>
8438c41f 2164 /// <return>1 when handled, 0 otherwise</return>
f9717bcc
LOK
2165 virtual int ReceiveCommand(CecCommand ^ command)
2166 {
2167 return 0;
2168 }
2169
2170 /// <summary>
8438c41f
LOK
2171 /// Called by libCEC to send back an updated configuration to the application.
2172 /// Override in the application to handle this callback.
f9717bcc
LOK
2173 /// </summary>
2174 /// <param name="config">The new configuration</param>
8438c41f 2175 /// <return>1 when handled, 0 otherwise</return>
f9717bcc
LOK
2176 virtual int ConfigurationChanged(LibCECConfiguration ^ config)
2177 {
2178 return 0;
2179 }
2180
2181 /// <summary>
8438c41f
LOK
2182 /// Called by libCEC to send back an alert message to the application.
2183 /// Override in the application to handle this callback.
f9717bcc
LOK
2184 /// </summary>
2185 /// <param name="data">The alert message</param>
8438c41f 2186 /// <return>1 when handled, 0 otherwise</return>
f9717bcc
LOK
2187 virtual int ReceiveAlert(CecAlert alert, CecParameter ^ data)
2188 {
2189 return 0;
2190 }
2191
2192 /// <summary>
8438c41f
LOK
2193 /// Called by libCEC to send back a menu state change to the application.
2194 /// Override in the application to handle this callback.
f9717bcc
LOK
2195 /// </summary>
2196 /// <param name="newVal">The new menu state</param>
8438c41f 2197 /// <return>1 when handled, 0 otherwise</return>
f9717bcc
LOK
2198 virtual int ReceiveMenuStateChange(CecMenuState newVal)
2199 {
2200 return 0;
2201 }
2202
2203 /// <summary>
8438c41f
LOK
2204 /// Called by libCEC to notify the application that the source that is handled by libCEC was (de)activated.
2205 /// Override in the application to handle this callback.
f9717bcc
LOK
2206 /// </summary>
2207 /// <param name="logicalAddress">The logical address that was (de)activated</param>
2208 /// <param name="activated">True when activated, false when deactivated</param>
2209 virtual void SourceActivated(CecLogicalAddress logicalAddress, bool activated)
2210 {
2211 }
2212
2213 protected:
2214 // managed callback methods
2215 int CecLogMessageManaged(const CEC::cec_log_message &message)
2216 {
2217 int iReturn(0);
2218 if (m_bHasCallbacks)
2219 iReturn = m_callbacks->ReceiveLogMessage(gcnew CecLogMessage(gcnew System::String(message.message), (CecLogLevel)message.level, message.time));
2220 return iReturn;
2221 }
2222
2223 int CecKeyPressManaged(const CEC::cec_keypress &key)
2224 {
2225 int iReturn(0);
2226 if (m_bHasCallbacks)
2227 iReturn = m_callbacks->ReceiveKeypress(gcnew CecKeypress((CecUserControlCode)key.keycode, key.duration));
2228 return iReturn;
2229 }
2230
2231 int CecCommandManaged(const CEC::cec_command &command)
2232 {
2233 int iReturn(0);
2234 if (m_bHasCallbacks)
2235 {
2236 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);
2237 for (uint8_t iPtr = 0; iPtr < command.parameters.size; iPtr++)
2238 newCommand->Parameters->PushBack(command.parameters[iPtr]);
2239 iReturn = m_callbacks->ReceiveCommand(newCommand);
2240 }
2241 return iReturn;
2242 }
2243
2244 int CecConfigManaged(const CEC::libcec_configuration &config)
2245 {
2246 int iReturn(0);
2247 if (m_bHasCallbacks)
2248 {
2249 LibCECConfiguration ^netConfig = gcnew LibCECConfiguration();
2250 netConfig->Update(config);
2251 iReturn = m_callbacks->ConfigurationChanged(netConfig);
2252 }
2253 return iReturn;
2254 }
2255
2256 int CecAlertManaged(const CEC::libcec_alert alert, const CEC::libcec_parameter &data)
2257 {
2258 int iReturn(0);
2259 if (m_bHasCallbacks)
2260 {
2261 CecParameterType newType = (CecParameterType)data.paramType;
2262 if (newType == CecParameterType::ParameterTypeString)
2263 {
2264 System::String ^ newData = gcnew System::String((const char *)data.paramData, 0, 128);
2265 CecParameter ^ newParam = gcnew CecParameter(newType, newData);
2266 iReturn = m_callbacks->ReceiveAlert((CecAlert)alert, newParam);
2267 }
2268 }
2269 return iReturn;
2270 }
2271
2272 int CecMenuManaged(const CEC::cec_menu_state newVal)
2273 {
2274 int iReturn(0);
2275 if (m_bHasCallbacks)
2276 {
2277 iReturn = m_callbacks->ReceiveMenuStateChange((CecMenuState)newVal);
2278 }
2279 return iReturn;
2280 }
2281
2282 void CecSourceActivatedManaged(const CEC::cec_logical_address logicalAddress, const uint8_t bActivated)
2283 {
2284 if (m_bHasCallbacks)
2285 m_callbacks->SourceActivated((CecLogicalAddress)logicalAddress, bActivated == 1);
2286 }
2287
2288 void DestroyDelegates()
2289 {
11fea069 2290 m_bHasCallbacks = false;
f9717bcc
LOK
2291 if (m_bDelegatesCreated)
2292 {
11fea069 2293 m_bDelegatesCreated = false;
f9717bcc
LOK
2294 m_logMessageGCHandle.Free();
2295 m_keypressGCHandle.Free();
2296 m_commandGCHandle.Free();
2297 m_alertGCHandle.Free();
2298 m_menuGCHandle.Free();
2299 m_sourceActivatedGCHandle.Free();
2300 }
2301 }
4ef3b314 2302
11fea069
LOK
2303 void CreateDelegates()
2304 {
2305 DestroyDelegates();
2306
2307 if (!m_bDelegatesCreated)
2308 {
2309 msclr::interop::marshal_context ^ context = gcnew msclr::interop::marshal_context();
2310
2311 // create the delegate method for the log message callback
dc6366e8
LOK
2312 m_logMessageDelegate = gcnew CecLogMessageManagedDelegate(this, &CecCallbackMethods::CecLogMessageManaged);
2313 m_logMessageGCHandle = System::Runtime::InteropServices::GCHandle::Alloc(m_logMessageDelegate);
f9717bcc 2314 m_logMessageCallback = static_cast<LOGCB>(System::Runtime::InteropServices::Marshal::GetFunctionPointerForDelegate(m_logMessageDelegate).ToPointer());
11fea069
LOK
2315
2316 // create the delegate method for the keypress callback
dc6366e8
LOK
2317 m_keypressDelegate = gcnew CecKeyPressManagedDelegate(this, &CecCallbackMethods::CecKeyPressManaged);
2318 m_keypressGCHandle = System::Runtime::InteropServices::GCHandle::Alloc(m_keypressDelegate);
f9717bcc 2319 m_keypressCallback = static_cast<KEYCB>(System::Runtime::InteropServices::Marshal::GetFunctionPointerForDelegate(m_keypressDelegate).ToPointer());
11fea069
LOK
2320
2321 // create the delegate method for the command callback
dc6366e8
LOK
2322 m_commandDelegate = gcnew CecCommandManagedDelegate(this, &CecCallbackMethods::CecCommandManaged);
2323 m_commandGCHandle = System::Runtime::InteropServices::GCHandle::Alloc(m_commandDelegate);
f9717bcc 2324 m_commandCallback = static_cast<COMMANDCB>(System::Runtime::InteropServices::Marshal::GetFunctionPointerForDelegate(m_commandDelegate).ToPointer());
11fea069
LOK
2325
2326 // create the delegate method for the configuration change callback
dc6366e8
LOK
2327 m_configDelegate = gcnew CecConfigManagedDelegate(this, &CecCallbackMethods::CecConfigManaged);
2328 m_configGCHandle = System::Runtime::InteropServices::GCHandle::Alloc(m_configDelegate);
f9717bcc 2329 m_configCallback = static_cast<CONFIGCB>(System::Runtime::InteropServices::Marshal::GetFunctionPointerForDelegate(m_configDelegate).ToPointer());
11fea069 2330
5ee37222 2331 // create the delegate method for the alert callback
dc6366e8
LOK
2332 m_alertDelegate = gcnew CecAlertManagedDelegate(this, &CecCallbackMethods::CecAlertManaged);
2333 m_alertGCHandle = System::Runtime::InteropServices::GCHandle::Alloc(m_alertDelegate);
f9717bcc 2334 m_alertCallback = static_cast<ALERTCB>(System::Runtime::InteropServices::Marshal::GetFunctionPointerForDelegate(m_alertDelegate).ToPointer());
5ee37222 2335
c3a20edb 2336 // create the delegate method for the menu callback
dc6366e8
LOK
2337 m_menuDelegate = gcnew CecMenuManagedDelegate(this, &CecCallbackMethods::CecMenuManaged);
2338 m_menuGCHandle = System::Runtime::InteropServices::GCHandle::Alloc(m_menuDelegate);
f9717bcc 2339 m_menuCallback = static_cast<MENUCB>(System::Runtime::InteropServices::Marshal::GetFunctionPointerForDelegate(m_menuDelegate).ToPointer());
c3a20edb 2340
f9717bcc 2341 // create the delegate method for the source activated callback
dc6366e8
LOK
2342 m_sourceActivatedDelegate = gcnew CecSourceActivatedManagedDelegate(this, &CecCallbackMethods::CecSourceActivatedManaged);
2343 m_sourceActivatedGCHandle = System::Runtime::InteropServices::GCHandle::Alloc(m_sourceActivatedDelegate);
f9717bcc 2344 m_sourceActivatedCallback = static_cast<ACTICB>(System::Runtime::InteropServices::Marshal::GetFunctionPointerForDelegate(m_sourceActivatedDelegate).ToPointer());
29d5198c 2345
11fea069 2346 delete context;
dc6366e8 2347
f9717bcc
LOK
2348 UnmanagedCecCallbacks unmanagedCallbacks;
2349 unmanagedCallbacks.logCB = m_logMessageCallback;
2350 unmanagedCallbacks.keyCB = m_keypressCallback;
2351 unmanagedCallbacks.commandCB = m_commandCallback;
2352 unmanagedCallbacks.configCB = m_configCallback;
2353 unmanagedCallbacks.alertCB = m_alertCallback;
2354 unmanagedCallbacks.menuCB = m_menuCallback;
2355 unmanagedCallbacks.sourceActivatedCB = m_sourceActivatedCallback;
2356
2357 PLATFORM::CLockObject lock(g_callbackMutex);
2358 g_unmanagedCallbacks.push_back(unmanagedCallbacks);
2359 m_iCallbackPtr = g_unmanagedCallbacks.size() - 1;
2360 m_bDelegatesCreated = true;
11fea069
LOK
2361 }
2362 }
2363
f9717bcc
LOK
2364 CecLogMessageManagedDelegate ^ m_logMessageDelegate;
2365 static System::Runtime::InteropServices::GCHandle m_logMessageGCHandle;
2366 LOGCB m_logMessageCallback;
4ef3b314 2367
f9717bcc
LOK
2368 CecKeyPressManagedDelegate ^ m_keypressDelegate;
2369 static System::Runtime::InteropServices::GCHandle m_keypressGCHandle;
2370 KEYCB m_keypressCallback;
4ef3b314 2371
f9717bcc
LOK
2372 CecCommandManagedDelegate ^ m_commandDelegate;
2373 static System::Runtime::InteropServices::GCHandle m_commandGCHandle;
2374 COMMANDCB m_commandCallback;
4ef3b314 2375
f9717bcc
LOK
2376 CecConfigManagedDelegate ^ m_configDelegate;
2377 static System::Runtime::InteropServices::GCHandle m_configGCHandle;
2378 CONFIGCB m_configCallback;
32403cc3 2379
f9717bcc
LOK
2380 CecAlertManagedDelegate ^ m_alertDelegate;
2381 static System::Runtime::InteropServices::GCHandle m_alertGCHandle;
2382 ALERTCB m_alertCallback;
5ee37222 2383
f9717bcc
LOK
2384 CecMenuManagedDelegate ^ m_menuDelegate;
2385 static System::Runtime::InteropServices::GCHandle m_menuGCHandle;
2386 MENUCB m_menuCallback;
c3a20edb 2387
f9717bcc
LOK
2388 CecSourceActivatedManagedDelegate ^ m_sourceActivatedDelegate;
2389 static System::Runtime::InteropServices::GCHandle m_sourceActivatedGCHandle;
2390 ACTICB m_sourceActivatedCallback;
29d5198c 2391
f9717bcc
LOK
2392 CecCallbackMethods ^ m_callbacks;
2393 bool m_bHasCallbacks;
11fea069 2394 bool m_bDelegatesCreated;
f9717bcc
LOK
2395 size_t m_iCallbackPtr;
2396 };
4ef3b314 2397}