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