cec-config-gui: read/write the vendor id override setting
authorLars Op den Kamp <lars@opdenkamp.eu>
Wed, 15 Feb 2012 15:27:06 +0000 (16:27 +0100)
committerLars Op den Kamp <lars@opdenkamp.eu>
Wed, 15 Feb 2012 15:27:06 +0000 (16:27 +0100)
src/LibCecSharp/CecSharpTypes.h
src/cec-config-gui/CecConfigGUI.Designer.cs
src/cec-config-gui/CecConfigGUI.cs
src/cec-config-gui/CecConfigGUI.resx
src/lib/CECProcessor.cpp

index 212d8181e3a758dbc7d69c0312011170ffec6962..39ef0cb28db367bb2b50f9596130b02b8ddfa7e3 100644 (file)
@@ -236,6 +236,7 @@ namespace CecSharp
                Onkyo     = 0x09B0,
                Yamaha    = 0xA0DE,
                Philips   = 0x903E,
+               Sony      = 0x080046,
                Unknown   = 0
        };
 
index c3d45e1470d969370356227c28827e66eb7ec758..a5cda7e803462da72cf8cec56c172b1554b85fa5 100644 (file)
@@ -31,6 +31,8 @@
       this.components = new System.ComponentModel.Container();
       this.tabControl1 = new System.Windows.Forms.TabControl();
       this.Configuration = new System.Windows.Forms.TabPage();
+      this.cbVendorOverride = new System.Windows.Forms.CheckBox();
+      this.cbVendorId = new System.Windows.Forms.ComboBox();
       this.lPowerOff = new System.Windows.Forms.Label();
       this.cbPowerOffDevices = new System.Windows.Forms.CheckedListBox();
       this.lWakeDevices = new System.Windows.Forms.Label();
@@ -83,8 +85,6 @@
       this.helpConnectedHDMIDevice = new System.Windows.Forms.ToolTip(this.components);
       this.helpPhysicalAddress = new System.Windows.Forms.ToolTip(this.components);
       this.helpDeviceType = new System.Windows.Forms.ToolTip(this.components);
-      this.cbVendorId = new System.Windows.Forms.ComboBox();
-      this.cbVendorOverride = new System.Windows.Forms.CheckBox();
       this.tabControl1.SuspendLayout();
       this.Configuration.SuspendLayout();
       this.tbButtons.SuspendLayout();
       this.Configuration.Text = "Configuration";
       this.Configuration.UseVisualStyleBackColor = true;
       // 
+      // cbVendorOverride
+      // 
+      this.cbVendorOverride.AutoSize = true;
+      this.cbVendorOverride.Location = new System.Drawing.Point(10, 156);
+      this.cbVendorOverride.Name = "cbVendorOverride";
+      this.cbVendorOverride.Size = new System.Drawing.Size(130, 17);
+      this.cbVendorOverride.TabIndex = 29;
+      this.cbVendorOverride.Text = "Override TV vendor id";
+      this.cbVendorOverride.UseVisualStyleBackColor = true;
+      this.cbVendorOverride.CheckedChanged += new System.EventHandler(this.cbVendorOverride_CheckedChanged);
+      // 
+      // cbVendorId
+      // 
+      this.cbVendorId.Enabled = false;
+      this.cbVendorId.FormattingEnabled = true;
+      this.cbVendorId.Items.AddRange(new object[] {
+            "- autodetect -",
+            "LG",
+            "Onkyo",
+            "Panasonic",
+            "Philips",
+            "Pioneer",
+            "Samsung",
+            "Sony",
+            "Yamaha"});
+      this.cbVendorId.Location = new System.Drawing.Point(174, 153);
+      this.cbVendorId.Name = "cbVendorId";
+      this.cbVendorId.Size = new System.Drawing.Size(121, 21);
+      this.cbVendorId.TabIndex = 28;
+      this.cbVendorId.Text = "- autodetect -";
+      this.helpDeviceType.SetToolTip(this.cbVendorId, "Only set this value when autodetection isn\'t working");
+      // 
       // lPowerOff
       // 
       this.lPowerOff.AutoSize = true;
       this.lStatus.TabIndex = 2;
       this.lStatus.Text = "Initialising...";
       // 
-      // cbVendorId
-      // 
-      this.cbVendorId.Enabled = false;
-      this.cbVendorId.FormattingEnabled = true;
-      this.cbVendorId.Items.AddRange(new object[] {
-            "- autodetect -",
-            "LG",
-            "Onkyo",
-            "Panasonic",
-            "Philips",
-            "Pioneer",
-            "Samsung",
-            "Sony",
-            "Yamaha"});
-      this.cbVendorId.Location = new System.Drawing.Point(174, 153);
-      this.cbVendorId.Name = "cbVendorId";
-      this.cbVendorId.Size = new System.Drawing.Size(121, 21);
-      this.cbVendorId.TabIndex = 28;
-      this.cbVendorId.Text = "- autodetect -";
-      this.helpDeviceType.SetToolTip(this.cbVendorId, "Only set this value when autodetection isn\'t working");
-      // 
-      // cbVendorOverride
-      // 
-      this.cbVendorOverride.AutoSize = true;
-      this.cbVendorOverride.Location = new System.Drawing.Point(10, 156);
-      this.cbVendorOverride.Name = "cbVendorOverride";
-      this.cbVendorOverride.Size = new System.Drawing.Size(130, 17);
-      this.cbVendorOverride.TabIndex = 29;
-      this.cbVendorOverride.Text = "Override TV vendor id";
-      this.cbVendorOverride.UseVisualStyleBackColor = true;
-      // 
       // CecConfigGUI
       // 
       this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
index b1731cfa2c8dfdcae7bb92ece32b03fab0c9a482..83a83ac43c9564fc93e4688a893fe5c9d9943075 100644 (file)
@@ -381,8 +381,8 @@ namespace CecConfigGui
       SetControlEnabled(cbPowerOffOnStandby, val);
       SetControlEnabled(cbWakeDevices, false); // TODO not implemented yet
       SetControlEnabled(cbPowerOffDevices, false); // TODO not implemented yet
-      SetControlEnabled(cbVendorOverride, false); // TODO not implemented yet
-      SetControlEnabled(cbVendorId, false); // TODO not implemented yet
+      SetControlEnabled(cbVendorOverride, val);
+      SetControlEnabled(cbVendorId, val && cbVendorOverride.Checked);
       SetControlEnabled(bClose, val);
       SetControlEnabled(bSave, val);
 
@@ -466,10 +466,19 @@ namespace CecConfigGui
 
           if (dialog.ShowDialog() == DialogResult.OK)
           {
-            FileStream fs = (FileStream)dialog.OpenFile();
+            FileStream fs = null;
+            string error = string.Empty;
+            try
+            {
+              fs = (FileStream)dialog.OpenFile();
+            }
+            catch (Exception ex)
+            {
+              error = ex.Message;
+            }
             if (fs == null)
             {
-              MessageBox.Show("Cannot open '" + dialog.FileName + "' for writing", "Pulse-Eight USB-CEC Adapter", MessageBoxButtons.OK, MessageBoxIcon.Error);
+              MessageBox.Show("Cannot open '" + dialog.FileName + "' for writing" + (error.Length > 0 ? ": " + error : string.Empty ), "Pulse-Eight USB-CEC Adapter", MessageBoxButtons.OK, MessageBoxIcon.Error);
             }
             else
             {
@@ -523,6 +532,49 @@ namespace CecConfigGui
       }
       SetControlsEnabled(true);
     }
+
+    private void cbVendorOverride_CheckedChanged(object sender, EventArgs e)
+    {
+      if (cbVendorOverride.Checked)
+      {
+        cbVendorId.Enabled = true;
+        switch (cbVendorId.Text)
+        {
+          case "LG":
+            Config.TvVendor = CecVendorId.LG;
+            break;
+          case "Onkyo":
+            Config.TvVendor = CecVendorId.Onkyo;
+            break;
+          case "Panasonic":
+            Config.TvVendor = CecVendorId.Panasonic;
+            break;
+          case "Philips":
+            Config.TvVendor = CecVendorId.Philips;
+            break;
+          case "Pioneer":
+            Config.TvVendor = CecVendorId.Pioneer;
+            break;
+          case "Samsung":
+            Config.TvVendor = CecVendorId.Samsung;
+            break;
+          case "Sony":
+            Config.TvVendor = CecVendorId.Sony;
+            break;
+          case "Yamaha":
+            Config.TvVendor = CecVendorId.Yamaha;
+            break;
+          default:
+            Config.TvVendor = CecVendorId.Unknown;
+            break;
+        }
+      }
+      else
+      {
+        cbVendorId.Enabled = false;
+        Config.TvVendor = CecVendorId.Unknown;
+      }
+    }
     #endregion
 
     #region Key configuration tab
@@ -770,6 +822,32 @@ namespace CecConfigGui
       SetControlText(tbPhysicalAddress, string.Format("{0,4:X}", Config.PhysicalAddress));
       SetControlText(cbConnectedDevice, Config.BaseDevice == CecLogicalAddress.AudioSystem ? AVRVendorString : TVVendorString);
       SetControlText(cbPortNumber, Config.HDMIPort.ToString());
+      switch (config.DeviceTypes.Types[0])
+      {
+        case CecDeviceType.RecordingDevice:
+          SetControlText(cbDeviceType, "Recorder");
+          break;
+        case CecDeviceType.PlaybackDevice:
+          SetControlText(cbDeviceType, "Player");
+          break;
+        case CecDeviceType.Tuner:
+          SetControlText(cbDeviceType, "Tuner");
+          break;
+        default:
+          SetControlText(cbDeviceType, "Recorder");
+          break;
+      }
+      if (config.TvVendor != CecVendorId.Unknown)
+      {
+        SetCheckboxChecked(cbVendorOverride, true);
+        SetControlText(cbVendorId, Lib.ToString(config.TvVendor));
+      }
+      else
+      {
+        SetCheckboxChecked(cbVendorOverride, false);
+        SetControlText(cbVendorId, Lib.ToString(TVVendor));
+      }
+
       SetCheckboxChecked(cbUseTVMenuLanguage, Config.UseTVMenuLanguage);
       SetCheckboxChecked(cbActivateSource, Config.ActivateSource);
       SetCheckboxChecked(cbPowerOffScreensaver, Config.PowerOffScreensaver);
index b3aad3ea1adbbd1c7d15c91f6fac4522df093c5e..c49183f8df8c900ee5a656b5a800e313a5c373c7 100644 (file)
   <metadata name="cecButtonConfigBindingSource.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
     <value>662, 17</value>
   </metadata>
-  <metadata name="CecButtonName.UserAddedColumn" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
-    <value>True</value>
-  </metadata>
-  <metadata name="cecButtonConfigBindingSource.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
-    <value>662, 17</value>
-  </metadata>
-  <metadata name="helpPortNumber.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
-    <value>17, 17</value>
-  </metadata>
-  <metadata name="helpConnectedHDMIDevice.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
-    <value>160, 17</value>
-  </metadata>
-  <metadata name="helpPhysicalAddress.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
-    <value>362, 17</value>
-  </metadata>
 </root>
\ No newline at end of file
index 3bc4e7372767cbbdc3f632bc1b9c4a313ea0a46d..a76f1980dba888c6ac18679f189c4508da44a662 100644 (file)
@@ -1474,8 +1474,6 @@ bool CCECProcessor::SetConfiguration(const libcec_configuration *configuration)
 
 bool CCECProcessor::GetCurrentConfiguration(libcec_configuration *configuration)
 {
-  m_configuration.tvVendor = m_busDevices[CECDEVICE_TV]->GetVendorId();
-
   // client version 1.5.0
   configuration->clientVersion        = m_configuration.clientVersion;
   snprintf(configuration->strDeviceName, 13, "%s", m_configuration.strDeviceName);