Skip to content
This repository
Browse code

cec-config-gui: make overriding the physical address optional

  • Loading branch information...
commit 66609663d93f48b37fa79647e339ab48a70f73d8 1 parent 099a04f
Lars Op den Kamp opdenkamp authored
77 src/cec-config-gui/CecConfigGUI.Designer.cs
@@ -31,21 +31,21 @@ private void InitializeComponent()
31 31 this.cbActivateSource = new System.Windows.Forms.CheckBox();
32 32 this.cbUseTVMenuLanguage = new System.Windows.Forms.CheckBox();
33 33 this.lPlayerConfig = new System.Windows.Forms.Label();
  34 + this.lAdapterConfig = new System.Windows.Forms.Label();
34 35 this.cbDeviceType = new System.Windows.Forms.ComboBox();
35 36 this.bClose = new System.Windows.Forms.Button();
36 37 this.bSaveConfig = new System.Windows.Forms.Button();
37 38 this.cbPortNumber = new System.Windows.Forms.ComboBox();
  39 + this.lConnectedPhysicalAddress = new System.Windows.Forms.Label();
38 40 this.tbPhysicalAddress = new System.Windows.Forms.TextBox();
39 41 this.cbConnectedDevice = new System.Windows.Forms.ComboBox();
40 42 this.lDeviceType = new System.Windows.Forms.Label();
41   - this.lPhysicalAddress = new System.Windows.Forms.Label();
42 43 this.lConnectedDevice = new System.Windows.Forms.Label();
43 44 this.lPortNumber = new System.Windows.Forms.Label();
44 45 this.tbButtons = new System.Windows.Forms.TabPage();
45 46 this.label1 = new System.Windows.Forms.Label();
46 47 this.dgButtons = new System.Windows.Forms.DataGridView();
47 48 this.CecButtonName = new System.Windows.Forms.DataGridViewTextBoxColumn();
48   - this.playerButtonDataGridViewTextBoxColumn = new System.Windows.Forms.DataGridViewTextBoxColumn();
49 49 this.cecButtonConfigBindingSource = new System.Windows.Forms.BindingSource(this.components);
50 50 this.tbTestCommands = new System.Windows.Forms.TabPage();
51 51 this.bRescanDevices = new System.Windows.Forms.Button();
@@ -73,8 +73,7 @@ private void InitializeComponent()
73 73 this.helpConnectedHDMIDevice = new System.Windows.Forms.ToolTip(this.components);
74 74 this.helpPhysicalAddress = new System.Windows.Forms.ToolTip(this.components);
75 75 this.helpDeviceType = new System.Windows.Forms.ToolTip(this.components);
76   - this.lConnectedPhysicalAddress = new System.Windows.Forms.Label();
77   - this.lAdapterConfig = new System.Windows.Forms.Label();
  76 + this.cbOverrideAddress = new System.Windows.Forms.CheckBox();
78 77 this.tabControl1.SuspendLayout();
79 78 this.Configuration.SuspendLayout();
80 79 this.tbButtons.SuspendLayout();
@@ -99,6 +98,7 @@ private void InitializeComponent()
99 98 //
100 99 // Configuration
101 100 //
  101 + this.Configuration.Controls.Add(this.cbOverrideAddress);
102 102 this.Configuration.Controls.Add(this.bReloadConfig);
103 103 this.Configuration.Controls.Add(this.cbVendorOverride);
104 104 this.Configuration.Controls.Add(this.cbVendorId);
@@ -120,7 +120,6 @@ private void InitializeComponent()
120 120 this.Configuration.Controls.Add(this.tbPhysicalAddress);
121 121 this.Configuration.Controls.Add(this.cbConnectedDevice);
122 122 this.Configuration.Controls.Add(this.lDeviceType);
123   - this.Configuration.Controls.Add(this.lPhysicalAddress);
124 123 this.Configuration.Controls.Add(this.lConnectedDevice);
125 124 this.Configuration.Controls.Add(this.lPortNumber);
126 125 this.Configuration.Location = new System.Drawing.Point(4, 22);
@@ -299,6 +298,16 @@ private void InitializeComponent()
299 298 this.lPlayerConfig.TabIndex = 16;
300 299 this.lPlayerConfig.Text = "Player Configuration";
301 300 //
  301 + // lAdapterConfig
  302 + //
  303 + this.lAdapterConfig.AutoSize = true;
  304 + this.lAdapterConfig.Font = new System.Drawing.Font("Microsoft Sans Serif", 14.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
  305 + this.lAdapterConfig.Location = new System.Drawing.Point(6, 3);
  306 + this.lAdapterConfig.Name = "lAdapterConfig";
  307 + this.lAdapterConfig.Size = new System.Drawing.Size(213, 24);
  308 + this.lAdapterConfig.TabIndex = 15;
  309 + this.lAdapterConfig.Text = "Adapter Configuration";
  310 + //
302 311 // cbDeviceType
303 312 //
304 313 this.cbDeviceType.Enabled = false;
@@ -355,6 +364,15 @@ private void InitializeComponent()
355 364 this.helpPortNumber.SetToolTip(this.cbPortNumber, "The HDMI port number, to which you connected your USB-CEC adapter.");
356 365 this.cbPortNumber.SelectedIndexChanged += new System.EventHandler(this.connectedDevice_SelectedIndexChanged);
357 366 //
  367 + // lConnectedPhysicalAddress
  368 + //
  369 + this.lConnectedPhysicalAddress.AutoSize = true;
  370 + this.lConnectedPhysicalAddress.Location = new System.Drawing.Point(340, 71);
  371 + this.lConnectedPhysicalAddress.Name = "lConnectedPhysicalAddress";
  372 + this.lConnectedPhysicalAddress.Size = new System.Drawing.Size(75, 13);
  373 + this.lConnectedPhysicalAddress.TabIndex = 10;
  374 + this.lConnectedPhysicalAddress.Text = "Address: 0000";
  375 + //
358 376 // tbPhysicalAddress
359 377 //
360 378 this.tbPhysicalAddress.Enabled = false;
@@ -389,15 +407,6 @@ private void InitializeComponent()
389 407 this.lDeviceType.TabIndex = 3;
390 408 this.lDeviceType.Text = "Device type";
391 409 //
392   - // lPhysicalAddress
393   - //
394   - this.lPhysicalAddress.AutoSize = true;
395   - this.lPhysicalAddress.Location = new System.Drawing.Point(6, 98);
396   - this.lPhysicalAddress.Name = "lPhysicalAddress";
397   - this.lPhysicalAddress.Size = new System.Drawing.Size(86, 13);
398   - this.lPhysicalAddress.TabIndex = 2;
399   - this.lPhysicalAddress.Text = "Physical address";
400   - //
401 410 // lConnectedDevice
402 411 //
403 412 this.lConnectedDevice.AutoSize = true;
@@ -448,8 +457,7 @@ private void InitializeComponent()
448 457 this.dgButtons.AutoGenerateColumns = false;
449 458 this.dgButtons.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.DisableResizing;
450 459 this.dgButtons.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] {
451   - this.CecButtonName,
452   - this.playerButtonDataGridViewTextBoxColumn});
  460 + this.CecButtonName});
453 461 this.dgButtons.DataSource = this.cecButtonConfigBindingSource;
454 462 this.dgButtons.Location = new System.Drawing.Point(7, 7);
455 463 this.dgButtons.Name = "dgButtons";
@@ -467,14 +475,6 @@ private void InitializeComponent()
467 475 this.CecButtonName.ReadOnly = true;
468 476 this.CecButtonName.Width = 260;
469 477 //
470   - // playerButtonDataGridViewTextBoxColumn
471   - //
472   - this.playerButtonDataGridViewTextBoxColumn.DataPropertyName = "PlayerButton";
473   - this.playerButtonDataGridViewTextBoxColumn.FillWeight = 260F;
474   - this.playerButtonDataGridViewTextBoxColumn.HeaderText = "Mapped to";
475   - this.playerButtonDataGridViewTextBoxColumn.Name = "playerButtonDataGridViewTextBoxColumn";
476   - this.playerButtonDataGridViewTextBoxColumn.Width = 260;
477   - //
478 478 // cecButtonConfigBindingSource
479 479 //
480 480 this.cecButtonConfigBindingSource.DataSource = typeof(CecConfigGui.CecButtonConfig);
@@ -733,24 +733,17 @@ private void InitializeComponent()
733 733 this.lStatus.TabIndex = 2;
734 734 this.lStatus.Text = "Initialising...";
735 735 //
736   - // lConnectedPhysicalAddress
737   - //
738   - this.lConnectedPhysicalAddress.AutoSize = true;
739   - this.lConnectedPhysicalAddress.Location = new System.Drawing.Point(340, 71);
740   - this.lConnectedPhysicalAddress.Name = "lConnectedPhysicalAddress";
741   - this.lConnectedPhysicalAddress.Size = new System.Drawing.Size(75, 13);
742   - this.lConnectedPhysicalAddress.TabIndex = 10;
743   - this.lConnectedPhysicalAddress.Text = "Address: 0000";
744   - //
745   - // lAdapterConfig
  736 + // cbOverrideAddress
746 737 //
747   - this.lAdapterConfig.AutoSize = true;
748   - this.lAdapterConfig.Font = new System.Drawing.Font("Microsoft Sans Serif", 14.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
749   - this.lAdapterConfig.Location = new System.Drawing.Point(6, 3);
750   - this.lAdapterConfig.Name = "lAdapterConfig";
751   - this.lAdapterConfig.Size = new System.Drawing.Size(213, 24);
752   - this.lAdapterConfig.TabIndex = 15;
753   - this.lAdapterConfig.Text = "Adapter Configuration";
  738 + this.cbOverrideAddress.AutoSize = true;
  739 + this.cbOverrideAddress.Enabled = false;
  740 + this.cbOverrideAddress.Location = new System.Drawing.Point(10, 97);
  741 + this.cbOverrideAddress.Name = "cbOverrideAddress";
  742 + this.cbOverrideAddress.Size = new System.Drawing.Size(147, 17);
  743 + this.cbOverrideAddress.TabIndex = 31;
  744 + this.cbOverrideAddress.Text = "Override physical address";
  745 + this.cbOverrideAddress.UseVisualStyleBackColor = true;
  746 + this.cbOverrideAddress.CheckedChanged += new System.EventHandler(this.cbOverrideAddress_CheckedChanged);
754 747 //
755 748 // CecConfigGUI
756 749 //
@@ -788,7 +781,6 @@ private void InitializeComponent()
788 781 private System.Windows.Forms.TabPage LogOutput;
789 782 private System.Windows.Forms.Label lPortNumber;
790 783 private System.Windows.Forms.Label lDeviceType;
791   - private System.Windows.Forms.Label lPhysicalAddress;
792 784 private System.Windows.Forms.Label lConnectedDevice;
793 785 private System.Windows.Forms.ComboBox cbConnectedDevice;
794 786 private System.Windows.Forms.TextBox tbPhysicalAddress;
@@ -841,5 +833,6 @@ private void InitializeComponent()
841 833 private System.Windows.Forms.Button bRescanDevices;
842 834 private System.Windows.Forms.Label lConnectedPhysicalAddress;
843 835 private System.Windows.Forms.Label lAdapterConfig;
  836 + private System.Windows.Forms.CheckBox cbOverrideAddress;
844 837 }
845 838 }
23 src/cec-config-gui/CecConfigGUI.cs
@@ -326,7 +326,8 @@ private void SetControlsEnabled(bool val)
326 326 {
327 327 SetControlEnabled(cbPortNumber, val && !Config.AutodetectAddress);
328 328 SetControlEnabled(cbConnectedDevice, cbConnectedDevice.Items.Count > 1 && !Config.AutodetectAddress ? val : false);
329   - SetControlEnabled(tbPhysicalAddress, val && !Config.AutodetectAddress);
  329 + SetControlEnabled(cbOverrideAddress, val);
  330 + SetControlEnabled(tbPhysicalAddress, val && !Config.AutodetectAddress && cbOverrideAddress.Checked);
330 331 SetControlEnabled(cbDeviceType, val);
331 332 SetControlEnabled(cbUseTVMenuLanguage, val);
332 333 SetControlEnabled(cbActivateSource, val);
@@ -413,7 +414,7 @@ public void UpdateInfoPanel(DeviceInformation panel)
413 414
414 415 public void SetPhysicalAddress(ushort physicalAddress)
415 416 {
416   - if (!SuppressUpdates && ActiveProcess == null)
  417 + if (!SuppressUpdates && ActiveProcess == null && cbOverrideAddress.Checked)
417 418 {
418 419 SetControlsEnabled(false);
419 420 SetControlText(cbPortNumber, string.Empty);
@@ -481,9 +482,15 @@ public void ShowDeviceInfo(CecLogicalAddress address)
481 482 #endregion
482 483
483 484 #region Configuration tab
  485 + private void cbOverrideAddress_CheckedChanged(object sender, EventArgs e)
  486 + {
  487 + SetControlEnabled(tbPhysicalAddress, ((CheckBox)sender).Checked);
  488 + }
  489 +
484 490 private void tbPhysicalAddress_TextChanged(object sender, EventArgs e)
485 491 {
486   - if (tbPhysicalAddress.Text.Length != 4)
  492 + if (tbPhysicalAddress.Text.Length != 4 ||
  493 + cbOverrideAddress.Checked)
487 494 return;
488 495 ushort physicalAddress = 0;
489 496 if (!ushort.TryParse(tbPhysicalAddress.Text, NumberStyles.AllowHexSpecifier, null, out physicalAddress))
@@ -583,20 +590,24 @@ private void bSave_Click(object sender, EventArgs e)
583 590 // only supported by 1.5.0+ clients
584 591 output.AppendLine("<!-- the following lines are only supported by v1.5.0+ clients -->");
585 592 output.AppendLine("<setting id=\"activate_source\" value=\"" + (Config.ActivateSource ? 1 : 0) + "\" />");
586   - output.AppendLine("<setting id=\"physical_address\" value=\"" + string.Format("{0,4:X}", Config.PhysicalAddress) + "\" />");
  593 + output.AppendLine("<setting id=\"physical_address\" value=\"" + string.Format("{0,4:X}", cbOverrideAddress.Checked ? Config.PhysicalAddress : 0).Trim() + "\" />");
587 594 output.AppendLine("<setting id=\"device_type\" value=\"" + (int)Config.DeviceTypes.Types[0] + "\" />");
588 595 output.AppendLine("<setting id=\"tv_vendor\" value=\"" + string.Format("{0,6:X}", (int)Config.TvVendor).Trim() + "\" />");
589 596
590 597 output.Append("<setting id=\"wake_devices\" value=\"");
  598 + StringBuilder strWakeDevices = new StringBuilder();
591 599 foreach (CecLogicalAddress addr in Config.WakeDevices.Addresses)
592 600 if (addr != CecLogicalAddress.Unknown)
593   - output.Append(" " + (int)addr);
  601 + strWakeDevices.Append(" " + (int)addr);
  602 + output.Append(strWakeDevices.ToString().Trim());
594 603 output.AppendLine("\" />");
595 604
596 605 output.Append("<setting id=\"standby_devices\" value=\"");
  606 + StringBuilder strSleepDevices = new StringBuilder();
597 607 foreach (CecLogicalAddress addr in Config.PowerOffDevices.Addresses)
598 608 if (addr != CecLogicalAddress.Unknown)
599   - output.Append(" " + (int)addr);
  609 + strSleepDevices.Append(" " + (int)addr);
  610 + output.Append(strSleepDevices.ToString().Trim());
600 611 output.AppendLine("\" />");
601 612
602 613 output.AppendLine("</settings>");

0 comments on commit 6660966

Please sign in to comment.
Something went wrong with that request. Please try again.