deadzones for analog bind. seems to work ok with my old ps2 controller, which has a slight lean to left on the left stick
This commit is contained in:
parent
4249860f0b
commit
58087b24c9
|
@ -702,10 +702,13 @@ namespace BizHawk.MultiClient
|
|||
public string Value;
|
||||
/// <summary>sensitivity and flip</summary>
|
||||
public float Mult;
|
||||
public AnalogBind(string Value, float Mult)
|
||||
/// <summary>portion of axis to ignore</summary>
|
||||
public float Deadzone;
|
||||
public AnalogBind(string Value, float Mult, float Deadzone)
|
||||
{
|
||||
this.Value = Value;
|
||||
this.Mult = Mult;
|
||||
this.Deadzone = Deadzone;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -92,11 +92,27 @@ namespace BizHawk.MultiClient
|
|||
float input = controller.GetFloat(kvp.Value.Value);
|
||||
string outkey = kvp.Key;
|
||||
float multiplier = kvp.Value.Mult;
|
||||
float deadzone = kvp.Value.Deadzone;
|
||||
ControllerDefinition.FloatRange range;
|
||||
if (FloatRanges.TryGetValue(outkey, out range))
|
||||
{
|
||||
// input range is assumed to be -10000,0,10000
|
||||
// todo: deadzones and such
|
||||
|
||||
// first, modify for deadzone
|
||||
{
|
||||
float absinput = Math.Abs(input);
|
||||
float zeropoint = deadzone * 10000.0f;
|
||||
if (absinput < zeropoint)
|
||||
input = 0.0f;
|
||||
else
|
||||
{
|
||||
absinput -= zeropoint;
|
||||
absinput *= 10000.0f;
|
||||
absinput /= (10000.0f - zeropoint);
|
||||
input = absinput * Math.Sign(input);
|
||||
}
|
||||
}
|
||||
|
||||
float output = (input * multiplier + 10000.0f) * (range.Max - range.Min) / 20000.0f + range.Min;
|
||||
if (output < range.Min) output = range.Min;
|
||||
if (output > range.Max) output = range.Max;
|
||||
|
|
|
@ -35,7 +35,10 @@
|
|||
this.labelSensitivity = new System.Windows.Forms.Label();
|
||||
this.timer1 = new System.Windows.Forms.Timer(this.components);
|
||||
this.buttonBind = new System.Windows.Forms.Button();
|
||||
this.trackBarDeadzone = new System.Windows.Forms.TrackBar();
|
||||
this.labelDeadzone = new System.Windows.Forms.Label();
|
||||
((System.ComponentModel.ISupportInitialize)(this.trackBarSensitivity)).BeginInit();
|
||||
((System.ComponentModel.ISupportInitialize)(this.trackBarDeadzone)).BeginInit();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// textBox1
|
||||
|
@ -58,7 +61,7 @@
|
|||
// trackBarSensitivity
|
||||
//
|
||||
this.trackBarSensitivity.LargeChange = 20;
|
||||
this.trackBarSensitivity.Location = new System.Drawing.Point(169, 3);
|
||||
this.trackBarSensitivity.Location = new System.Drawing.Point(267, 3);
|
||||
this.trackBarSensitivity.Maximum = 20;
|
||||
this.trackBarSensitivity.Minimum = -20;
|
||||
this.trackBarSensitivity.Name = "trackBarSensitivity";
|
||||
|
@ -71,7 +74,7 @@
|
|||
// labelSensitivity
|
||||
//
|
||||
this.labelSensitivity.AutoSize = true;
|
||||
this.labelSensitivity.Location = new System.Drawing.Point(3, 26);
|
||||
this.labelSensitivity.Location = new System.Drawing.Point(166, 6);
|
||||
this.labelSensitivity.Name = "labelSensitivity";
|
||||
this.labelSensitivity.Size = new System.Drawing.Size(95, 13);
|
||||
this.labelSensitivity.TabIndex = 3;
|
||||
|
@ -83,7 +86,7 @@
|
|||
//
|
||||
// buttonBind
|
||||
//
|
||||
this.buttonBind.Location = new System.Drawing.Point(279, 1);
|
||||
this.buttonBind.Location = new System.Drawing.Point(3, 29);
|
||||
this.buttonBind.Name = "buttonBind";
|
||||
this.buttonBind.Size = new System.Drawing.Size(75, 23);
|
||||
this.buttonBind.TabIndex = 4;
|
||||
|
@ -91,18 +94,38 @@
|
|||
this.buttonBind.UseVisualStyleBackColor = true;
|
||||
this.buttonBind.Click += new System.EventHandler(this.buttonBind_Click);
|
||||
//
|
||||
// trackBarDeadzone
|
||||
//
|
||||
this.trackBarDeadzone.Location = new System.Drawing.Point(267, 51);
|
||||
this.trackBarDeadzone.Name = "trackBarDeadzone";
|
||||
this.trackBarDeadzone.Size = new System.Drawing.Size(104, 42);
|
||||
this.trackBarDeadzone.TabIndex = 5;
|
||||
this.trackBarDeadzone.ValueChanged += new System.EventHandler(this.trackBarDeadzone_ValueChanged);
|
||||
//
|
||||
// labelDeadzone
|
||||
//
|
||||
this.labelDeadzone.AutoSize = true;
|
||||
this.labelDeadzone.Location = new System.Drawing.Point(166, 60);
|
||||
this.labelDeadzone.Name = "labelDeadzone";
|
||||
this.labelDeadzone.Size = new System.Drawing.Size(97, 13);
|
||||
this.labelDeadzone.TabIndex = 6;
|
||||
this.labelDeadzone.Text = "Deadzone: 5 billion";
|
||||
//
|
||||
// AnalogBindControl
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.Controls.Add(this.labelDeadzone);
|
||||
this.Controls.Add(this.trackBarDeadzone);
|
||||
this.Controls.Add(this.buttonBind);
|
||||
this.Controls.Add(this.labelSensitivity);
|
||||
this.Controls.Add(this.trackBarSensitivity);
|
||||
this.Controls.Add(this.labelButtonName);
|
||||
this.Controls.Add(this.textBox1);
|
||||
this.Name = "AnalogBindControl";
|
||||
this.Size = new System.Drawing.Size(387, 43);
|
||||
this.Size = new System.Drawing.Size(378, 99);
|
||||
((System.ComponentModel.ISupportInitialize)(this.trackBarSensitivity)).EndInit();
|
||||
((System.ComponentModel.ISupportInitialize)(this.trackBarDeadzone)).EndInit();
|
||||
this.ResumeLayout(false);
|
||||
this.PerformLayout();
|
||||
|
||||
|
@ -116,5 +139,7 @@
|
|||
private System.Windows.Forms.Label labelSensitivity;
|
||||
private System.Windows.Forms.Timer timer1;
|
||||
private System.Windows.Forms.Button buttonBind;
|
||||
private System.Windows.Forms.TrackBar trackBarDeadzone;
|
||||
private System.Windows.Forms.Label labelDeadzone;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -27,6 +27,9 @@ namespace BizHawk.MultiClient.config.ControllerConfig
|
|||
this.ButtonName = ButtonName;
|
||||
labelButtonName.Text = ButtonName;
|
||||
trackBarSensitivity.Value = (int)(Bind.Mult * 10.0f);
|
||||
trackBarDeadzone.Value = (int)(Bind.Deadzone * 10.0f);
|
||||
trackBarSensitivity_ValueChanged(null, null);
|
||||
trackBarDeadzone_ValueChanged(null, null);
|
||||
textBox1.Text = Bind.Value;
|
||||
}
|
||||
|
||||
|
@ -67,5 +70,11 @@ namespace BizHawk.MultiClient.config.ControllerConfig
|
|||
Bind.Mult = trackBarSensitivity.Value / 10.0f;
|
||||
labelSensitivity.Text = string.Format("Sensitivity: {0}", Bind.Mult);
|
||||
}
|
||||
|
||||
private void trackBarDeadzone_ValueChanged(object sender, EventArgs e)
|
||||
{
|
||||
Bind.Deadzone = trackBarDeadzone.Value / 10.0f;
|
||||
labelDeadzone.Text = string.Format("Deadzone: {0}", Bind.Deadzone);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -153,7 +153,7 @@ namespace BizHawk.MultiClient.config
|
|||
{
|
||||
LoadToPanel(tabPage1, the_definition.Name, the_definition.BoolButtons, Global.Config.AllTrollers, "", CreateNormalPanel);
|
||||
LoadToPanel(tabPage2, the_definition.Name, the_definition.BoolButtons, Global.Config.AllTrollersAutoFire, "", CreateNormalPanel);
|
||||
LoadToPanel(tabPage3, the_definition.Name, the_definition.FloatControls, Global.Config.AllTrollersAnalog, new Config.AnalogBind("", 1.0f), CreateAnalogPanel);
|
||||
LoadToPanel(tabPage3, the_definition.Name, the_definition.FloatControls, Global.Config.AllTrollersAnalog, new Config.AnalogBind("", 1.0f, 0.0f), CreateAnalogPanel);
|
||||
|
||||
if (tabPage3.Controls.Count == 0)
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue