Misc Emulation.Common cleanups

This commit is contained in:
adelikat 2017-04-27 12:07:34 -05:00
parent 83124a8d20
commit 957736b787
8 changed files with 21 additions and 18 deletions

View File

@ -553,6 +553,7 @@ namespace BizHawk.Emulation.Common.BizInvoke
public bool Compatibility { get; set; }
/// <summary>
/// Initializes a new instance of the <see cref="BizImportAttribute"/> class.
/// </summary>
/// <param name="c">unmanaged calling convention</param>
public BizImportAttribute(CallingConvention c)

View File

@ -18,7 +18,9 @@ namespace BizHawk.Emulation.Common.BizInvoke
_p = Libdl.dlopen(dllName, Libdl.RTLD_NOW);
#endif
if (_p == IntPtr.Zero)
{
throw new InvalidOperationException("LoadLibrary returned NULL");
}
}
public IntPtr Resolve(string entryPoint)

View File

@ -58,42 +58,43 @@ namespace BizHawk.Emulation.Common
public class ControlDefUnMerger
{
private readonly Dictionary<string, string> Remaps;
private readonly Dictionary<string, string> _remaps;
public ControlDefUnMerger(Dictionary<string, string> remaps)
{
Remaps = remaps;
_remaps = remaps;
}
private class DummyController : IController
{
private readonly IController src;
private readonly Dictionary<string, string> remaps;
private readonly IController _src;
private readonly Dictionary<string, string> _remaps;
public DummyController(IController src, Dictionary<string, string> remaps)
{
this.src = src;
this.remaps = remaps;
_src = src;
_remaps = remaps;
}
public ControllerDefinition Definition { get { throw new NotImplementedException(); } }
public bool this[string button] => IsPressed(button);
public ControllerDefinition Definition
{
get { throw new NotImplementedException(); }
}
public bool IsPressed(string button)
{
return src.IsPressed(remaps[button]);
return _src.IsPressed(_remaps[button]);
}
public float GetFloat(string name)
{
return src.GetFloat(remaps[name]);
return _src.GetFloat(_remaps[name]);
}
}
public IController UnMerge(IController c)
{
return new DummyController(c, Remaps);
return new DummyController(c, _remaps);
}
}
}

View File

@ -27,7 +27,7 @@ namespace BizHawk.Emulation.Common
/// <summary>
/// Sets the controller instance that the core will use for input.
/// Tee <seealso cref="IController"/> provided by the client must provide the buttons specified the buttons
/// defined by the <seealso cref="=ControllerDefinition"/> provided by the core
/// defined by the <seealso cref="ControllerDefinition"/> provided by the core
/// </summary>
IController Controller { set; }

View File

@ -1,7 +1,7 @@
namespace BizHawk.Emulation.Common
{
/// <summary>
/// This interface specifies that an interface or implementation is a emulator core service, such as IDebuggable,
/// This interface specifies that an interface or implementation is a emulator core service, such as <seealso cref="IDebuggable"/>,
/// but is an optional part of the core functionality
/// Clients should gracefully handle an IEmulator that has a missing or partial implementation of one of these services
/// </summary>

View File

@ -4,7 +4,7 @@ using System.Collections.Generic;
namespace BizHawk.Emulation.Common
{
/// <summary>
/// This is a property of IInputPollable, and defines the means by which a client
/// This is a property of <seealso cref="IInputPollable"/>, and defines the means by which a client
/// gets and sets input callbacks in the core. An input callback should fire any time input is
/// polled by the core
/// </summary>

View File

@ -60,7 +60,7 @@ namespace BizHawk.Emulation.Common
/// <param name="in_rate">Input sampling rate rounded to the nearest integer (in Hz).</param>
/// <param name="out_rate">Output sampling rate rounded to the nearest integer (in Hz).</param>
/// <param name="quality">Resampling quality between 0 and 10, where 0 has poor quality and 10 has very high quality.</param>
/// <param name="err"></param>
/// <param name="err">The error state</param>
/// <returns>Newly created resampler state</returns>
[DllImport("libspeexdsp.dll", CallingConvention = CallingConvention.Cdecl)]
public static extern IntPtr speex_resampler_init_frac(uint nb_channels, uint ratio_num, uint ratio_den, uint in_rate, uint out_rate, int quality, ref RESAMPLER_ERR err);
@ -161,7 +161,6 @@ namespace BizHawk.Emulation.Common
/// </summary>
/// <param name="st">Resampler state</param>
/// <param name="quality">Resampling quality between 0 and 10, where 0 has poor quality and 10 has very high quality.</param>
/// <returns></returns>
[DllImport("libspeexdsp.dll", CallingConvention = CallingConvention.Cdecl)]
public static extern RESAMPLER_ERR speex_resampler_set_quality(IntPtr st, int quality);

View File

@ -37,7 +37,7 @@ namespace BizHawk.Emulation.Common
public readonly Node Root = new Node();
[JsonIgnore]
Stack<Node> Nodes;
private Stack<Node> Nodes;
[JsonIgnore]
private Node Current => Nodes.Peek();