X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=src%2FLibCecSharp%2FLibCecSharp.cpp;h=088c9ef51c70637df6e2e7de592b4b08a070a81e;hb=863c4e5740face8308279a49a3fcc62f25c716cb;hp=0aec2ff111823d8145a0883ce37e53783c03b42e;hpb=0e1971485665b684b77f620dcd39c1b88a0300b3;p=deb_libcec.git diff --git a/src/LibCecSharp/LibCecSharp.cpp b/src/LibCecSharp/LibCecSharp.cpp index 0aec2ff..088c9ef 100644 --- a/src/LibCecSharp/LibCecSharp.cpp +++ b/src/LibCecSharp/LibCecSharp.cpp @@ -144,6 +144,185 @@ public enum class CecDeckInfo OtherStatus = 0x1F }; +public enum class CecUserControlCode +{ + Select = 0x00, + Up = 0x01, + Down = 0x02, + Left = 0x03, + Right = 0x04, + RightUp = 0x05, + RightDown = 0x06, + LeftUp = 0x07, + LeftDown = 0x08, + RootMenu = 0x09, + SetupMenu = 0x0A, + ContentsMenu = 0x0B, + FavoriteMenu = 0x0C, + Exit = 0x0D, + Number0 = 0x20, + Number1 = 0x21, + Number2 = 0x22, + Number3 = 0x23, + Number4 = 0x24, + Number5 = 0x25, + Number6 = 0x26, + Number7 = 0x27, + Number8 = 0x28, + Number9 = 0x29, + Dot = 0x2A, + Enter = 0x2B, + Clear = 0x2C, + NextFavorite = 0x2F, + ChannelUp = 0x30, + ChannelDown = 0x31, + PreviousChannel = 0x32, + SoundSelect = 0x33, + InputSelect = 0x34, + DisplayInformation = 0x35, + Help = 0x36, + PageUp = 0x37, + PageDown = 0x38, + Power = 0x40, + VolumeUp = 0x41, + VolumeDown = 0x42, + Mute = 0x43, + Play = 0x44, + Stop = 0x45, + Pause = 0x46, + Record = 0x47, + Rewind = 0x48, + FastForward = 0x49, + Eject = 0x4A, + Forward = 0x4B, + Backward = 0x4C, + StopRecord = 0x4D, + PauseRecord = 0x4E, + Angle = 0x50, + SubPicture = 0x51, + VideoOnDemand = 0x52, + ElectronicProgramGuide = 0x53, + TimerProgramming = 0x54, + InitialConfiguration = 0x55, + PlayFunction = 0x60, + PausePlayFunction = 0x61, + RecordFunction = 0x62, + PauseRecordFunction = 0x63, + StopFunction = 0x64, + MuteFunction = 0x65, + RestoreVolumeFunction = 0x66, + TuneFunction = 0x67, + SelectMediaFunction = 0x68, + SelectAVInputFunction = 0x69, + SelectAudioInputFunction = 0x6A, + PowerToggleFunction = 0x6B, + PowerOffFunction = 0x6C, + PowerOnFunction = 0x6D, + F1Blue = 0x71, + F2Red = 0X72, + F3Green = 0x73, + F4Yellow = 0x74, + F5 = 0x75, + Data = 0x76, + Max = 0x76, + Unknown +}; + +public enum class CecVendorId +{ + Samsung = 0x00F0, + LG = 0xE091, + Panasonic = 0x8045, + Pioneer = 0xE036, + Onkyo = 0x09B0, + Yamaha = 0xA0DE, + Philips = 0x903E, + Unknown = 0 +}; + +public enum class CecAudioStatus +{ + MuteStatusMask = 0x80, + VolumeStatusMask = 0x7F, + VolumeMin = 0x00, + VolumeMax = 0x64, + VolumeStatusUnknown = 0x7F +}; + +public enum class CecOpcode +{ + ActiveSource = 0x82, + ImageViewOn = 0x04, + TextViewOn = 0x0D, + InactiveSource = 0x9D, + RequestActiveSource = 0x85, + RoutingChange = 0x80, + RoutingInformation = 0x81, + SetStreamPath = 0x86, + Standby = 0x36, + RecordOff = 0x0B, + RecordOn = 0x09, + RecordStatus = 0x0A, + RecordTvScreen = 0x0F, + ClearAnalogueTimer = 0x33, + ClearDigitalTimer = 0x99, + ClearExternalTimer = 0xA1, + SetAnalogueTimer = 0x34, + SetDigitalTimer = 0x97, + SetExternalTimer = 0xA2, + SetTimerProgramTitle = 0x67, + TimerClearedStatus = 0x43, + TimerStatus = 0x35, + CecVersion = 0x9E, + GetCecVersion = 0x9F, + GivePhysicalAddress = 0x83, + GetMenuLanguage = 0x91, + ReportPhysicalAddress = 0x84, + SetMenuLanguage = 0x32, + DeckControl = 0x42, + DeckStatus = 0x1B, + GiveDeckStatus = 0x1A, + Play = 0x41, + GiveTunerDeviceStatus = 0x08, + SelectAnalogueService = 0x92, + SelectDigtalService = 0x93, + TunerDeviceStatus = 0x07, + TunerStepDecrement = 0x06, + TunerStepIncrement = 0x05, + DeviceVendorId = 0x87, + GiveDeviceVendorId = 0x8C, + VendorCommand = 0x89, + VendorCommandWithId = 0xA0, + VendorRemoteButtonDown = 0x8A, + VendorRemoteButtonUp = 0x8B, + SetOsdString = 0x64, + GiveOsdName = 0x46, + SetOsdName = 0x47, + MenuRequest = 0x8D, + MenuStatus = 0x8E, + UserControlPressed = 0x44, + UserControlRelease = 0x45, + GiveDevicePowerStatus = 0x8F, + ReportPowerStatus = 0x90, + FeatureAbort = 0x00, + Abort = 0xFF, + GiveAudioStatus = 0x71, + GiveSystemAudioMode = 0x7D, + ReportAudioStatus = 0x7A, + SetSystemAudioMode = 0x72, + SystemAudioModeRequest = 0x70, + SystemAudioModeStatus = 0x7E, + SetAudioRate = 0x9A, + /* when this opcode is set, no opcode will be sent to the device. this is one of the reserved numbers */ + None = 0xFD +}; + +public enum class CecSystemAudioStatus +{ + Off = 0, + On = 1 +}; + public ref class CecAdapter { public: @@ -170,6 +349,24 @@ public: property array ^ Types; }; +public ref class CecLogicalAddresses +{ +public: + CecLogicalAddresses(void) + { + Addresses = gcnew array(16); + for (unsigned int iPtr = 0; iPtr < 16; iPtr++) + Addresses[iPtr] = CecLogicalAddress::Unregistered; + } + + bool IsSet(CecLogicalAddress iAddress) + { + return Addresses[(unsigned int)iAddress] != CecLogicalAddress::Unregistered; + } + + property array ^ Addresses; +}; + public ref class CecDatapacket { public: @@ -195,7 +392,7 @@ public: public ref class CecCommand { public: - CecCommand(CecLogicalAddress iInitiator, CecLogicalAddress iDestination, bool bAck, bool bEom, int8_t iOpcode, int32_t iTransmitTimeout) + CecCommand(CecLogicalAddress iInitiator, CecLogicalAddress iDestination, bool bAck, bool bEom, CecOpcode iOpcode, int32_t iTransmitTimeout) { Initiator = iInitiator; Destination = iDestination; @@ -214,7 +411,7 @@ public: Destination = CecLogicalAddress::Unknown; Ack = false; Eom = false; - Opcode = 0; + Opcode = CecOpcode::None; OpcodeSet = false; TransmitTimeout = 0; Parameters = gcnew CecDatapacket; @@ -231,7 +428,7 @@ public: else if (!OpcodeSet) { OpcodeSet = true; - Opcode = data; + Opcode = (CecOpcode)data; } else { @@ -244,7 +441,7 @@ public: property CecLogicalAddress Destination; property bool Ack; property bool Eom; - property int8_t Opcode; + property CecOpcode Opcode; property CecDatapacket ^ Parameters; property bool OpcodeSet; property int32_t TransmitTimeout; @@ -411,7 +608,7 @@ public: cec_command command; if (m_libCec->GetNextCommand(&command)) { - CecCommand ^ retVal = gcnew CecCommand((CecLogicalAddress)command.initiator, (CecLogicalAddress)command.destination, command.ack == 1 ? true : false, command.eom == 1 ? true : false, command.opcode, command.transmit_timeout); + 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); for (uint8_t iPtr = 0; iPtr < command.parameters.size; iPtr++) retVal->Parameters->PushBack(command.parameters[iPtr]); return retVal; @@ -515,9 +712,9 @@ public: return gcnew String(""); } - uint64_t GetDeviceVendorId(CecLogicalAddress logicalAddress) + CecVendorId GetDeviceVendorId(CecLogicalAddress logicalAddress) { - return m_libCec->GetDeviceVendorId((cec_logical_address) logicalAddress); + return (CecVendorId)m_libCec->GetDeviceVendorId((cec_logical_address) logicalAddress); } CecPowerStatus GetDevicePowerStatus(CecLogicalAddress logicalAddress) @@ -525,6 +722,141 @@ public: return (CecPowerStatus) m_libCec->GetDevicePowerStatus((cec_logical_address) logicalAddress); } + CecLogicalAddresses ^ GetActiveDevices(void) + { + CecLogicalAddresses ^ retVal = gcnew CecLogicalAddresses(); + unsigned int iDevices = 0; + + cec_logical_addresses activeDevices = m_libCec->GetActiveDevices(); + + for (uint8_t iPtr = 0; iPtr < 16; iPtr++) + if (activeDevices[iPtr]) + retVal->Addresses[iDevices++] = (CecLogicalAddress)iPtr; + + return retVal; + } + + bool IsActiveDevice(CecLogicalAddress logicalAddress) + { + return m_libCec->IsActiveDevice((cec_logical_address)logicalAddress); + } + + bool IsActiveDeviceType(CecDeviceType type) + { + return m_libCec->IsActiveDeviceType((cec_device_type)type); + } + + bool SetHDMIPort(CecLogicalAddress address, uint8_t port) + { + return m_libCec->SetHDMIPort((cec_logical_address)address, port); + } + + uint8_t VolumeUp(bool wait) + { + return m_libCec->VolumeUp(wait); + } + + uint8_t VolumeDown(bool wait) + { + return m_libCec->VolumeDown(wait); + } + + uint8_t MuteAudio(bool wait) + { + return m_libCec->MuteAudio(wait); + } + + bool SendKeypress(CecLogicalAddress destination, CecUserControlCode key, bool wait) + { + return m_libCec->SendKeypress((cec_logical_address)destination, (cec_user_control_code)key, wait); + } + + bool SendKeyRelease(CecLogicalAddress destination, bool wait) + { + return m_libCec->SendKeyRelease((cec_logical_address)destination, wait); + } + + String ^ GetDeviceOSDName(CecLogicalAddress logicalAddress) + { + cec_osd_name osd = m_libCec->GetDeviceOSDName((cec_logical_address) logicalAddress); + return gcnew String(osd.name); + } + + CecLogicalAddress GetActiveSource() + { + return (CecLogicalAddress)m_libCec->GetActiveSource(); + } + + bool IsActiveSource(CecLogicalAddress logicalAddress) + { + return m_libCec->IsActiveSource((cec_logical_address)logicalAddress); + } + + uint16_t GetDevicePhysicalAddress(CecLogicalAddress iAddress) + { + return m_libCec->GetDevicePhysicalAddress((cec_logical_address)iAddress); + } + + String ^ ToString(CecLogicalAddress iAddress) + { + const char *retVal = m_libCec->ToString((cec_logical_address)iAddress); + return gcnew String(retVal); + } + + String ^ ToString(CecVendorId iVendorId) + { + const char *retVal = m_libCec->ToString((cec_vendor_id)iVendorId); + return gcnew String(retVal); + } + + String ^ ToString(CecVersion iVersion) + { + const char *retVal = m_libCec->ToString((cec_version)iVersion); + return gcnew String(retVal); + } + + String ^ ToString(CecPowerStatus iState) + { + const char *retVal = m_libCec->ToString((cec_power_status)iState); + return gcnew String(retVal); + } + + String ^ ToString(CecMenuState iState) + { + const char *retVal = m_libCec->ToString((cec_menu_state)iState); + return gcnew String(retVal); + } + + String ^ ToString(CecDeckControlMode iMode) + { + const char *retVal = m_libCec->ToString((cec_deck_control_mode)iMode); + return gcnew String(retVal); + } + + String ^ ToString(CecDeckInfo status) + { + const char *retVal = m_libCec->ToString((cec_deck_info)status); + return gcnew String(retVal); + } + + String ^ ToString(CecOpcode opcode) + { + const char *retVal = m_libCec->ToString((cec_opcode)opcode); + return gcnew String(retVal); + } + + String ^ ToString(CecSystemAudioStatus mode) + { + const char *retVal = m_libCec->ToString((cec_system_audio_status)mode); + return gcnew String(retVal); + } + + String ^ ToString(CecAudioStatus status) + { + const char *retVal = m_libCec->ToString((cec_audio_status)status); + return gcnew String(retVal); + } + private: - ICECAdapter * m_libCec; + ICECAdapter *m_libCec; };