more analog controller stuff
This commit is contained in:
parent
fdb8098f90
commit
66f4e10e9e
|
@ -206,7 +206,9 @@
|
|||
<DependentUpon>PathInfo.cs</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="config\PathManager.cs" />
|
||||
<Compile Include="config\RewindConfig.cs" />
|
||||
<Compile Include="config\RewindConfig.cs">
|
||||
<SubType>Form</SubType>
|
||||
</Compile>
|
||||
<Compile Include="config\RewindConfig.Designer.cs">
|
||||
<DependentUpon>RewindConfig.cs</DependentUpon>
|
||||
</Compile>
|
||||
|
|
|
@ -692,9 +692,23 @@ namespace BizHawk.MultiClient
|
|||
public const int NESNoiseMax = 247;
|
||||
public const int NESDMCMax = 167;
|
||||
|
||||
// [ControllerType][ControllerName] => Bind
|
||||
public class AnalogBind
|
||||
{
|
||||
/// <summary>the physical stick that we're bound to</summary>
|
||||
public string Value;
|
||||
/// <summary>sensitivity and flip</summary>
|
||||
public float Mult;
|
||||
public AnalogBind(string Value, float Mult)
|
||||
{
|
||||
this.Value = Value;
|
||||
this.Mult = Mult;
|
||||
}
|
||||
}
|
||||
|
||||
// [ControllerType][ButtonName] => Physical Bind
|
||||
public Dictionary<string, Dictionary<string, string>> AllTrollers = new Dictionary<string, Dictionary<string, string>>();
|
||||
public Dictionary<string, Dictionary<string, string>> AllTrollersAutoFire = new Dictionary<string, Dictionary<string, string>>();
|
||||
public Dictionary<string, Dictionary<string, AnalogBind>> AllTrollersAnalog = new Dictionary<string, Dictionary<string, AnalogBind>>();
|
||||
|
||||
// SMS / GameGear Settings
|
||||
public bool SmsEnableFM = true;
|
||||
|
|
|
@ -14,7 +14,7 @@ namespace BizHawk.MultiClient
|
|||
|
||||
private readonly Dictionary<string, ControllerDefinition.FloatRange> FloatRanges = new WorkingDictionary<string, ControllerDefinition.FloatRange>();
|
||||
|
||||
private readonly Dictionary<string, string> FloatBinds = new Dictionary<string, string>();
|
||||
private readonly Dictionary<string, Config.AnalogBind> FloatBinds = new Dictionary<string, Config.AnalogBind>();
|
||||
|
||||
public Controller(ControllerDefinition definition)
|
||||
{
|
||||
|
@ -24,8 +24,8 @@ namespace BizHawk.MultiClient
|
|||
FloatButtons[type.FloatControls[i]] = type.FloatRanges[i].Mid;
|
||||
FloatRanges[type.FloatControls[i]] = type.FloatRanges[i];
|
||||
}
|
||||
FloatBinds.Add("J1 X", "P1 X Axis");
|
||||
FloatBinds.Add("J1 Y", "P1 Y Axis");
|
||||
FloatBinds.Add("J5 X", new Config.AnalogBind("P1 X Axis", 1.0f));
|
||||
FloatBinds.Add("J5 Y", new Config.AnalogBind("P1 Y Axis", -1.0f));
|
||||
}
|
||||
|
||||
public ControllerDefinition Type { get { return type; } }
|
||||
|
@ -90,13 +90,14 @@ namespace BizHawk.MultiClient
|
|||
foreach (var kvp in FloatBinds)
|
||||
{
|
||||
float input = controller.GetFloat(kvp.Key);
|
||||
string outkey = kvp.Value;
|
||||
string outkey = kvp.Value.Value;
|
||||
float multiplier = kvp.Value.Mult;
|
||||
ControllerDefinition.FloatRange range;
|
||||
if (FloatRanges.TryGetValue(outkey, out range))
|
||||
{
|
||||
// input range is assumed to be -10000,0,10000
|
||||
// this is where deadzone, axis flip, sensitivity would be implemented
|
||||
FloatButtons[outkey] = (input + 10000.0f) * (range.Max - range.Min) / 20000.0f + range.Min;
|
||||
// todo: deadzones and such
|
||||
FloatButtons[outkey] = (input * multiplier + 10000.0f) * (range.Max - range.Min) / 20000.0f + range.Min;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -207,6 +207,7 @@ namespace BizHawk.MultiClient.config
|
|||
ControlDefaults cd = new ControlDefaults();
|
||||
cd = ConfigService.Load(ControlDefaultPath, cd);
|
||||
Dictionary<string, string> settings;
|
||||
Dictionary<string, Config.AnalogBind> asettings;
|
||||
if (cd.AllTrollers.TryGetValue(ControllerType, out settings))
|
||||
Global.Config.AllTrollers[ControllerType] = settings;
|
||||
else
|
||||
|
@ -215,6 +216,10 @@ namespace BizHawk.MultiClient.config
|
|||
Global.Config.AllTrollersAutoFire[ControllerType] = settings;
|
||||
else
|
||||
Global.Config.AllTrollersAutoFire[ControllerType].Clear();
|
||||
if (cd.AllTrollersAnalog.TryGetValue(ControllerType, out asettings))
|
||||
Global.Config.AllTrollersAnalog[ControllerType] = asettings;
|
||||
else
|
||||
Global.Config.AllTrollersAnalog[ControllerType].Clear();
|
||||
|
||||
Global.OSD.AddMessage("Default controls loaded");
|
||||
DialogResult = System.Windows.Forms.DialogResult.OK;
|
||||
|
@ -230,6 +235,7 @@ namespace BizHawk.MultiClient.config
|
|||
ControlDefaults cd = new ControlDefaults();
|
||||
cd.AllTrollers = Global.Config.AllTrollers;
|
||||
cd.AllTrollersAutoFire = Global.Config.AllTrollersAutoFire;
|
||||
cd.AllTrollersAnalog = Global.Config.AllTrollersAnalog;
|
||||
ConfigService.Save(ControlDefaultPath, cd);
|
||||
}
|
||||
}
|
||||
|
@ -238,16 +244,18 @@ namespace BizHawk.MultiClient.config
|
|||
{
|
||||
public Dictionary<string, Dictionary<string, string>> AllTrollers = new Dictionary<string, Dictionary<string, string>>();
|
||||
public Dictionary<string, Dictionary<string, string>> AllTrollersAutoFire = new Dictionary<string, Dictionary<string, string>>();
|
||||
public Dictionary<string, Dictionary<string, Config.AnalogBind>> AllTrollersAnalog = new Dictionary<string, Dictionary<string, Config.AnalogBind>>();
|
||||
}
|
||||
|
||||
public static void ConfigCheckAllControlDefaults(Config c)
|
||||
{
|
||||
if (c.AllTrollers.Count == 0 && c.AllTrollersAutoFire.Count == 0)
|
||||
if (c.AllTrollers.Count == 0 && c.AllTrollersAutoFire.Count == 0 && c.AllTrollersAnalog.Count == 0)
|
||||
{
|
||||
ControlDefaults cd = new ControlDefaults();
|
||||
cd = ConfigService.Load(ControlDefaultPath, cd);
|
||||
c.AllTrollers = cd.AllTrollers;
|
||||
c.AllTrollersAutoFire = cd.AllTrollersAutoFire;
|
||||
c.AllTrollersAnalog = cd.AllTrollersAnalog;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue