add StickyXORAdapter

This commit is contained in:
zeromus 2011-07-24 19:52:13 +00:00
parent 813e0d0d97
commit 198431b8a2
3 changed files with 62 additions and 5 deletions

View File

@ -28,7 +28,8 @@ namespace BizHawk.MultiClient
public static MultitrackRewiringControllerAdapter MultitrackRewiringControllerAdapter = new MultitrackRewiringControllerAdapter();
//user -> Input -> ActiveController -> TurboAdapter(TBD) -> Lua(?) -> ..
//dont take my word for it, since the final word is actually in RewireInputChain, but here is a guide...
//user -> Input -> ActiveController -> UDLR -> StickyXORPlayerInputAdapter -> TurboAdapter(TBD) -> Lua(?TBD?) -> ..
//.. -> MultitrackRewiringControllerAdapter -> MovieInputSourceAdapter -> MovieInputController -> ControllerOutput(1) -> Game
//(1)->Input Display
@ -45,6 +46,11 @@ namespace BizHawk.MultiClient
public static UD_LR_ControllerAdapter UD_LR_ControllerAdapter = new UD_LR_ControllerAdapter();
/// <summary>
/// provides an opportunity to mutate the player's input in an autohold style
/// </summary>
public static StickyXORAdapter StickyXORAdapter = new StickyXORAdapter();
public static Controller ClientControls;
public static string GetOutputControllersAsMnemonic()

View File

@ -781,12 +781,13 @@ namespace BizHawk.MultiClient
void RewireInputChain()
{
//insert turbo and lua here?
Global.ControllerInputCoalescer = new InputCoalescer();
Global.ControllerInputCoalescer.Type = Global.ActiveController.Type;
Global.UD_LR_ControllerAdapter.Source = Global.ActiveController;
Global.MultitrackRewiringControllerAdapter.Source = Global.UD_LR_ControllerAdapter;
Global.StickyXORAdapter.Source = Global.UD_LR_ControllerAdapter;
Global.MultitrackRewiringControllerAdapter.Source = Global.StickyXORAdapter;
Global.MovieInputSourceAdapter.Source = Global.MultitrackRewiringControllerAdapter;
Global.MovieControllerAdapter.SetSource(Global.MovieInputSourceAdapter);
Global.ControllerOutput = Global.MovieControllerAdapter;
@ -828,8 +829,12 @@ namespace BizHawk.MultiClient
{
if (Global.PsxCoreLibrary.IsOpen)
{
nextEmulator = new PsxCore(Global.PsxCoreLibrary);
PsxCore psx = new PsxCore(Global.PsxCoreLibrary);
nextEmulator = psx;
game = new RomGame();
//set disc
//psx.
}
}
else

View File

@ -43,10 +43,56 @@ namespace BizHawk.MultiClient
public ControllerDefinition Type { get; set; }
protected WorkingDictionary<string, bool> Buttons = new WorkingDictionary<string, bool>();
public bool this[string button] { get { return Buttons[button]; } set { Buttons[button] = value; } }
public virtual bool this[string button] { get { return Buttons[button]; } set { Buttons[button] = value; } }
public virtual bool IsPressed(string button) { return this[button]; }
public float GetFloat(string name) { return 0.0f; } //TODO
public void UpdateControls(int frame) { }
public virtual void LatchFrom(IController source)
{
foreach (string button in source.Type.BoolButtons)
{
Buttons[button] = source[button];
}
}
}
public class StickyXORAdapter : IController
{
private HashSet<string> stickySet = new HashSet<string>();
public IController Source;
public ControllerDefinition Type { get { return Source.Type; } set { throw new InvalidOperationException(); } }
public bool IsPressed(string button) { return this[button]; }
public float GetFloat(string name) { return 0.0f; } //TODO
public void UpdateControls(int frame) { }
public bool this[string button] {
get
{
bool source = Source[button];
if (source)
{
}
source ^= stickySet.Contains(button);
return source;
}
set { throw new InvalidOperationException(); }
}
public void SetSticky(string button, bool isSticky)
{
if(isSticky)
stickySet.Add(button);
else stickySet.Remove(button);
}
public bool IsSticky(string button)
{
return stickySet.Contains(button);
}
}
public class MnemonicsGenerator