diff --git a/BizHawk.Client.Common/lua/LuaFunctionList.cs b/BizHawk.Client.Common/lua/LuaFunctionList.cs index fe9946fff9..1298bd1fc8 100644 --- a/BizHawk.Client.Common/lua/LuaFunctionList.cs +++ b/BizHawk.Client.Common/lua/LuaFunctionList.cs @@ -33,22 +33,15 @@ namespace BizHawk.Client.Common public void ClearAll() { - if (Global.Emulator.CanPollInput()) + if (Global.Emulator.InputCallbacksAvailable()) { Global.Emulator.AsInputPollable().InputCallbacks.RemoveAll(this.Select(x => x.Callback)); } - if (Global.Emulator.CanDebug()) + if (Global.Emulator.MemoryCallbacksAvailable()) { - try - { - var cbSys = Global.Emulator.AsDebuggable().MemoryCallbacks; - cbSys.RemoveAll(this.Select(x => x.Callback)); - } - catch - { - //swallow exceptions here. many cores havent implemented memorycallbacks, we ought to have more granular feature querying - } + var cbSys = Global.Emulator.AsDebuggable().MemoryCallbacks; + cbSys.RemoveAll(this.Select(x => x.Callback)); } Clear(); diff --git a/BizHawk.Emulation.Common/Extensions.cs b/BizHawk.Emulation.Common/Extensions.cs index 6ac14b6d79..c1130930f0 100644 --- a/BizHawk.Emulation.Common/Extensions.cs +++ b/BizHawk.Emulation.Common/Extensions.cs @@ -78,6 +78,31 @@ namespace BizHawk.Emulation.Common.IEmulatorExtensions return (IInputPollable)core.ServiceProvider.GetService(); } + public static bool InputCallbacksAvailable(this IEmulator core) + { + if (core == null) + { + return false; + } + + // TODO: this is a pretty ugly way to handle this + var pollable = (IInputPollable)core.ServiceProvider.GetService(); + if (pollable != null) + { + try + { + var callbacks = pollable.InputCallbacks; + return true; + } + catch (NotImplementedException) + { + return false; + } + } + + return false; + } + public static bool HasDriveLight(this IEmulator core) { if (core == null)