cec: new libCEC methods added to LibCecSharp. fixed some compiler warnings
authorLars Op den Kamp <lars.opdenkamp@pulse-eight.com>
Mon, 28 Nov 2011 12:05:57 +0000 (13:05 +0100)
committerLars Op den Kamp <lars.opdenkamp@pulse-eight.com>
Mon, 28 Nov 2011 12:05:57 +0000 (13:05 +0100)
src/LibCecSharp/LibCecSharp.cpp
src/lib/CECProcessor.cpp
src/lib/LibCEC.cpp
src/lib/LibCECC.cpp
src/lib/devices/CECBusDevice.cpp
src/testclient/main.cpp

index 0aec2ff111823d8145a0883ce37e53783c03b42e..6e4895e8cbf9119acfac0a25e9152869c4e8de71 100644 (file)
@@ -144,6 +144,90 @@ 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 ref class CecAdapter
 {
 public:
@@ -170,6 +254,19 @@ public:
   property array<CecDeviceType> ^ Types;
 };
 
+public ref class CecLogicalAddresses
+{
+public:
+  CecLogicalAddresses(void)
+  {
+    Addresses = gcnew array<CecLogicalAddress>(16);
+    for (unsigned int iPtr = 0; iPtr < 16; iPtr++)
+      Addresses[iPtr] = CecLogicalAddress::Unregistered;
+  }
+
+  property array<CecLogicalAddress> ^ Addresses;
+};
+
 public ref class CecDatapacket
 {
 public:
@@ -525,6 +622,66 @@ 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(uint8_t port)
+  {
+    return m_libCec->SetHDMIPort(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 ^ GetOSDName(CecLogicalAddress logicalAddress)
+  {
+    cec_osd_name osd = m_libCec->GetOSDName((cec_logical_address) logicalAddress);
+    return gcnew String(osd.name);
+  }
+
 private:
-   ICECAdapter *     m_libCec;
+   ICECAdapter *m_libCec;
 };
index 8c95da7294a4fe866115ca6003947f7961fe173a..772f1e2e2e36e0417a9d2ae92afdd594b0387003 100644 (file)
@@ -273,7 +273,7 @@ void *CCECProcessor::Process(void)
 
     m_controller->CheckKeypressTimeout();
 
-    for (unsigned int iDevicePtr = 0; iDevicePtr < 16; iDevicePtr++)
+    for (uint8_t iDevicePtr = 0; iDevicePtr < 16; iDevicePtr++)
     {
       if (!m_logicalAddresses[iDevicePtr])
         m_busDevices[iDevicePtr]->PollVendorId();
@@ -767,6 +767,7 @@ void CCECProcessor::ParseCommand(cec_command &command)
 cec_logical_addresses CCECProcessor::GetActiveDevices(void)
 {
   cec_logical_addresses addresses;
+  addresses.Clear();
   for (unsigned int iPtr = 0; iPtr < 15; iPtr++)
   {
     if (m_busDevices[iPtr]->GetStatus() == CEC_DEVICE_STATUS_PRESENT)
index 92f00c32ed855247b8282db441229ae8aed9e8d0..524748709feac1e0067742eb3bd0373f30a4c797 100644 (file)
@@ -261,6 +261,7 @@ bool CLibCEC::PollDevice(cec_logical_address iAddress)
 cec_logical_addresses CLibCEC::GetActiveDevices(void)
 {
   cec_logical_addresses addresses;
+  addresses.Clear();
   if (m_cec)
     addresses = m_cec->GetActiveDevices();
   return addresses;
index 54b82f9fa6eaca31fce73bda8608ad1bf7ef92fb..e71cd11a1ad5d008976627fb4db64d24b4ed6743 100644 (file)
@@ -245,6 +245,7 @@ int cec_poll_device(cec_logical_address iLogicalAddress)
 cec_logical_addresses cec_get_active_devices(void)
 {
   cec_logical_addresses addresses;
+  addresses.Clear();
   if (cec_parser)
     addresses = cec_parser->GetActiveDevices();
   return addresses;
index 52d71df7f245ebf3365105d39a1b5e18f09eb0b0..b54e0a5c636e5a89ea56edb61c7f616c4689f179 100644 (file)
@@ -790,7 +790,7 @@ bool CCECBusDevice::SendKeypress(cec_user_control_code key, bool bWait /* = fals
     CLockObject lock(&m_transmitMutex);
     cec_command command;
     cec_command::Format(command, m_processor->GetLogicalAddress(), m_iLogicalAddress, CEC_OPCODE_USER_CONTROL_PRESSED);
-    command.parameters.PushBack(key);
+    command.parameters.PushBack((uint8_t)key);
 
     if (bWait)
     {
index d8daa8d7d8dc5691f89e486e1007958059fd9c48..0a7a9be9874326691bbb2ea07142d78daee3963e 100644 (file)
@@ -371,7 +371,7 @@ int main (int argc, char *argv[])
       {
         if (argc >= iArgPtr + 2)
         {
-          iHDMIPortatoi(argv[iArgPtr + 1]);
+          iHDMIPort = (int8_t)atoi(argv[iArgPtr + 1]);
           cout << "using HDMI port '" << iHDMIPort << "'" << endl;
           ++iArgPtr;
         }
@@ -561,7 +561,7 @@ int main (int argc, char *argv[])
           string strvalue;
           if (GetWord(input, strvalue))
           {
-            parser->SetHDMIPort(atoi(strvalue.c_str()));
+            parser->SetHDMIPort((uint8_t)atoi(strvalue.c_str()));
           }
         }
         else if (command == "pa")
@@ -738,7 +738,7 @@ int main (int argc, char *argv[])
         {
           cout << "listing active devices:" << endl;
           cec_logical_addresses addresses = parser->GetActiveDevices();
-          for (unsigned iPtr = 0; iPtr < 16; iPtr++)
+          for (uint8_t iPtr = 0; iPtr < 16; iPtr++)
             if (addresses[iPtr])
               cout << "logical address " << iPtr << endl;
         }