From de90f347e13651ab1463bb2df4b19ff5ae46e3b0 Mon Sep 17 00:00:00 2001 From: Lars Op den Kamp Date: Wed, 15 Feb 2012 16:27:06 +0100 Subject: [PATCH] cec-config-gui: read/write the vendor id override setting --- src/LibCecSharp/CecSharpTypes.h | 1 + src/cec-config-gui/CecConfigGUI.Designer.cs | 67 ++++++++-------- src/cec-config-gui/CecConfigGUI.cs | 86 ++++++++++++++++++++- src/cec-config-gui/CecConfigGUI.resx | 15 ---- src/lib/CECProcessor.cpp | 2 - 5 files changed, 117 insertions(+), 54 deletions(-) diff --git a/src/LibCecSharp/CecSharpTypes.h b/src/LibCecSharp/CecSharpTypes.h index 212d818..39ef0cb 100644 --- a/src/LibCecSharp/CecSharpTypes.h +++ b/src/LibCecSharp/CecSharpTypes.h @@ -236,6 +236,7 @@ namespace CecSharp Onkyo = 0x09B0, Yamaha = 0xA0DE, Philips = 0x903E, + Sony = 0x080046, Unknown = 0 }; diff --git a/src/cec-config-gui/CecConfigGUI.Designer.cs b/src/cec-config-gui/CecConfigGUI.Designer.cs index c3d45e1..a5cda7e 100644 --- a/src/cec-config-gui/CecConfigGUI.Designer.cs +++ b/src/cec-config-gui/CecConfigGUI.Designer.cs @@ -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(); @@ -139,6 +139,38 @@ 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; @@ -707,37 +739,6 @@ 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); diff --git a/src/cec-config-gui/CecConfigGUI.cs b/src/cec-config-gui/CecConfigGUI.cs index b1731cf..83a83ac 100644 --- a/src/cec-config-gui/CecConfigGUI.cs +++ b/src/cec-config-gui/CecConfigGUI.cs @@ -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); diff --git a/src/cec-config-gui/CecConfigGUI.resx b/src/cec-config-gui/CecConfigGUI.resx index b3aad3e..c49183f 100644 --- a/src/cec-config-gui/CecConfigGUI.resx +++ b/src/cec-config-gui/CecConfigGUI.resx @@ -135,19 +135,4 @@ 662, 17 - - True - - - 662, 17 - - - 17, 17 - - - 160, 17 - - - 362, 17 - \ No newline at end of file diff --git a/src/lib/CECProcessor.cpp b/src/lib/CECProcessor.cpp index 3bc4e73..a76f198 100644 --- a/src/lib/CECProcessor.cpp +++ b/src/lib/CECProcessor.cpp @@ -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); -- 2.34.1