diff --git a/BizHawk.Client.EmuHawk/tools/VirtualPads/controls/VirtualPadAnalogStick.Designer.cs b/BizHawk.Client.EmuHawk/tools/VirtualPads/controls/VirtualPadAnalogStick.Designer.cs index c6a3467f80..0195077866 100644 --- a/BizHawk.Client.EmuHawk/tools/VirtualPads/controls/VirtualPadAnalogStick.Designer.cs +++ b/BizHawk.Client.EmuHawk/tools/VirtualPads/controls/VirtualPadAnalogStick.Designer.cs @@ -28,9 +28,9 @@ /// private void InitializeComponent() { - this.label1 = new System.Windows.Forms.Label(); + this.XLabel = new System.Windows.Forms.Label(); this.ManualX = new System.Windows.Forms.NumericUpDown(); - this.label2 = new System.Windows.Forms.Label(); + this.YLabel = new System.Windows.Forms.Label(); this.ManualY = new System.Windows.Forms.NumericUpDown(); this.MaxLabel = new System.Windows.Forms.Label(); this.MaxXNumeric = new System.Windows.Forms.NumericUpDown(); @@ -42,14 +42,14 @@ ((System.ComponentModel.ISupportInitialize)(this.MaxYNumeric)).BeginInit(); this.SuspendLayout(); // - // label1 + // XLabel // - this.label1.AutoSize = true; - this.label1.Location = new System.Drawing.Point(138, 7); - this.label1.Name = "label1"; - this.label1.Size = new System.Drawing.Size(14, 13); - this.label1.TabIndex = 23; - this.label1.Text = "X"; + this.XLabel.AutoSize = true; + this.XLabel.Location = new System.Drawing.Point(138, 7); + this.XLabel.Name = "XLabel"; + this.XLabel.Size = new System.Drawing.Size(14, 13); + this.XLabel.TabIndex = 23; + this.XLabel.Text = "X"; // // ManualX // @@ -70,14 +70,14 @@ this.ManualX.ValueChanged += new System.EventHandler(this.ManualX_ValueChanged); this.ManualX.KeyUp += new System.Windows.Forms.KeyEventHandler(this.ManualX_KeyUp); // - // label2 + // YLabel // - this.label2.AutoSize = true; - this.label2.Location = new System.Drawing.Point(138, 33); - this.label2.Name = "label2"; - this.label2.Size = new System.Drawing.Size(14, 13); - this.label2.TabIndex = 26; - this.label2.Text = "Y"; + this.YLabel.AutoSize = true; + this.YLabel.Location = new System.Drawing.Point(138, 33); + this.YLabel.Name = "YLabel"; + this.YLabel.Size = new System.Drawing.Size(14, 13); + this.YLabel.TabIndex = 26; + this.YLabel.Text = "Y"; // // ManualY // @@ -152,6 +152,8 @@ this.AnalogStick.BackColor = System.Drawing.Color.Gray; this.AnalogStick.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D; this.AnalogStick.Location = new System.Drawing.Point(3, 3); + this.AnalogStick.MaxX = 127; + this.AnalogStick.MaxY = 127; this.AnalogStick.Name = "AnalogStick"; this.AnalogStick.Size = new System.Drawing.Size(129, 129); this.AnalogStick.TabIndex = 0; @@ -165,10 +167,10 @@ this.Controls.Add(this.MaxYNumeric); this.Controls.Add(this.MaxXNumeric); this.Controls.Add(this.MaxLabel); - this.Controls.Add(this.label2); + this.Controls.Add(this.YLabel); this.Controls.Add(this.ManualY); this.Controls.Add(this.ManualX); - this.Controls.Add(this.label1); + this.Controls.Add(this.XLabel); this.Controls.Add(this.AnalogStick); this.Name = "VirtualPadAnalogStick"; this.Size = new System.Drawing.Size(204, 136); @@ -185,9 +187,9 @@ #endregion private AnalogStickPanel AnalogStick; - private System.Windows.Forms.Label label1; + private System.Windows.Forms.Label XLabel; private System.Windows.Forms.NumericUpDown ManualX; - private System.Windows.Forms.Label label2; + private System.Windows.Forms.Label YLabel; private System.Windows.Forms.NumericUpDown ManualY; private System.Windows.Forms.Label MaxLabel; private System.Windows.Forms.NumericUpDown MaxXNumeric; diff --git a/BizHawk.Client.EmuHawk/tools/VirtualPads/controls/VirtualPadAnalogStick.cs b/BizHawk.Client.EmuHawk/tools/VirtualPads/controls/VirtualPadAnalogStick.cs index 9a500ed8c4..96136b7b70 100644 --- a/BizHawk.Client.EmuHawk/tools/VirtualPads/controls/VirtualPadAnalogStick.cs +++ b/BizHawk.Client.EmuHawk/tools/VirtualPads/controls/VirtualPadAnalogStick.cs @@ -14,6 +14,7 @@ namespace BizHawk.Client.EmuHawk public partial class VirtualPadAnalogStick : UserControl, IVirtualPadControl { private bool _programmaticallyUpdatingNumerics = false; + private bool _readonly = false; public VirtualPadAnalogStick() { @@ -46,8 +47,33 @@ namespace BizHawk.Client.EmuHawk public bool ReadOnly { - get; - set; // TODO + get + { + return _readonly; + } + + set + { + var changed = _readonly != value; + + XLabel.Enabled = + ManualX.Enabled = + YLabel.Enabled = + ManualY.Enabled = + MaxLabel.Enabled = + MaxXNumeric.Enabled = + MaxYNumeric.Enabled = + !value; + + AnalogStick.Readonly = + _readonly = + value; + + if (changed) + { + Refresh(); + } + } } #endregion @@ -94,16 +120,22 @@ namespace BizHawk.Client.EmuHawk private void AnalogStick_MouseDown(object sender, MouseEventArgs e) { - _programmaticallyUpdatingNumerics = true; - SetNumericsFromAnalog(); - _programmaticallyUpdatingNumerics = false; + if (!ReadOnly) + { + _programmaticallyUpdatingNumerics = true; + SetNumericsFromAnalog(); + _programmaticallyUpdatingNumerics = false; + } } private void AnalogStick_MouseMove(object sender, MouseEventArgs e) { - _programmaticallyUpdatingNumerics = true; - SetNumericsFromAnalog(); - _programmaticallyUpdatingNumerics = false; + if (!ReadOnly) + { + _programmaticallyUpdatingNumerics = true; + SetNumericsFromAnalog(); + _programmaticallyUpdatingNumerics = false; + } } private void MaxXNumeric_ValueChanged(object sender, EventArgs e) diff --git a/BizHawk.Client.EmuHawk/tools/VirtualPads/controls/components/AnalogSticklPanel.cs b/BizHawk.Client.EmuHawk/tools/VirtualPads/controls/components/AnalogSticklPanel.cs index c4ba1a07c6..0421ebf63c 100644 --- a/BizHawk.Client.EmuHawk/tools/VirtualPads/controls/components/AnalogSticklPanel.cs +++ b/BizHawk.Client.EmuHawk/tools/VirtualPads/controls/components/AnalogSticklPanel.cs @@ -11,6 +11,7 @@ namespace BizHawk.Client.EmuHawk public int X = 0; public int Y = 0; public bool HasValue = false; + public bool Readonly { get; set; } public string XName = string.Empty; public string YName = string.Empty; @@ -153,20 +154,23 @@ namespace BizHawk.Client.EmuHawk protected override void OnMouseMove(MouseEventArgs e) { - if (e.Button == MouseButtons.Left) + if (!Readonly) { - X = GFXToReal(e.X - 64, true); - Y = GFXToReal(-(e.Y - 63), false); - HasValue = true; - SetAnalog(); - } - else if (e.Button == MouseButtons.Right) - { - Clear(); - } + if (e.Button == MouseButtons.Left) + { + X = GFXToReal(e.X - 64, true); + Y = GFXToReal(-(e.Y - 63), false); + HasValue = true; + SetAnalog(); + } + else if (e.Button == MouseButtons.Right) + { + Clear(); + } - Refresh(); - base.OnMouseMove(e); + Refresh(); + base.OnMouseMove(e); + } } protected override void OnMouseUp(MouseEventArgs e) @@ -188,18 +192,21 @@ namespace BizHawk.Client.EmuHawk protected override void OnMouseDown(MouseEventArgs e) { - if (e.Button == MouseButtons.Left) + if (!Readonly) { - X = GFXToReal(e.X - 64, true); - Y = GFXToReal(-(e.Y - 63), false); - HasValue = true; - } - if (e.Button == MouseButtons.Right) - { - Clear(); - } + if (e.Button == MouseButtons.Left) + { + X = GFXToReal(e.X - 64, true); + Y = GFXToReal(-(e.Y - 63), false); + HasValue = true; + } + if (e.Button == MouseButtons.Right) + { + Clear(); + } - Refresh(); + Refresh(); + } }