cleanup Controller class (remove old sticky and forcing code)
This commit is contained in:
parent
e4f9f76198
commit
29b2e30c36
|
@ -51,6 +51,9 @@ namespace BizHawk.MultiClient
|
|||
/// </summary>
|
||||
public static StickyXORAdapter StickyXORAdapter = new StickyXORAdapter();
|
||||
|
||||
/// <summary>
|
||||
/// fire off one-frame logical button clicks here. useful for things like ti-83 virtual pad and reset buttons
|
||||
/// </summary>
|
||||
public static ClickyVirtualPadController ClickyVirtualPadController = new ClickyVirtualPadController();
|
||||
|
||||
public static Controller ClientControls;
|
||||
|
|
|
@ -219,7 +219,7 @@ namespace BizHawk.MultiClient
|
|||
extractor.ExtractFile(archiveIndex, boundStream);
|
||||
boundStream.Position = 0;
|
||||
memberPath = FixArchiveFilename(extractor.ArchiveFileNames[archiveIndex]); //TODO - maybe go through our own list of names? maybe not, its indexes dont match..
|
||||
Console.WriteLine("bound " + CanonicalFullPath);
|
||||
Console.WriteLine("HawkFile bound " + CanonicalFullPath);
|
||||
|
||||
return this;
|
||||
}
|
||||
|
@ -240,7 +240,7 @@ namespace BizHawk.MultiClient
|
|||
void BindRoot()
|
||||
{
|
||||
boundStream = rootStream;
|
||||
Console.WriteLine("bound " + CanonicalFullPath);
|
||||
Console.WriteLine("HawkFile bound " + CanonicalFullPath);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
|
@ -7,12 +7,19 @@ namespace BizHawk.MultiClient
|
|||
public class Controller : IController
|
||||
{
|
||||
private ControllerDefinition type;
|
||||
private Dictionary<string, List<string>> bindings = new Dictionary<string, List<string>>();
|
||||
private WorkingDictionary<string, bool> stickyButtons = new WorkingDictionary<string, bool>();
|
||||
private List<string> unpressedButtons = new List<string>();
|
||||
private List<string> forcePressedButtons = new List<string>();
|
||||
private List<string> removeFromForcePressedButtons = new List<string>();
|
||||
private List<string> programmaticallyPressedButtons = new List<string>();
|
||||
private WorkingDictionary<string, List<string>> bindings = new WorkingDictionary<string, List<string>>();
|
||||
private WorkingDictionary<string, bool> buttons = new WorkingDictionary<string, bool>();
|
||||
|
||||
public Controller(ControllerDefinition definition)
|
||||
{
|
||||
type = definition;
|
||||
}
|
||||
|
||||
public ControllerDefinition Type { get { return type; } }
|
||||
public bool this[string button] { get { return IsPressed(button); } }
|
||||
public bool IsPressed(string button) { return buttons[button]; }
|
||||
public float GetFloat(string name) { throw new NotImplementedException(); }
|
||||
public void UpdateControls(int frame) { }
|
||||
|
||||
//look for bindings which are activated by the supplied physical button.
|
||||
public List<string> SearchBindings(string button)
|
||||
|
@ -36,11 +43,11 @@ namespace BizHawk.MultiClient
|
|||
{
|
||||
foreach (var kvp in bindings)
|
||||
{
|
||||
stickyButtons[kvp.Key] = false;
|
||||
buttons[kvp.Key] = false;
|
||||
foreach (var bound_button in kvp.Value)
|
||||
{
|
||||
if(controller[bound_button])
|
||||
stickyButtons[kvp.Key] = true;
|
||||
buttons[kvp.Key] = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -54,23 +61,10 @@ namespace BizHawk.MultiClient
|
|||
foreach (string button in type.BoolButtons)
|
||||
{
|
||||
if (controller.IsPressed(button))
|
||||
stickyButtons[button] = true;
|
||||
buttons[button] = true;
|
||||
}
|
||||
}
|
||||
|
||||
public Controller(ControllerDefinition definition)
|
||||
{
|
||||
type = definition;
|
||||
|
||||
foreach (var b in type.BoolButtons)
|
||||
{
|
||||
bindings[b] = new List<string>();
|
||||
}
|
||||
|
||||
foreach (var f in type.FloatControls)
|
||||
bindings[f] = new List<string>();
|
||||
}
|
||||
|
||||
public void BindButton(string button, string control)
|
||||
{
|
||||
bindings[button].Add(control);
|
||||
|
@ -85,50 +79,5 @@ namespace BizHawk.MultiClient
|
|||
bindings[button].Add(control.Trim());
|
||||
}
|
||||
|
||||
public ControllerDefinition Type
|
||||
{
|
||||
get { return type; }
|
||||
}
|
||||
|
||||
public bool this[string button]
|
||||
{
|
||||
get { return IsPressed(button); }
|
||||
}
|
||||
|
||||
public bool IsPressed(string button)
|
||||
{
|
||||
return stickyButtons[button];
|
||||
}
|
||||
|
||||
public float GetFloat(string name)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void UnpressButton(string name)
|
||||
{
|
||||
unpressedButtons.Add(name);
|
||||
}
|
||||
|
||||
public void UpdateControls(int frame)
|
||||
{
|
||||
}
|
||||
|
||||
public void SetSticky(string button, bool sticky)
|
||||
{
|
||||
stickyButtons[button] = sticky;
|
||||
}
|
||||
|
||||
public bool IsSticky(string button)
|
||||
{
|
||||
return stickyButtons[button];
|
||||
}
|
||||
|
||||
public void ForceButton(string button)
|
||||
{
|
||||
forcePressedButtons.Add(button);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
|
@ -98,6 +98,10 @@ namespace BizHawk.MultiClient
|
|||
var other = (LogicalButton)obj;
|
||||
return other == this;
|
||||
}
|
||||
public override int GetHashCode()
|
||||
{
|
||||
return Button.GetHashCode() ^ Modifiers.GetHashCode();
|
||||
}
|
||||
public static bool operator==(LogicalButton lhs, LogicalButton rhs)
|
||||
{
|
||||
return lhs.Button == rhs.Button && lhs.Modifiers == rhs.Modifiers;
|
||||
|
|
|
@ -2121,8 +2121,9 @@ namespace BizHawk.MultiClient
|
|||
|
||||
private void SoftReset()
|
||||
{
|
||||
//is it enough to run this for one frame? maybe..
|
||||
if (Global.Emulator.ControllerDefinition.BoolButtons.Contains("Reset"))
|
||||
Global.ActiveController.ForceButton("Reset");
|
||||
Global.ClickyVirtualPadController.Click("Reset");
|
||||
}
|
||||
|
||||
public void UpdateStatusSlots()
|
||||
|
|
Loading…
Reference in New Issue