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