diff --git a/BizHawk.MultiClient/Global.cs b/BizHawk.MultiClient/Global.cs index 15d8ca330f..8a372800cf 100644 --- a/BizHawk.MultiClient/Global.cs +++ b/BizHawk.MultiClient/Global.cs @@ -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(); + /// + /// provides an opportunity to mutate the player's input in an autohold style + /// + public static StickyXORAdapter StickyXORAdapter = new StickyXORAdapter(); + public static Controller ClientControls; public static string GetOutputControllersAsMnemonic() diff --git a/BizHawk.MultiClient/MainForm.cs b/BizHawk.MultiClient/MainForm.cs index 7edf93ad95..5c34427d37 100644 --- a/BizHawk.MultiClient/MainForm.cs +++ b/BizHawk.MultiClient/MainForm.cs @@ -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 diff --git a/BizHawk.MultiClient/movie/InputAdapters.cs b/BizHawk.MultiClient/movie/InputAdapters.cs index 0a9b2f319f..1ad471c09e 100644 --- a/BizHawk.MultiClient/movie/InputAdapters.cs +++ b/BizHawk.MultiClient/movie/InputAdapters.cs @@ -43,10 +43,56 @@ namespace BizHawk.MultiClient public ControllerDefinition Type { get; set; } protected WorkingDictionary Buttons = new WorkingDictionary(); - 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 stickySet = new HashSet(); + 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