Commit | Line | Data |
---|---|---|
61f3c2ad LOK |
1 | /* |
2 | * This file is part of the libCEC(R) library. | |
3 | * | |
4 | * libCEC(R) is Copyright (C) 2011 Pulse-Eight Limited. All rights reserved. | |
5 | * libCEC(R) is an original work, containing original code. | |
6 | * | |
7 | * libCEC(R) is a trademark of Pulse-Eight Limited. | |
8 | * | |
9 | * This program is dual-licensed; you can redistribute it and/or modify | |
10 | * it under the terms of the GNU General Public License as published by | |
11 | * the Free Software Foundation; either version 2 of the License, or | |
12 | * (at your option) any later version. | |
13 | * | |
14 | * This program is distributed in the hope that it will be useful, | |
15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
17 | * GNU General Public License for more details. | |
18 | * | |
19 | * You should have received a copy of the GNU General Public License | |
20 | * along with this program; if not, write to the Free Software | |
21 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | |
22 | * | |
23 | * | |
24 | * Alternatively, you can license this library under a commercial license, | |
25 | * please contact Pulse-Eight Licensing for more information. | |
26 | * | |
27 | * For more information contact: | |
28 | * Pulse-Eight Licensing <license@pulse-eight.com> | |
29 | * http://www.pulse-eight.com/ | |
30 | * http://www.pulse-eight.net/ | |
31 | */ | |
32 | ||
33 | #include "stdafx.h" | |
34 | #include <windows.h> | |
35 | #include <vcclr.h> | |
36 | #include <msclr/marshal.h> | |
37 | #include <cec.h> | |
38 | #using <System.dll> | |
39 | ||
40 | using namespace System; | |
41 | using namespace CEC; | |
42 | using namespace msclr::interop; | |
43 | ||
44 | public enum class CecDeviceType | |
45 | { | |
46 | Tv = 0, | |
47 | RecordingDevice = 1, | |
48 | Reserved = 2, | |
49 | Tuner = 3, | |
50 | PlaybackDevice = 4, | |
51 | AudioSystem = 5 | |
52 | }; | |
53 | ||
54 | public enum class CecLogLevel | |
55 | { | |
56 | None = 0, | |
57 | Error = 1, | |
58 | Warning = 2, | |
59 | Notice = 4, | |
60 | Traffic = 8, | |
61 | Debug = 16, | |
62 | All = 31 | |
63 | }; | |
64 | ||
65 | public enum class CecLogicalAddress | |
66 | { | |
67 | Unknown = -1, //not a valid logical address | |
68 | Tv = 0, | |
69 | RecordingDevice1 = 1, | |
70 | RecordingDevice2 = 2, | |
71 | Tuner1 = 3, | |
72 | PlaybackDevice1 = 4, | |
73 | AudioSystem = 5, | |
74 | Tuner2 = 6, | |
75 | Tuner3 = 7, | |
76 | PlaybackDevice2 = 8, | |
77 | RecordingDevice3 = 9, | |
78 | Tuner4 = 10, | |
79 | PlaybackDevice3 = 11, | |
80 | Reserved1 = 12, | |
81 | Reserved2 = 13, | |
82 | FreeUse = 14, | |
83 | Unregistered = 15, | |
84 | Broadcast = 15 | |
85 | }; | |
86 | ||
87 | public enum class CecPowerStatus | |
88 | { | |
89 | On = 0x00, | |
90 | Standby = 0x01, | |
91 | InTransitionStandbyToOn = 0x02, | |
92 | InTransitionOnToStandby = 0x03, | |
93 | Unknown = 0x99 | |
94 | }; | |
95 | ||
96 | public enum class CecVersion | |
97 | { | |
98 | Unknown = 0x00, | |
99 | V1_2 = 0x01, | |
100 | V1_2A = 0x02, | |
101 | V1_3 = 0x03, | |
102 | V1_3A = 0x04, | |
103 | V1_4 = 0x05 | |
104 | }; | |
105 | ||
106 | public enum class CecDisplayControl | |
107 | { | |
108 | DisplayForDefaultTime = 0x00, | |
109 | DisplayUntilCleared = 0x40, | |
110 | ClearPreviousMessage = 0x80, | |
111 | ReservedForFutureUse = 0xC0 | |
112 | }; | |
113 | ||
114 | public enum class CecMenuState | |
115 | { | |
116 | Activated = 0, | |
117 | Deactivated = 1 | |
118 | }; | |
119 | ||
120 | public enum class CecDeckControlMode | |
121 | { | |
122 | SkipForwardWind = 1, | |
123 | SkipReverseRewind = 2, | |
124 | Stop = 3, | |
125 | Eject = 4 | |
126 | }; | |
127 | ||
128 | public enum class CecDeckInfo | |
129 | { | |
130 | Play = 0x11, | |
131 | Record = 0x12, | |
132 | Reverse = 0x13, | |
133 | Still = 0x14, | |
134 | Slow = 0x15, | |
135 | SlowReverse = 0x16, | |
136 | FastForward = 0x17, | |
137 | FastReverse = 0x18, | |
138 | NoMedia = 0x19, | |
139 | Stop = 0x1A, | |
140 | SkipForwardWind = 0x1B, | |
141 | SkipReverseRewind = 0x1C, | |
142 | IndexSearchForward = 0x1D, | |
143 | IndexSearchReverse = 0x1E, | |
144 | OtherStatus = 0x1F | |
145 | }; | |
146 | ||
988de7b9 LOK |
147 | public enum class CecUserControlCode |
148 | { | |
149 | Select = 0x00, | |
150 | Up = 0x01, | |
151 | Down = 0x02, | |
152 | Left = 0x03, | |
153 | Right = 0x04, | |
154 | RightUp = 0x05, | |
155 | RightDown = 0x06, | |
156 | LeftUp = 0x07, | |
157 | LeftDown = 0x08, | |
158 | RootMenu = 0x09, | |
159 | SetupMenu = 0x0A, | |
160 | ContentsMenu = 0x0B, | |
161 | FavoriteMenu = 0x0C, | |
162 | Exit = 0x0D, | |
163 | Number0 = 0x20, | |
164 | Number1 = 0x21, | |
165 | Number2 = 0x22, | |
166 | Number3 = 0x23, | |
167 | Number4 = 0x24, | |
168 | Number5 = 0x25, | |
169 | Number6 = 0x26, | |
170 | Number7 = 0x27, | |
171 | Number8 = 0x28, | |
172 | Number9 = 0x29, | |
173 | Dot = 0x2A, | |
174 | Enter = 0x2B, | |
175 | Clear = 0x2C, | |
176 | NextFavorite = 0x2F, | |
177 | ChannelUp = 0x30, | |
178 | ChannelDown = 0x31, | |
179 | PreviousChannel = 0x32, | |
180 | SoundSelect = 0x33, | |
181 | InputSelect = 0x34, | |
182 | DisplayInformation = 0x35, | |
183 | Help = 0x36, | |
184 | PageUp = 0x37, | |
185 | PageDown = 0x38, | |
186 | Power = 0x40, | |
187 | VolumeUp = 0x41, | |
188 | VolumeDown = 0x42, | |
189 | Mute = 0x43, | |
190 | Play = 0x44, | |
191 | Stop = 0x45, | |
192 | Pause = 0x46, | |
193 | Record = 0x47, | |
194 | Rewind = 0x48, | |
195 | FastForward = 0x49, | |
196 | Eject = 0x4A, | |
197 | Forward = 0x4B, | |
198 | Backward = 0x4C, | |
199 | StopRecord = 0x4D, | |
200 | PauseRecord = 0x4E, | |
201 | Angle = 0x50, | |
202 | SubPicture = 0x51, | |
203 | VideoOnDemand = 0x52, | |
204 | ElectronicProgramGuide = 0x53, | |
205 | TimerProgramming = 0x54, | |
206 | InitialConfiguration = 0x55, | |
207 | PlayFunction = 0x60, | |
208 | PausePlayFunction = 0x61, | |
209 | RecordFunction = 0x62, | |
210 | PauseRecordFunction = 0x63, | |
211 | StopFunction = 0x64, | |
212 | MuteFunction = 0x65, | |
213 | RestoreVolumeFunction = 0x66, | |
214 | TuneFunction = 0x67, | |
215 | SelectMediaFunction = 0x68, | |
216 | SelectAVInputFunction = 0x69, | |
217 | SelectAudioInputFunction = 0x6A, | |
218 | PowerToggleFunction = 0x6B, | |
219 | PowerOffFunction = 0x6C, | |
220 | PowerOnFunction = 0x6D, | |
221 | F1Blue = 0x71, | |
222 | F2Red = 0X72, | |
223 | F3Green = 0x73, | |
224 | F4Yellow = 0x74, | |
225 | F5 = 0x75, | |
226 | Data = 0x76, | |
227 | Max = 0x76, | |
228 | Unknown | |
229 | }; | |
230 | ||
8d4c47d9 LOK |
231 | public enum class CecVendorId |
232 | { | |
233 | Samsung = 0x00F0, | |
234 | LG = 0xE091, | |
235 | Panasonic = 0x8045, | |
236 | Pioneer = 0xE036, | |
237 | Onkyo = 0x09B0, | |
238 | Yamaha = 0xA0DE, | |
239 | Philips = 0x903E, | |
240 | Unknown = 0 | |
241 | }; | |
242 | ||
243 | public enum class CecAudioStatus | |
244 | { | |
245 | MuteStatusMask = 0x80, | |
246 | VolumeStatusMask = 0x7F, | |
247 | VolumeMin = 0x00, | |
248 | VolumeMax = 0x64, | |
249 | VolumeStatusUnknown = 0x7F | |
250 | }; | |
251 | ||
252 | public enum class CecOpcode | |
253 | { | |
254 | ActiveSource = 0x82, | |
255 | ImageViewOn = 0x04, | |
256 | TextViewOn = 0x0D, | |
257 | InactiveSource = 0x9D, | |
258 | RequestActiveSource = 0x85, | |
259 | RoutingChange = 0x80, | |
260 | RoutingInformation = 0x81, | |
261 | SetStreamPath = 0x86, | |
262 | Standby = 0x36, | |
263 | RecordOff = 0x0B, | |
264 | RecordOn = 0x09, | |
265 | RecordStatus = 0x0A, | |
266 | RecordTvScreen = 0x0F, | |
267 | ClearAnalogueTimer = 0x33, | |
268 | ClearDigitalTimer = 0x99, | |
269 | ClearExternalTimer = 0xA1, | |
270 | SetAnalogueTimer = 0x34, | |
271 | SetDigitalTimer = 0x97, | |
272 | SetExternalTimer = 0xA2, | |
273 | SetTimerProgramTitle = 0x67, | |
274 | TimerClearedStatus = 0x43, | |
275 | TimerStatus = 0x35, | |
276 | CecVersion = 0x9E, | |
277 | GetCecVersion = 0x9F, | |
278 | GivePhysicalAddress = 0x83, | |
279 | GetMenuLanguage = 0x91, | |
280 | ReportPhysicalAddress = 0x84, | |
281 | SetMenuLanguage = 0x32, | |
282 | DeckControl = 0x42, | |
283 | DeckStatus = 0x1B, | |
284 | GiveDeckStatus = 0x1A, | |
285 | Play = 0x41, | |
286 | GiveTunerDeviceStatus = 0x08, | |
287 | SelectAnalogueService = 0x92, | |
288 | SelectDigtalService = 0x93, | |
289 | TunerDeviceStatus = 0x07, | |
290 | TunerStepDecrement = 0x06, | |
291 | TunerStepIncrement = 0x05, | |
292 | DeviceVendorId = 0x87, | |
293 | GiveDeviceVendorId = 0x8C, | |
294 | VendorCommand = 0x89, | |
295 | VendorCommandWithId = 0xA0, | |
296 | VendorRemoteButtonDown = 0x8A, | |
297 | VendorRemoteButtonUp = 0x8B, | |
298 | SetOsdString = 0x64, | |
299 | GiveOsdName = 0x46, | |
300 | SetOsdName = 0x47, | |
301 | MenuRequest = 0x8D, | |
302 | MenuStatus = 0x8E, | |
303 | UserControlPressed = 0x44, | |
304 | UserControlRelease = 0x45, | |
305 | GiveDevicePowerStatus = 0x8F, | |
306 | ReportPowerStatus = 0x90, | |
307 | FeatureAbort = 0x00, | |
308 | Abort = 0xFF, | |
309 | GiveAudioStatus = 0x71, | |
310 | GiveSystemAudioMode = 0x7D, | |
311 | ReportAudioStatus = 0x7A, | |
312 | SetSystemAudioMode = 0x72, | |
313 | SystemAudioModeRequest = 0x70, | |
314 | SystemAudioModeStatus = 0x7E, | |
315 | SetAudioRate = 0x9A, | |
316 | /* when this opcode is set, no opcode will be sent to the device. this is one of the reserved numbers */ | |
317 | None = 0xFD | |
318 | }; | |
319 | ||
320 | public enum class CecSystemAudioStatus | |
321 | { | |
322 | Off = 0, | |
323 | On = 1 | |
324 | }; | |
325 | ||
61f3c2ad LOK |
326 | public ref class CecAdapter |
327 | { | |
328 | public: | |
329 | CecAdapter(String ^ strPath, String ^ strComPort) | |
330 | { | |
331 | Path = strPath; | |
332 | ComPort = strComPort; | |
333 | } | |
334 | ||
335 | property String ^ Path; | |
336 | property String ^ ComPort; | |
337 | }; | |
338 | ||
339 | public ref class CecDeviceTypeList | |
340 | { | |
341 | public: | |
342 | CecDeviceTypeList(void) | |
343 | { | |
344 | Types = gcnew array<CecDeviceType>(5); | |
345 | for (unsigned int iPtr = 0; iPtr < 5; iPtr++) | |
346 | Types[iPtr] = CecDeviceType::Reserved; | |
347 | } | |
348 | ||
349 | property array<CecDeviceType> ^ Types; | |
350 | }; | |
351 | ||
988de7b9 LOK |
352 | public ref class CecLogicalAddresses |
353 | { | |
354 | public: | |
355 | CecLogicalAddresses(void) | |
356 | { | |
357 | Addresses = gcnew array<CecLogicalAddress>(16); | |
358 | for (unsigned int iPtr = 0; iPtr < 16; iPtr++) | |
359 | Addresses[iPtr] = CecLogicalAddress::Unregistered; | |
360 | } | |
361 | ||
8d4c47d9 LOK |
362 | bool IsSet(CecLogicalAddress iAddress) |
363 | { | |
364 | return Addresses[(unsigned int)iAddress] != CecLogicalAddress::Unregistered; | |
365 | } | |
366 | ||
988de7b9 LOK |
367 | property array<CecLogicalAddress> ^ Addresses; |
368 | }; | |
369 | ||
61f3c2ad LOK |
370 | public ref class CecDatapacket |
371 | { | |
372 | public: | |
373 | CecDatapacket(void) | |
374 | { | |
375 | Data = gcnew array<uint8_t>(100); | |
376 | Size = 0; | |
377 | } | |
378 | ||
379 | void PushBack(uint8_t data) | |
380 | { | |
381 | if (Size < 100) | |
382 | { | |
383 | Data[Size] = data; | |
384 | Size++; | |
385 | } | |
386 | } | |
387 | ||
388 | property array<uint8_t> ^ Data; | |
389 | property uint8_t Size; | |
390 | }; | |
391 | ||
392 | public ref class CecCommand | |
393 | { | |
394 | public: | |
8d4c47d9 | 395 | CecCommand(CecLogicalAddress iInitiator, CecLogicalAddress iDestination, bool bAck, bool bEom, CecOpcode iOpcode, int32_t iTransmitTimeout) |
61f3c2ad LOK |
396 | { |
397 | Initiator = iInitiator; | |
398 | Destination = iDestination; | |
399 | Ack = bAck; | |
400 | Eom = bEom; | |
401 | Opcode = iOpcode; | |
402 | OpcodeSet = true; | |
403 | TransmitTimeout = iTransmitTimeout; | |
404 | Parameters = gcnew CecDatapacket; | |
405 | Empty = false; | |
406 | } | |
407 | ||
408 | CecCommand(void) | |
409 | { | |
410 | Initiator = CecLogicalAddress::Unknown; | |
411 | Destination = CecLogicalAddress::Unknown; | |
412 | Ack = false; | |
413 | Eom = false; | |
8d4c47d9 | 414 | Opcode = CecOpcode::None; |
61f3c2ad LOK |
415 | OpcodeSet = false; |
416 | TransmitTimeout = 0; | |
417 | Parameters = gcnew CecDatapacket; | |
418 | Empty = true; | |
419 | } | |
420 | ||
421 | void PushBack(uint8_t data) | |
422 | { | |
423 | if (Initiator == CecLogicalAddress::Unknown && Destination == CecLogicalAddress::Unknown) | |
424 | { | |
425 | Initiator = (CecLogicalAddress) (data >> 4); | |
426 | Destination = (CecLogicalAddress) (data & 0xF); | |
427 | } | |
428 | else if (!OpcodeSet) | |
429 | { | |
430 | OpcodeSet = true; | |
8d4c47d9 | 431 | Opcode = (CecOpcode)data; |
61f3c2ad LOK |
432 | } |
433 | else | |
434 | { | |
435 | Parameters->PushBack(data); | |
436 | } | |
437 | } | |
438 | ||
439 | property bool Empty; | |
440 | property CecLogicalAddress Initiator; | |
441 | property CecLogicalAddress Destination; | |
442 | property bool Ack; | |
443 | property bool Eom; | |
8d4c47d9 | 444 | property CecOpcode Opcode; |
61f3c2ad LOK |
445 | property CecDatapacket ^ Parameters; |
446 | property bool OpcodeSet; | |
447 | property int32_t TransmitTimeout; | |
448 | }; | |
449 | ||
450 | public ref class CecKeypress | |
451 | { | |
452 | public: | |
453 | CecKeypress(int iKeycode, unsigned int iDuration) | |
454 | { | |
455 | Keycode = iKeycode; | |
456 | Duration = iDuration; | |
457 | Empty = false; | |
458 | } | |
459 | ||
460 | CecKeypress(void) | |
461 | { | |
462 | Keycode = 0; | |
463 | Duration = 0; | |
464 | Empty = true; | |
465 | } | |
466 | ||
467 | property bool Empty; | |
468 | property int Keycode; | |
469 | property unsigned int Duration; | |
470 | }; | |
471 | ||
472 | public ref class CecLogMessage | |
473 | { | |
474 | public: | |
475 | CecLogMessage(String ^ strMessage, CecLogLevel iLevel, int64_t iTime) | |
476 | { | |
477 | Message = strMessage; | |
478 | Level = iLevel; | |
479 | Time = iTime; | |
480 | Empty = false; | |
481 | } | |
482 | ||
483 | CecLogMessage(void) | |
484 | { | |
485 | Message = ""; | |
486 | Level = CecLogLevel::None; | |
487 | Time = 0; | |
488 | Empty = true; | |
489 | } | |
490 | ||
491 | property bool Empty; | |
492 | property String ^ Message; | |
493 | property CecLogLevel Level; | |
494 | property int64_t Time; | |
495 | }; | |
496 | ||
497 | public ref class LibCecSharp | |
498 | { | |
499 | public: | |
500 | LibCecSharp(String ^ strDeviceName, CecDeviceTypeList ^ deviceTypes) | |
501 | { | |
502 | marshal_context ^ context = gcnew marshal_context(); | |
503 | ||
504 | const char* strDeviceNameC = context->marshal_as<const char*>(strDeviceName); | |
505 | ||
506 | cec_device_type_list types; | |
507 | for (unsigned int iPtr = 0; iPtr < 5; iPtr++) | |
508 | types.types[iPtr] = (cec_device_type)deviceTypes->Types[iPtr]; | |
509 | m_libCec = (ICECAdapter *) CECInit(strDeviceNameC, types); | |
510 | delete context; | |
511 | } | |
512 | ||
513 | ~LibCecSharp(void) | |
514 | { | |
515 | CECDestroy(m_libCec); | |
516 | m_libCec = NULL; | |
517 | } | |
518 | ||
519 | protected: | |
520 | !LibCecSharp(void) | |
521 | { | |
522 | CECDestroy(m_libCec); | |
523 | m_libCec = NULL; | |
524 | } | |
525 | ||
526 | public: | |
527 | array<CecAdapter ^> ^ FindAdapters(String ^ path) | |
528 | { | |
529 | cec_adapter *devices = new cec_adapter[10]; | |
530 | ||
531 | marshal_context ^ context = gcnew marshal_context(); | |
532 | const char* strPathC = path->Length > 0 ? context->marshal_as<const char*>(path) : NULL; | |
533 | ||
534 | uint8_t iDevicesFound = m_libCec->FindAdapters(devices, 10, NULL); | |
535 | ||
536 | array<CecAdapter ^> ^ adapters = gcnew array<CecAdapter ^>(iDevicesFound); | |
537 | for (unsigned int iPtr = 0; iPtr < iDevicesFound; iPtr++) | |
538 | adapters[iPtr] = gcnew CecAdapter(gcnew String(devices[iPtr].path), gcnew String(devices[iPtr].comm)); | |
539 | ||
540 | delete devices; | |
541 | delete context; | |
542 | return adapters; | |
543 | } | |
544 | ||
545 | bool Open(String ^ strPort, int iTimeoutMs) | |
546 | { | |
547 | marshal_context ^ context = gcnew marshal_context(); | |
548 | const char* strPortC = context->marshal_as<const char*>(strPort); | |
549 | bool bReturn = m_libCec->Open(strPortC, iTimeoutMs); | |
550 | delete context; | |
551 | return bReturn; | |
552 | } | |
553 | ||
554 | void Close(void) | |
555 | { | |
556 | m_libCec->Close(); | |
557 | } | |
558 | ||
559 | bool PingAdapter(void) | |
560 | { | |
561 | return m_libCec->PingAdapter(); | |
562 | } | |
563 | ||
564 | bool StartBootloader(void) | |
565 | { | |
566 | return m_libCec->StartBootloader(); | |
567 | } | |
568 | ||
569 | int GetMinLibVersion(void) | |
570 | { | |
571 | return m_libCec->GetMinLibVersion(); | |
572 | } | |
573 | ||
574 | int GetLibVersionMajor(void) | |
575 | { | |
576 | return m_libCec->GetLibVersionMajor(); | |
577 | } | |
578 | ||
579 | int GetLibVersionMinor(void) | |
580 | { | |
581 | return m_libCec->GetLibVersionMinor(); | |
582 | } | |
583 | ||
584 | CecLogMessage ^ GetNextLogMessage(void) | |
585 | { | |
586 | cec_log_message msg; | |
587 | if (m_libCec->GetNextLogMessage(&msg)) | |
588 | { | |
589 | return gcnew CecLogMessage(gcnew String(msg.message), (CecLogLevel)msg.level, msg.time); | |
590 | } | |
591 | ||
592 | return gcnew CecLogMessage(); | |
593 | } | |
594 | ||
595 | CecKeypress ^ GetNextKeypress(void) | |
596 | { | |
597 | cec_keypress key; | |
598 | if (m_libCec->GetNextKeypress(&key)) | |
599 | { | |
600 | return gcnew CecKeypress(key.keycode, key.duration); | |
601 | } | |
602 | ||
603 | return gcnew CecKeypress(); | |
604 | } | |
605 | ||
606 | CecCommand ^ GetNextCommand(void) | |
607 | { | |
608 | cec_command command; | |
609 | if (m_libCec->GetNextCommand(&command)) | |
610 | { | |
8d4c47d9 | 611 | CecCommand ^ retVal = gcnew CecCommand((CecLogicalAddress)command.initiator, (CecLogicalAddress)command.destination, command.ack == 1 ? true : false, command.eom == 1 ? true : false, (CecOpcode)command.opcode, command.transmit_timeout); |
0e197148 LOK |
612 | for (uint8_t iPtr = 0; iPtr < command.parameters.size; iPtr++) |
613 | retVal->Parameters->PushBack(command.parameters[iPtr]); | |
614 | return retVal; | |
61f3c2ad LOK |
615 | } |
616 | ||
617 | return gcnew CecCommand(); | |
618 | } | |
619 | ||
620 | bool Transmit(CecCommand ^ command) | |
621 | { | |
622 | cec_command ccommand; | |
ab1469a0 | 623 | cec_command::Format(ccommand, (cec_logical_address)command->Initiator, (cec_logical_address)command->Destination, (cec_opcode)command->Opcode); |
61f3c2ad LOK |
624 | ccommand.transmit_timeout = command->TransmitTimeout; |
625 | ccommand.eom = command->Eom; | |
626 | ccommand.ack = command->Ack; | |
627 | for (unsigned int iPtr = 0; iPtr < command->Parameters->Size; iPtr++) | |
ab1469a0 | 628 | ccommand.parameters.PushBack(command->Parameters->Data[iPtr]); |
61f3c2ad LOK |
629 | |
630 | return m_libCec->Transmit(ccommand); | |
631 | } | |
632 | ||
633 | bool SetLogicalAddress(CecLogicalAddress logicalAddress) | |
634 | { | |
635 | return m_libCec->SetLogicalAddress((cec_logical_address) logicalAddress); | |
636 | } | |
637 | ||
638 | bool SetPhysicalAddress(int16_t physicalAddress) | |
639 | { | |
640 | return m_libCec->SetPhysicalAddress(physicalAddress); | |
641 | } | |
642 | ||
643 | bool PowerOnDevices(CecLogicalAddress logicalAddress) | |
644 | { | |
645 | return m_libCec->PowerOnDevices((cec_logical_address) logicalAddress); | |
646 | } | |
647 | ||
648 | bool StandbyDevices(CecLogicalAddress logicalAddress) | |
649 | { | |
650 | return m_libCec->StandbyDevices((cec_logical_address) logicalAddress); | |
651 | } | |
652 | ||
653 | bool PollDevice(CecLogicalAddress logicalAddress) | |
654 | { | |
655 | return m_libCec->PollDevice((cec_logical_address) logicalAddress); | |
656 | } | |
657 | ||
658 | bool SetActiveSource(CecDeviceType type) | |
659 | { | |
660 | return m_libCec->SetActiveSource((cec_device_type) type); | |
661 | } | |
662 | ||
663 | bool SetDeckControlMode(CecDeckControlMode mode, bool sendUpdate) | |
664 | { | |
665 | return m_libCec->SetDeckControlMode((cec_deck_control_mode) mode, sendUpdate); | |
666 | } | |
667 | ||
668 | bool SetDeckInfo(CecDeckInfo info, bool sendUpdate) | |
669 | { | |
670 | return m_libCec->SetDeckInfo((cec_deck_info) info, sendUpdate); | |
671 | } | |
672 | ||
673 | bool SetInactiveView(void) | |
674 | { | |
675 | return m_libCec->SetInactiveView(); | |
676 | } | |
677 | ||
678 | bool SetMenuState(CecMenuState state, bool sendUpdate) | |
679 | { | |
680 | return m_libCec->SetMenuState((cec_menu_state) state, sendUpdate); | |
681 | } | |
682 | ||
683 | bool SetOSDString(CecLogicalAddress logicalAddress, CecDisplayControl duration, String ^ message) | |
684 | { | |
685 | marshal_context ^ context = gcnew marshal_context(); | |
686 | const char* strMessageC = context->marshal_as<const char*>(message); | |
687 | ||
688 | bool bReturn = m_libCec->SetOSDString((cec_logical_address) logicalAddress, (cec_display_control) duration, strMessageC); | |
689 | ||
690 | delete context; | |
691 | return bReturn; | |
692 | } | |
693 | ||
694 | bool SwitchMonitoring(bool enable) | |
695 | { | |
696 | return m_libCec->SwitchMonitoring(enable); | |
697 | } | |
698 | ||
699 | CecVersion GetDeviceCecVersion(CecLogicalAddress logicalAddress) | |
700 | { | |
701 | return (CecVersion) m_libCec->GetDeviceCecVersion((cec_logical_address) logicalAddress); | |
702 | } | |
703 | ||
704 | String ^ GetDeviceMenuLanguage(CecLogicalAddress logicalAddress) | |
705 | { | |
706 | cec_menu_language lang; | |
707 | if (m_libCec->GetDeviceMenuLanguage((cec_logical_address) logicalAddress, &lang)) | |
708 | { | |
709 | return gcnew String(lang.language); | |
710 | } | |
711 | ||
712 | return gcnew String(""); | |
713 | } | |
714 | ||
8d4c47d9 | 715 | CecVendorId GetDeviceVendorId(CecLogicalAddress logicalAddress) |
61f3c2ad | 716 | { |
8d4c47d9 | 717 | return (CecVendorId)m_libCec->GetDeviceVendorId((cec_logical_address) logicalAddress); |
61f3c2ad LOK |
718 | } |
719 | ||
720 | CecPowerStatus GetDevicePowerStatus(CecLogicalAddress logicalAddress) | |
721 | { | |
722 | return (CecPowerStatus) m_libCec->GetDevicePowerStatus((cec_logical_address) logicalAddress); | |
723 | } | |
724 | ||
988de7b9 LOK |
725 | CecLogicalAddresses ^ GetActiveDevices(void) |
726 | { | |
727 | CecLogicalAddresses ^ retVal = gcnew CecLogicalAddresses(); | |
728 | unsigned int iDevices = 0; | |
729 | ||
730 | cec_logical_addresses activeDevices = m_libCec->GetActiveDevices(); | |
731 | ||
732 | for (uint8_t iPtr = 0; iPtr < 16; iPtr++) | |
733 | if (activeDevices[iPtr]) | |
734 | retVal->Addresses[iDevices++] = (CecLogicalAddress)iPtr; | |
735 | ||
736 | return retVal; | |
737 | } | |
738 | ||
739 | bool IsActiveDevice(CecLogicalAddress logicalAddress) | |
740 | { | |
741 | return m_libCec->IsActiveDevice((cec_logical_address)logicalAddress); | |
742 | } | |
743 | ||
744 | bool IsActiveDeviceType(CecDeviceType type) | |
745 | { | |
746 | return m_libCec->IsActiveDeviceType((cec_device_type)type); | |
747 | } | |
748 | ||
bdccb711 | 749 | bool SetHDMIPort(CecLogicalAddress address, uint8_t port) |
988de7b9 | 750 | { |
bdccb711 | 751 | return m_libCec->SetHDMIPort((cec_logical_address)address, port); |
988de7b9 LOK |
752 | } |
753 | ||
754 | uint8_t VolumeUp(bool wait) | |
755 | { | |
756 | return m_libCec->VolumeUp(wait); | |
757 | } | |
758 | ||
759 | uint8_t VolumeDown(bool wait) | |
760 | { | |
761 | return m_libCec->VolumeDown(wait); | |
762 | } | |
763 | ||
764 | uint8_t MuteAudio(bool wait) | |
765 | { | |
766 | return m_libCec->MuteAudio(wait); | |
767 | } | |
768 | ||
8b86fb7a | 769 | bool SendKeypress(CecLogicalAddress destination, CecUserControlCode key, bool wait) |
988de7b9 | 770 | { |
8b86fb7a | 771 | return m_libCec->SendKeypress((cec_logical_address)destination, (cec_user_control_code)key, wait); |
988de7b9 LOK |
772 | } |
773 | ||
8b86fb7a | 774 | bool SendKeyRelease(CecLogicalAddress destination, bool wait) |
988de7b9 | 775 | { |
8b86fb7a | 776 | return m_libCec->SendKeyRelease((cec_logical_address)destination, wait); |
988de7b9 LOK |
777 | } |
778 | ||
f71a1df9 | 779 | String ^ GetDeviceOSDName(CecLogicalAddress logicalAddress) |
988de7b9 | 780 | { |
f71a1df9 | 781 | cec_osd_name osd = m_libCec->GetDeviceOSDName((cec_logical_address) logicalAddress); |
988de7b9 LOK |
782 | return gcnew String(osd.name); |
783 | } | |
784 | ||
6c3c8d5a LOK |
785 | CecLogicalAddress GetActiveSource() |
786 | { | |
787 | return (CecLogicalAddress)m_libCec->GetActiveSource(); | |
788 | } | |
789 | ||
790 | bool IsActiveSource(CecLogicalAddress logicalAddress) | |
791 | { | |
792 | return m_libCec->IsActiveSource((cec_logical_address)logicalAddress); | |
793 | } | |
794 | ||
8d4c47d9 LOK |
795 | uint16_t GetDevicePhysicalAddress(CecLogicalAddress iAddress) |
796 | { | |
797 | return m_libCec->GetDevicePhysicalAddress((cec_logical_address)iAddress); | |
798 | } | |
799 | ||
800 | String ^ ToString(CecLogicalAddress iAddress) | |
801 | { | |
802 | const char *retVal = m_libCec->ToString((cec_logical_address)iAddress); | |
803 | return gcnew String(retVal); | |
804 | } | |
805 | ||
806 | String ^ ToString(CecVendorId iVendorId) | |
807 | { | |
808 | const char *retVal = m_libCec->ToString((cec_vendor_id)iVendorId); | |
809 | return gcnew String(retVal); | |
810 | } | |
811 | ||
812 | String ^ ToString(CecVersion iVersion) | |
813 | { | |
814 | const char *retVal = m_libCec->ToString((cec_version)iVersion); | |
815 | return gcnew String(retVal); | |
816 | } | |
817 | ||
818 | String ^ ToString(CecPowerStatus iState) | |
819 | { | |
820 | const char *retVal = m_libCec->ToString((cec_power_status)iState); | |
821 | return gcnew String(retVal); | |
822 | } | |
823 | ||
824 | String ^ ToString(CecMenuState iState) | |
825 | { | |
826 | const char *retVal = m_libCec->ToString((cec_menu_state)iState); | |
827 | return gcnew String(retVal); | |
828 | } | |
829 | ||
830 | String ^ ToString(CecDeckControlMode iMode) | |
831 | { | |
832 | const char *retVal = m_libCec->ToString((cec_deck_control_mode)iMode); | |
833 | return gcnew String(retVal); | |
834 | } | |
835 | ||
836 | String ^ ToString(CecDeckInfo status) | |
837 | { | |
838 | const char *retVal = m_libCec->ToString((cec_deck_info)status); | |
839 | return gcnew String(retVal); | |
840 | } | |
841 | ||
842 | String ^ ToString(CecOpcode opcode) | |
843 | { | |
844 | const char *retVal = m_libCec->ToString((cec_opcode)opcode); | |
845 | return gcnew String(retVal); | |
846 | } | |
847 | ||
848 | String ^ ToString(CecSystemAudioStatus mode) | |
849 | { | |
850 | const char *retVal = m_libCec->ToString((cec_system_audio_status)mode); | |
851 | return gcnew String(retVal); | |
852 | } | |
853 | ||
854 | String ^ ToString(CecAudioStatus status) | |
855 | { | |
856 | const char *retVal = m_libCec->ToString((cec_audio_status)status); | |
857 | return gcnew String(retVal); | |
858 | } | |
859 | ||
61f3c2ad | 860 | private: |
988de7b9 | 861 | ICECAdapter *m_libCec; |
61f3c2ad | 862 | }; |