From d92c27f89d47ea40186cff0eb223b32aa62a999a Mon Sep 17 00:00:00 2001 From: "andres.delikat" Date: Sun, 7 Aug 2011 23:26:06 +0000 Subject: [PATCH] Autofire Input Adaptor, currently no UI for it --- BizHawk.MultiClient/Global.cs | 5 +++ BizHawk.MultiClient/MainForm.Designer.cs | 2 +- BizHawk.MultiClient/MainForm.cs | 7 ++-- BizHawk.MultiClient/movie/InputAdapters.cs | 47 ++++++++++++++++++++++ 4 files changed, 57 insertions(+), 4 deletions(-) diff --git a/BizHawk.MultiClient/Global.cs b/BizHawk.MultiClient/Global.cs index 1a75f7f34d..792c1e332e 100644 --- a/BizHawk.MultiClient/Global.cs +++ b/BizHawk.MultiClient/Global.cs @@ -60,6 +60,11 @@ namespace BizHawk.MultiClient /// public static StickyXORAdapter StickyXORAdapter = new StickyXORAdapter(); + /// + /// Auto-fire (Rapid fire) of controller buttons + /// + public static AutoFireAdapter AutoFireAdapter = new AutoFireAdapter(); + /// /// fire off one-frame logical button clicks here. useful for things like ti-83 virtual pad and reset buttons /// diff --git a/BizHawk.MultiClient/MainForm.Designer.cs b/BizHawk.MultiClient/MainForm.Designer.cs index cf56b220b5..67c4a4706e 100644 --- a/BizHawk.MultiClient/MainForm.Designer.cs +++ b/BizHawk.MultiClient/MainForm.Designer.cs @@ -1972,7 +1972,7 @@ this.MainMenuStrip = this.menuStrip1; this.MaximizeBox = false; this.Name = "MainForm"; - this.Text = "BizHawk"; + this.Text = "0"; this.Deactivate += new System.EventHandler(this.MainForm_Deactivate); this.Load += new System.EventHandler(this.MainForm_Load); this.MouseClick += new System.Windows.Forms.MouseEventHandler(this.MainForm_MouseClick); diff --git a/BizHawk.MultiClient/MainForm.cs b/BizHawk.MultiClient/MainForm.cs index fdb43683b5..70b71d521d 100644 --- a/BizHawk.MultiClient/MainForm.cs +++ b/BizHawk.MultiClient/MainForm.cs @@ -794,12 +794,12 @@ namespace BizHawk.MultiClient Global.UD_LR_ControllerAdapter.Source = Global.ActiveController; Global.StickyXORAdapter.Source = Global.UD_LR_ControllerAdapter; - - Global.MultitrackRewiringControllerAdapter.Source = Global.StickyXORAdapter; + Global.AutoFireAdapter.Source = Global.StickyXORAdapter; + Global.MultitrackRewiringControllerAdapter.Source = Global.AutoFireAdapter; Global.MovieInputSourceAdapter.Source = Global.MultitrackRewiringControllerAdapter; Global.ControllerOutput.Source = Global.MovieOutputAdapter; + Global.Emulator.Controller = Global.ControllerOutput; - Global.MovieSession.MovieControllerAdapter.Type = Global.MovieInputSourceAdapter.Type; //splice the movie session before MovieOutputAdapter if it is doing anything @@ -1188,6 +1188,7 @@ namespace BizHawk.MultiClient return false; case "Record AVI": RecordAVI(); + //Global.AutoFireAdapter.SetAutoFire("P1 A", !Global.AutoFireAdapter.IsAutoFire("P1 A")); break; case "Stop AVI": StopAVI(); diff --git a/BizHawk.MultiClient/movie/InputAdapters.cs b/BizHawk.MultiClient/movie/InputAdapters.cs index 433aa7e90d..f26abed6d2 100644 --- a/BizHawk.MultiClient/movie/InputAdapters.cs +++ b/BizHawk.MultiClient/movie/InputAdapters.cs @@ -130,6 +130,53 @@ namespace BizHawk.MultiClient } } + public class AutoFireAdapter : IController + { + private HashSet autoFireSet = 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) + { + } + + if (autoFireSet.Contains(button)) + { + int a = Global.Emulator.Frame % 2; + if (a == 0) + return true; + else + return false; + } + return source; + } + set { throw new InvalidOperationException(); } + } + + + public void SetAutoFire(string button, bool isSticky) + { + if (isSticky) + autoFireSet.Add(button); + else autoFireSet.Remove(button); + } + + public bool IsAutoFire(string button) + { + return autoFireSet.Contains(button); + } + } + public class MnemonicsGenerator { IController Source;