diff --git a/BizHawk.Client.Common/BizHawk.Client.Common.csproj b/BizHawk.Client.Common/BizHawk.Client.Common.csproj index e146480e65..8d0cef30d6 100644 --- a/BizHawk.Client.Common/BizHawk.Client.Common.csproj +++ b/BizHawk.Client.Common/BizHawk.Client.Common.csproj @@ -134,6 +134,7 @@ + diff --git a/BizHawk.Client.Common/Global.cs b/BizHawk.Client.Common/Global.cs index 5f727f4845..021f6e31c4 100644 --- a/BizHawk.Client.Common/Global.cs +++ b/BizHawk.Client.Common/Global.cs @@ -57,6 +57,15 @@ namespace BizHawk.Client.Common public static DiscHopper DiscHopper = new DiscHopper(); + public static UD_LR_ControllerAdapter UD_LR_ControllerAdapter = new UD_LR_ControllerAdapter(); + + public static AutoFireStickyXORAdapter AutofireStickyXORAdapter = new AutoFireStickyXORAdapter(); + + /// + /// will OR together two IControllers + /// + public static ORAdapter OrControllerAdapter = new ORAdapter(); + /// /// provides an opportunity to mutate the player's input in an autohold style /// @@ -71,5 +80,9 @@ namespace BizHawk.Client.Common /// fire off one-frame logical button clicks here. useful for things like ti-83 virtual pad and reset buttons /// public static ClickyVirtualPadController ClickyVirtualPadController = new ClickyVirtualPadController(); + + public static SimpleController MovieOutputController = new SimpleController(); + + public static Controller ClientControls; } } diff --git a/BizHawk.Client.EmuHawk/Throttle.cs b/BizHawk.Client.Common/Throttle.cs similarity index 93% rename from BizHawk.Client.EmuHawk/Throttle.cs rename to BizHawk.Client.Common/Throttle.cs index 884918a993..666f2ab2e0 100644 --- a/BizHawk.Client.EmuHawk/Throttle.cs +++ b/BizHawk.Client.Common/Throttle.cs @@ -1,14 +1,11 @@ using System; -using System.Runtime.InteropServices; using System.Threading; -using BizHawk.Client.Common; - //this throttle is nitsuja's fine-tuned techniques from desmume -namespace BizHawk.Client.EmuHawk +namespace BizHawk.Client.Common { - class Throttle + public class Throttle { int lastskiprate; int framestoskip; @@ -25,7 +22,7 @@ namespace BizHawk.Client.EmuHawk { get { - if (GlobalWin.ClientControls["MaxTurbo"]) + if (Global.ClientControls["MaxTurbo"]) { return 20; } @@ -39,7 +36,7 @@ namespace BizHawk.Client.EmuHawk { get { - if (GlobalWin.ClientControls["MaxTurbo"]) + if (Global.ClientControls["MaxTurbo"]) { return false; } @@ -54,7 +51,7 @@ namespace BizHawk.Client.EmuHawk { get { - if (GlobalWin.ClientControls["MaxTurbo"]) + if (Global.ClientControls["MaxTurbo"]) { return false; } diff --git a/BizHawk.Client.EmuHawk/BizHawk.Client.EmuHawk.csproj b/BizHawk.Client.EmuHawk/BizHawk.Client.EmuHawk.csproj index 1e74afdc78..51aa3b37f6 100644 --- a/BizHawk.Client.EmuHawk/BizHawk.Client.EmuHawk.csproj +++ b/BizHawk.Client.EmuHawk/BizHawk.Client.EmuHawk.csproj @@ -975,7 +975,6 @@ True - Form diff --git a/BizHawk.Client.EmuHawk/DisplayManager/DisplayManager.cs b/BizHawk.Client.EmuHawk/DisplayManager/DisplayManager.cs index b802429b3f..07b753848e 100644 --- a/BizHawk.Client.EmuHawk/DisplayManager/DisplayManager.cs +++ b/BizHawk.Client.EmuHawk/DisplayManager/DisplayManager.cs @@ -414,7 +414,7 @@ namespace BizHawk.Client.EmuHawk public void DrawMessages(IBlitter g) { - if (!GlobalWin.ClientControls["MaxTurbo"]) + if (!Global.ClientControls["MaxTurbo"]) { messages.RemoveAll(m => DateTime.Now > m.ExpireAt); int line = 1; @@ -587,7 +587,7 @@ namespace BizHawk.Client.EmuHawk g.DrawString(rerec, MessageFont, FixedMessagesColor, x, y); } - if (GlobalWin.ClientControls["Autohold"] || GlobalWin.ClientControls["Autofire"]) + if (Global.ClientControls["Autohold"] || Global.ClientControls["Autofire"]) { StringBuilder disp = new StringBuilder("Held: "); @@ -597,7 +597,7 @@ namespace BizHawk.Client.EmuHawk disp.Append(' '); } - foreach (string s in GlobalWin.AutofireStickyXORAdapter.CurrentStickies) + foreach (string s in Global.AutofireStickyXORAdapter.CurrentStickies) { disp.Append("Auto-"); disp.Append(s); diff --git a/BizHawk.Client.EmuHawk/GlobalWin.cs b/BizHawk.Client.EmuHawk/GlobalWin.cs index 76ec803843..32307e78e8 100644 --- a/BizHawk.Client.EmuHawk/GlobalWin.cs +++ b/BizHawk.Client.EmuHawk/GlobalWin.cs @@ -18,23 +18,9 @@ namespace BizHawk.Client.EmuHawk public static OSDManager OSD = new OSDManager(); public static DisplayManager DisplayManager = new DisplayManager(); - //input state which has been destined for game controller inputs are coalesced here public static ControllerInputCoalescer ControllerInputCoalescer = new ControllerInputCoalescer(); //input state which has been destined for client hotkey consumption are colesced here public static InputCoalescer HotkeyCoalescer = new InputCoalescer(); - - public static UD_LR_ControllerAdapter UD_LR_ControllerAdapter = new UD_LR_ControllerAdapter(); - - public static AutoFireStickyXORAdapter AutofireStickyXORAdapter = new AutoFireStickyXORAdapter(); - - /// - /// will OR together two IControllers - /// - public static ORAdapter OrControllerAdapter = new ORAdapter(); - - public static SimpleController MovieOutputController = new SimpleController(); - - public static Controller ClientControls; } } diff --git a/BizHawk.Client.EmuHawk/MainForm.cs b/BizHawk.Client.EmuHawk/MainForm.cs index c2ea8215f3..2a203f869e 100644 --- a/BizHawk.Client.EmuHawk/MainForm.cs +++ b/BizHawk.Client.EmuHawk/MainForm.cs @@ -122,7 +122,7 @@ namespace BizHawk.Client.EmuHawk Global.Emulator = new NullEmulator(Global.CoreComm); Global.ActiveController = Global.NullControls; Global.AutoFireController = Global.AutofireNullControls; - GlobalWin.AutofireStickyXORAdapter.SetOnOffPatternFromConfig(); + Global.AutofireStickyXORAdapter.SetOnOffPatternFromConfig(); #if WINDOWS GlobalWin.Sound = new Sound(Handle, GlobalWin.DSound); #else @@ -334,20 +334,20 @@ namespace BizHawk.Client.EmuHawk Input.Instance.Update(); //handle events and dispatch as a hotkey action, or a hotkey button, or an input button ProcessInput(); - GlobalWin.ClientControls.LatchFromPhysical(GlobalWin.HotkeyCoalescer); + Global.ClientControls.LatchFromPhysical(GlobalWin.HotkeyCoalescer); Global.ActiveController.LatchFromPhysical(GlobalWin.ControllerInputCoalescer); Global.ActiveController.OR_FromLogical(Global.ClickyVirtualPadController); Global.AutoFireController.LatchFromPhysical(GlobalWin.ControllerInputCoalescer); - if (GlobalWin.ClientControls["Autohold"]) + if (Global.ClientControls["Autohold"]) { Global.StickyXORAdapter.MassToggleStickyState(Global.ActiveController.PressedButtons); - GlobalWin.AutofireStickyXORAdapter.MassToggleStickyState(Global.AutoFireController.PressedButtons); + Global.AutofireStickyXORAdapter.MassToggleStickyState(Global.AutoFireController.PressedButtons); } - else if (GlobalWin.ClientControls["Autofire"]) + else if (Global.ClientControls["Autofire"]) { - GlobalWin.AutofireStickyXORAdapter.MassToggleStickyState(Global.ActiveController.PressedButtons); + Global.AutofireStickyXORAdapter.MassToggleStickyState(Global.ActiveController.PressedButtons); } if (GlobalWin.Tools.Has()) @@ -444,7 +444,7 @@ namespace BizHawk.Client.EmuHawk //TODO - wonder what happens if we pop up something interactive as a response to one of these hotkeys? may need to purge further processing //look for hotkey bindings for this key - var triggers = GlobalWin.ClientControls.SearchBindings(ie.LogicalButton.ToString()); + var triggers = Global.ClientControls.SearchBindings(ie.LogicalButton.ToString()); if (triggers.Count == 0) { //bool sys_hotkey = false; @@ -1064,7 +1064,7 @@ namespace BizHawk.Client.EmuHawk private void ClearAutohold() { Global.StickyXORAdapter.ClearStickies(); - GlobalWin.AutofireStickyXORAdapter.ClearStickies(); + Global.AutofireStickyXORAdapter.ClearStickies(); if (GlobalWin.Tools.Has()) { @@ -1599,7 +1599,7 @@ namespace BizHawk.Client.EmuHawk controls.BindMulti(b.DisplayName, b.Bindings); } - GlobalWin.ClientControls = controls; + Global.ClientControls = controls; Global.NullControls = new Controller(NullEmulator.NullController); Global.AutofireNullControls = new AutofireController(NullEmulator.NullController); @@ -1763,8 +1763,8 @@ namespace BizHawk.Client.EmuHawk private void SyncThrottle() { - bool fastforward = GlobalWin.ClientControls["Fast Forward"] || FastForward; - bool superfastforward = GlobalWin.ClientControls["Turbo"]; + bool fastforward = Global.ClientControls["Fast Forward"] || FastForward; + bool superfastforward = Global.ClientControls["Turbo"]; Global.ForceNoThrottle = unthrottled || fastforward; // realtime throttle is never going to be so exact that using a double here is wrong @@ -2533,7 +2533,7 @@ namespace BizHawk.Client.EmuHawk runFrame = true; } - if (GlobalWin.ClientControls["Frame Advance"] || PressFrameAdvance) + if (Global.ClientControls["Frame Advance"] || PressFrameAdvance) { //handle the initial trigger of a frame advance if (FrameAdvanceTimestamp == DateTime.MinValue) @@ -2571,7 +2571,7 @@ namespace BizHawk.Client.EmuHawk } bool ReturnToRecording = Global.MovieSession.Movie.IsRecording; - if (RewindActive && (GlobalWin.ClientControls["Rewind"] || PressRewind)) + if (RewindActive && (Global.ClientControls["Rewind"] || PressRewind)) { Rewind(1); suppressCaptureRewind = true; @@ -2602,8 +2602,8 @@ namespace BizHawk.Client.EmuHawk bool coreskipaudio = false; if (runFrame) { - bool ff = GlobalWin.ClientControls["Fast Forward"] || GlobalWin.ClientControls["Turbo"]; - bool fff = GlobalWin.ClientControls["Turbo"]; + bool ff = Global.ClientControls["Fast Forward"] || Global.ClientControls["Turbo"]; + bool fff = Global.ClientControls["Turbo"]; bool updateFpsString = (runloop_last_ff != ff); runloop_last_ff = ff; @@ -2646,9 +2646,9 @@ namespace BizHawk.Client.EmuHawk else if (!Global.Config.MuteFrameAdvance) genSound = true; - Global.MovieSession.HandleMovieOnFrameLoop(GlobalWin.ClientControls["ClearFrame"]); + Global.MovieSession.HandleMovieOnFrameLoop(Global.ClientControls["ClearFrame"]); - coreskipaudio = GlobalWin.ClientControls["Turbo"] && CurrAviWriter == null; + coreskipaudio = Global.ClientControls["Turbo"] && CurrAviWriter == null; //======================================= Global.CheatList.Pulse(); Global.Emulator.FrameAdvance(!throttle.skipnextframe || CurrAviWriter != null, !coreskipaudio); @@ -2673,7 +2673,7 @@ namespace BizHawk.Client.EmuHawk } } - if (GlobalWin.ClientControls["Rewind"] || PressRewind) + if (Global.ClientControls["Rewind"] || PressRewind) { UpdateToolsAfter(); if (ReturnToRecording) @@ -3010,14 +3010,14 @@ namespace BizHawk.Client.EmuHawk { GlobalWin.ControllerInputCoalescer = new ControllerInputCoalescer { Type = Global.ActiveController.Type }; - GlobalWin.OrControllerAdapter.Source = Global.ActiveController; - GlobalWin.OrControllerAdapter.SourceOr = Global.AutoFireController; - GlobalWin.UD_LR_ControllerAdapter.Source = GlobalWin.OrControllerAdapter; + Global.OrControllerAdapter.Source = Global.ActiveController; + Global.OrControllerAdapter.SourceOr = Global.AutoFireController; + Global.UD_LR_ControllerAdapter.Source = Global.OrControllerAdapter; - Global.StickyXORAdapter.Source = GlobalWin.UD_LR_ControllerAdapter; - GlobalWin.AutofireStickyXORAdapter.Source = Global.StickyXORAdapter; + Global.StickyXORAdapter.Source = Global.UD_LR_ControllerAdapter; + Global.AutofireStickyXORAdapter.Source = Global.StickyXORAdapter; - Global.MultitrackRewiringControllerAdapter.Source = GlobalWin.AutofireStickyXORAdapter; + Global.MultitrackRewiringControllerAdapter.Source = Global.AutofireStickyXORAdapter; Global.ForceOffAdaptor.Source = Global.MultitrackRewiringControllerAdapter; Global.MovieInputSourceAdapter.Source = Global.ForceOffAdaptor; @@ -3600,7 +3600,7 @@ namespace BizHawk.Client.EmuHawk Global.StickyXORAdapter.ClearStickies(); Global.StickyXORAdapter.ClearStickyFloats(); - GlobalWin.AutofireStickyXORAdapter.ClearStickies(); + Global.AutofireStickyXORAdapter.ClearStickies(); RewireSound(); diff --git a/BizHawk.Client.EmuHawk/config/AutofireConfig.cs b/BizHawk.Client.EmuHawk/config/AutofireConfig.cs index 64b7947a5b..eb644d4ff9 100644 --- a/BizHawk.Client.EmuHawk/config/AutofireConfig.cs +++ b/BizHawk.Client.EmuHawk/config/AutofireConfig.cs @@ -42,7 +42,7 @@ namespace BizHawk.Client.EmuHawk Global.AutoFireController.On = Global.Config.AutofireOn = (int)OnNumeric.Value; Global.AutoFireController.Off = Global.Config.AutofireOff = (int)OffNumeric.Value; Global.Config.AutofireLagFrames = LagFrameCheck.Checked; - GlobalWin.AutofireStickyXORAdapter.SetOnOffPatternFromConfig(); + Global.AutofireStickyXORAdapter.SetOnOffPatternFromConfig(); GlobalWin.OSD.AddMessage("Autofire settings saved"); this.Close(); diff --git a/BizHawk.Client.EmuHawk/tools/VirtualPads/VirtualPadButton.cs b/BizHawk.Client.EmuHawk/tools/VirtualPads/VirtualPadButton.cs index b7267856ad..a7986a7383 100644 --- a/BizHawk.Client.EmuHawk/tools/VirtualPads/VirtualPadButton.cs +++ b/BizHawk.Client.EmuHawk/tools/VirtualPads/VirtualPadButton.cs @@ -57,7 +57,7 @@ namespace BizHawk.Client.EmuHawk protected void SetAutofireSticky() { - GlobalWin.AutofireStickyXORAdapter.SetSticky(ControllerButton, Checked); + Global.AutofireStickyXORAdapter.SetSticky(ControllerButton, Checked); if (Checked == false) { @@ -94,7 +94,7 @@ namespace BizHawk.Client.EmuHawk _rightClicked = false; ForeColor = Color.Black; Checked = false; - GlobalWin.AutofireStickyXORAdapter.SetSticky(ControllerButton, false); + Global.AutofireStickyXORAdapter.SetSticky(ControllerButton, false); Global.StickyXORAdapter.SetSticky(ControllerButton, false); } }