Refactor the way a Null ControllerDefinition is created

This commit is contained in:
adelikat 2016-12-16 23:34:18 -06:00
parent 2b4267d2c9
commit 40be0dd0b3
5 changed files with 13 additions and 10 deletions

View File

@ -290,7 +290,7 @@ namespace BizHawk.Client.EmuHawk
var comm = CreateCoreComm(); var comm = CreateCoreComm();
CoreFileProvider.SyncCoreCommInputSignals(comm); CoreFileProvider.SyncCoreCommInputSignals(comm);
Emulator = new NullEmulator(comm, Global.Config.GetCoreSettings<NullEmulator>()); Emulator = new NullEmulator(comm, Global.Config.GetCoreSettings<NullEmulator>());
Global.ActiveController = new Controller(NullEmulator.NullController); Global.ActiveController = new Controller(NullController.Instance.Definition);
Global.AutoFireController = Global.AutofireNullControls; Global.AutoFireController = Global.AutofireNullControls;
Global.AutofireStickyXORAdapter.SetOnOffPatternFromConfig(); Global.AutofireStickyXORAdapter.SetOnOffPatternFromConfig();
try { GlobalWin.Sound = new Sound(Handle); } try { GlobalWin.Sound = new Sound(Handle); }
@ -1769,7 +1769,7 @@ namespace BizHawk.Client.EmuHawk
} }
Global.ClientControls = controls; Global.ClientControls = controls;
Global.AutofireNullControls = new AutofireController(NullEmulator.NullController, Emulator); Global.AutofireNullControls = new AutofireController(NullController.Instance.Definition, Emulator);
} }
@ -3655,7 +3655,7 @@ namespace BizHawk.Client.EmuHawk
var coreComm = CreateCoreComm(); var coreComm = CreateCoreComm();
CoreFileProvider.SyncCoreCommInputSignals(coreComm); CoreFileProvider.SyncCoreCommInputSignals(coreComm);
Emulator = new NullEmulator(coreComm, Global.Config.GetCoreSettings<NullEmulator>()); Emulator = new NullEmulator(coreComm, Global.Config.GetCoreSettings<NullEmulator>());
Global.ActiveController = new Controller(NullEmulator.NullController); Global.ActiveController = new Controller(NullController.Instance.Definition);
Global.AutoFireController = Global.AutofireNullControls; Global.AutoFireController = Global.AutofireNullControls;
RewireSound(); RewireSound();
RebootStatusBarIcon.Visible = false; RebootStatusBarIcon.Visible = false;

View File

@ -84,7 +84,7 @@ namespace BizHawk.Client.MultiHawk
// TODO // TODO
//CoreFileProvider.SyncCoreCommInputSignals(); //CoreFileProvider.SyncCoreCommInputSignals();
Global.ActiveController = new Controller(NullEmulator.NullController); Global.ActiveController = new Controller(NullController.Instance.Definition);
Global.AutoFireController = Global.AutofireNullControls; Global.AutoFireController = Global.AutofireNullControls;
Global.AutofireStickyXORAdapter.SetOnOffPatternFromConfig(); Global.AutofireStickyXORAdapter.SetOnOffPatternFromConfig();
@ -199,7 +199,7 @@ namespace BizHawk.Client.MultiHawk
} }
Global.ClientControls = controls; Global.ClientControls = controls;
Global.AutofireNullControls = new AutofireController(NullEmulator.NullController, Emulator); Global.AutofireNullControls = new AutofireController(NullController.Instance.Definition, Emulator);
} }
private void OpenRomMenuItem_Click(object sender, EventArgs e) private void OpenRomMenuItem_Click(object sender, EventArgs e)

View File

@ -7,9 +7,14 @@
/// <seealso cref="IController" /> /// <seealso cref="IController" />
public class NullController : IController public class NullController : IController
{ {
private static readonly ControllerDefinition _definition = new ControllerDefinition
{
Name = "Null Controller"
};
public ControllerDefinition Definition public ControllerDefinition Definition
{ {
get { return null; } get { return _definition; }
} }
public bool this[string button] public bool this[string button]

View File

@ -33,7 +33,7 @@ namespace BizHawk.Emulation.Common
public ControllerDefinition ControllerDefinition public ControllerDefinition ControllerDefinition
{ {
get { return NullController; } get { return NullController.Instance.Definition; }
} }
public IController Controller { get; set; } public IController Controller { get; set; }
@ -205,8 +205,6 @@ namespace BizHawk.Emulation.Common
#endregion #endregion
public static readonly ControllerDefinition NullController = new ControllerDefinition { Name = "Null Controller" };
private readonly int[] FrameBuffer = new int[256 * 192]; private readonly int[] FrameBuffer = new int[256 * 192];
private readonly short[] SampleBuffer = new short[735 * 2]; private readonly short[] SampleBuffer = new short[735 * 2];
private readonly Random Rand = new Random(); private readonly Random Rand = new Random();

View File

@ -16,7 +16,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.SNES9X
public ControllerDefinition ControllerDefinition public ControllerDefinition ControllerDefinition
{ {
get { return NullEmulator.NullController; } get { return NullController.Instance.Definition; }
} }
public IController Controller { get; set; } public IController Controller { get; set; }