Replace helper methods with readonly bool IsUnixHost and cleanup
This commit is contained in:
parent
fec63fb66a
commit
8c059aa43c
|
@ -410,21 +410,18 @@ namespace BizHawk.Client.Common
|
||||||
#if true
|
#if true
|
||||||
if (!IsSubfolder(parentPath, absolutePath)) return absolutePath;
|
if (!IsSubfolder(parentPath, absolutePath)) return absolutePath;
|
||||||
|
|
||||||
return OSTailoredCode.IsWindows()
|
return OSTailoredCode.IsUnixHost
|
||||||
? absolutePath.Replace(parentPath, ".")
|
? "./" + OSTailoredCode.SimpleSubshell("realpath", $"--relative-to=\"{parentPath}\" \"{absolutePath}\"", $"invalid path {absolutePath} or missing realpath binary")
|
||||||
: "./" + OSTailoredCode.SimpleSubshell("realpath", $"--relative-to=\"{parentPath}\" \"{absolutePath}\"", $"invalid path {absolutePath} or missing realpath binary");
|
: absolutePath.Replace(parentPath, ".");
|
||||||
#else // written for Unix port but may be useful for .NET Core
|
#else // written for Unix port but may be useful for .NET Core
|
||||||
if (!IsSubfolder(parentPath, absolutePath))
|
if (!IsSubfolder(parentPath, absolutePath))
|
||||||
{
|
{
|
||||||
return OSTailoredCode.CurrentOS == OSTailoredCode.DistinctOS.Windows
|
return OSTailoredCode.IsUnixHost && parentPath.TrimEnd('.') == $"{absolutePath}/" ? "." : absolutePath;
|
||||||
|| parentPath.TrimEnd('.') != $"{absolutePath}/"
|
|
||||||
? absolutePath
|
|
||||||
: ".";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return OSTailoredCode.CurrentOS == OSTailoredCode.DistinctOS.Windows
|
return OSTailoredCode.IsUnixHost
|
||||||
? absolutePath.Replace(parentPath, ".")
|
? absolutePath.Replace(parentPath.TrimEnd('.'), "./")
|
||||||
: absolutePath.Replace(parentPath.TrimEnd('.'), "./");
|
: absolutePath.Replace(parentPath, ".");
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -441,40 +438,33 @@ namespace BizHawk.Client.Common
|
||||||
/// <remarks>Algorithm for Windows taken from https://stackoverflow.com/a/7710620/7467292</remarks>
|
/// <remarks>Algorithm for Windows taken from https://stackoverflow.com/a/7710620/7467292</remarks>
|
||||||
public static bool IsSubfolder(string parentPath, string childPath)
|
public static bool IsSubfolder(string parentPath, string childPath)
|
||||||
{
|
{
|
||||||
if (OSTailoredCode.IsWindows())
|
if (OSTailoredCode.IsUnixHost)
|
||||||
{
|
{
|
||||||
var parentUri = new Uri(parentPath);
|
|
||||||
|
|
||||||
for (var childUri = new DirectoryInfo(childPath).Parent; childUri != null; childUri = childUri?.Parent)
|
|
||||||
{
|
|
||||||
if (new Uri(childUri.FullName) == parentUri) return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
#if true
|
#if true
|
||||||
return OSTailoredCode.SimpleSubshell("realpath", $"-L \"{childPath}\"", $"invalid path {childPath} or missing realpath binary")
|
return OSTailoredCode.SimpleSubshell("realpath", $"-L \"{childPath}\"", $"invalid path {childPath} or missing realpath binary")
|
||||||
.StartsWith(OSTailoredCode.SimpleSubshell("realpath", $"-L \"{parentPath}\"", $"invalid path {parentPath} or missing realpath binary"));
|
.StartsWith(OSTailoredCode.SimpleSubshell("realpath", $"-L \"{parentPath}\"", $"invalid path {parentPath} or missing realpath binary"));
|
||||||
#else // written for Unix port but may be useful for .NET Core
|
#else // written for Unix port but may be useful for Windows when moving to .NET Core
|
||||||
{
|
var parentUriPath = new Uri(parentPath.TrimEnd('.')).AbsolutePath.TrimEnd('/');
|
||||||
var parentUri = new Uri(parentPath.TrimEnd('.'));
|
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
for (var childUri = new DirectoryInfo(childPath).Parent; childUri != null; childUri = childUri?.Parent)
|
for (var childUri = new DirectoryInfo(childPath).Parent; childUri != null; childUri = childUri?.Parent)
|
||||||
{
|
{
|
||||||
if (new Uri(childUri.FullName).AbsolutePath.TrimEnd('/') == parentUri.AbsolutePath.TrimEnd('/')) return true;
|
if (new Uri(childUri.FullName).AbsolutePath.TrimEnd('/') == parentUriPath) return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch
|
catch
|
||||||
{
|
{
|
||||||
// ignored
|
// ignored
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
|
||||||
#endif
|
#endif
|
||||||
|
}
|
||||||
|
var parentUri = new Uri(parentPath);
|
||||||
|
for (var childUri = new DirectoryInfo(childPath).Parent; childUri != null; childUri = childUri?.Parent)
|
||||||
|
{
|
||||||
|
if (new Uri(childUri.FullName) == parentUri) return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
|
@ -346,11 +346,9 @@ namespace BizHawk.Client.Common
|
||||||
|
|
||||||
/// <remarks>
|
/// <remarks>
|
||||||
/// warning: we dont even want to deal with changing this at runtime. but we want it changed here for config purposes. so dont check this variable. check in GlobalWin or something like that.
|
/// warning: we dont even want to deal with changing this at runtime. but we want it changed here for config purposes. so dont check this variable. check in GlobalWin or something like that.
|
||||||
/// force DX for Windows and GDI+ for Unix when a new config is generated
|
/// force DX for Windows and OpenGL for Unix when a new config is generated
|
||||||
/// </remarks>
|
/// </remarks>
|
||||||
public EDispMethod DispMethod = OSTailoredCode.IsWindows()
|
public EDispMethod DispMethod = OSTailoredCode.IsUnixHost ? EDispMethod.OpenGL : EDispMethod.SlimDX9;
|
||||||
? EDispMethod.SlimDX9
|
|
||||||
: EDispMethod.GdiPlus;
|
|
||||||
|
|
||||||
public int DispChrome_FrameWindowed = 2;
|
public int DispChrome_FrameWindowed = 2;
|
||||||
public bool DispChrome_StatusBarWindowed = true;
|
public bool DispChrome_StatusBarWindowed = true;
|
||||||
|
@ -378,9 +376,7 @@ namespace BizHawk.Client.Common
|
||||||
public int DispCropBottom = 0;
|
public int DispCropBottom = 0;
|
||||||
|
|
||||||
// Sound options
|
// Sound options
|
||||||
public ESoundOutputMethod SoundOutputMethod = OSTailoredCode.IsWindows()
|
public ESoundOutputMethod SoundOutputMethod = OSTailoredCode.IsUnixHost ? ESoundOutputMethod.OpenAL : ESoundOutputMethod.DirectSound; // force OpenAL for Unix when config is generated
|
||||||
? ESoundOutputMethod.DirectSound
|
|
||||||
: ESoundOutputMethod.OpenAL; // force OpenAL for Unix when config is generated
|
|
||||||
public bool SoundEnabled = true;
|
public bool SoundEnabled = true;
|
||||||
public bool SoundEnabledNormal = true;
|
public bool SoundEnabledNormal = true;
|
||||||
public bool SoundEnabledRWFF = true;
|
public bool SoundEnabledRWFF = true;
|
||||||
|
|
|
@ -43,37 +43,30 @@ namespace BizHawk.Client.Common
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (OSTailoredCode.IsWindows())
|
if (OSTailoredCode.IsUnixHost)
|
||||||
{
|
{
|
||||||
// WARNING: setting the current directory is SLOW!!! security checks for some reason.
|
if (System.IO.Directory.Exists(_currentDirectory)) //TODO is this necessary with Mono? extra TODO: is this necessary with .NET Core on Windows?
|
||||||
// so we're bypassing it with windows hacks
|
{
|
||||||
fixed (byte* pstr = &System.Text.Encoding.Unicode.GetBytes($"{target}\0")[0])
|
Environment.CurrentDirectory = _currentDirectory;
|
||||||
return SetCurrentDirectoryW(pstr);
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (System.IO.Directory.Exists(_currentDirectory)) // race condition for great justice
|
//HACK to bypass Windows security checks triggered by setting the current directory, which only slow us down
|
||||||
{
|
fixed (byte* pstr = &System.Text.Encoding.Unicode.GetBytes($"{target}\0")[0])
|
||||||
Environment.CurrentDirectory = _currentDirectory; // that's right, you can't set a directory as current that doesnt exist because .net's got to do SENSELESS SLOW-ASS SECURITY CHECKS on it and it can't do that on a NONEXISTENT DIRECTORY
|
return SetCurrentDirectoryW(pstr);
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private string CoolGetCurrentDirectory()
|
private string CoolGetCurrentDirectory()
|
||||||
{
|
{
|
||||||
if (OSTailoredCode.IsWindows())
|
if (OSTailoredCode.IsUnixHost) return Environment.CurrentDirectory;
|
||||||
{
|
|
||||||
// GUESS WHAT!
|
|
||||||
// .NET DOES A SECURITY CHECK ON THE DIRECTORY WE JUST RETRIEVED
|
|
||||||
// AS IF ASKING FOR THE CURRENT DIRECTORY IS EQUIVALENT TO TRYING TO ACCESS IT
|
|
||||||
// SCREW YOU
|
|
||||||
var buf = new byte[32768];
|
|
||||||
fixed (byte* pBuf = &buf[0])
|
|
||||||
return System.Text.Encoding.Unicode.GetString(buf, 0, 2 * (int) GetCurrentDirectoryW(32767, pBuf));
|
|
||||||
}
|
|
||||||
|
|
||||||
return Environment.CurrentDirectory;
|
//HACK to bypass Windows security checks triggered by *getting* the current directory (why), which only slow us down
|
||||||
|
var buf = new byte[32768];
|
||||||
|
fixed (byte* pBuf = &buf[0])
|
||||||
|
return System.Text.Encoding.Unicode.GetString(buf, 0, 2 * (int) GetCurrentDirectoryW(32767, pBuf));
|
||||||
}
|
}
|
||||||
|
|
||||||
private void Sandbox(Action callback, Action exceptionCallback)
|
private void Sandbox(Action callback, Action exceptionCallback)
|
||||||
|
|
|
@ -86,9 +86,7 @@ namespace BizHawk.Client.EmuHawk
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
_ffmpeg = OSTailoredCode.ConstructSubshell(
|
_ffmpeg = OSTailoredCode.ConstructSubshell(
|
||||||
OSTailoredCode.IsWindows()
|
OSTailoredCode.IsUnixHost ? "ffmpeg" : Path.Combine(PathManager.GetDllDirectory(), "ffmpeg.exe"),
|
||||||
? Path.Combine(PathManager.GetDllDirectory(), "ffmpeg.exe")
|
|
||||||
: "ffmpeg",
|
|
||||||
$"-y -f nut -i - {_token.Commandline} \"{_baseName}{(_segment == 0 ? string.Empty : $"_{_segment}")}{_ext}\"",
|
$"-y -f nut -i - {_token.Commandline} \"{_baseName}{(_segment == 0 ? string.Empty : $"_{_segment}")}{_ext}\"",
|
||||||
checkStdout: false,
|
checkStdout: false,
|
||||||
checkStderr: true // ffmpeg sends informative display to stderr, and nothing to stdout
|
checkStderr: true // ffmpeg sends informative display to stderr, and nothing to stdout
|
||||||
|
|
|
@ -83,14 +83,7 @@ namespace BizHawk.Client.EmuHawk
|
||||||
SetStyle(ControlStyles.Opaque, true);
|
SetStyle(ControlStyles.Opaque, true);
|
||||||
SetStyle(ControlStyles.OptimizedDoubleBuffer, true);
|
SetStyle(ControlStyles.OptimizedDoubleBuffer, true);
|
||||||
|
|
||||||
if (OSTailoredCode.IsWindows())
|
_renderer = OSTailoredCode.IsUnixHost ? (IControlRenderer) new GdiPlusRenderer() : new GdiRenderer();
|
||||||
{
|
|
||||||
_renderer = new GdiRenderer();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
_renderer = new GdiPlusRenderer();
|
|
||||||
}
|
|
||||||
|
|
||||||
using (var g = CreateGraphics())
|
using (var g = CreateGraphics())
|
||||||
using (_renderer.LockGraphics(g, Width, Height))
|
using (_renderer.LockGraphics(g, Width, Height))
|
||||||
|
|
|
@ -128,24 +128,24 @@ namespace BizHawk.Client.EmuHawk
|
||||||
|
|
||||||
public static void Initialize()
|
public static void Initialize()
|
||||||
{
|
{
|
||||||
if (OSTailoredCode.IsWindows())
|
if (OSTailoredCode.IsUnixHost)
|
||||||
|
{
|
||||||
|
OTK_Keyboard.Initialize();
|
||||||
|
OTK_GamePad.Initialize();
|
||||||
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
KeyInput.Initialize();
|
KeyInput.Initialize();
|
||||||
IPCKeyInput.Initialize();
|
IPCKeyInput.Initialize();
|
||||||
GamePad.Initialize();
|
GamePad.Initialize();
|
||||||
GamePad360.Initialize();
|
GamePad360.Initialize();
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
OTK_Keyboard.Initialize();
|
|
||||||
OTK_GamePad.Initialize();
|
|
||||||
}
|
|
||||||
Instance = new Input();
|
Instance = new Input();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void Cleanup()
|
public static void Cleanup()
|
||||||
{
|
{
|
||||||
if (OSTailoredCode.IsWindows())
|
if (!OSTailoredCode.IsUnixHost)
|
||||||
{
|
{
|
||||||
KeyInput.Cleanup();
|
KeyInput.Cleanup();
|
||||||
GamePad.Cleanup();
|
GamePad.Cleanup();
|
||||||
|
@ -339,17 +339,17 @@ namespace BizHawk.Client.EmuHawk
|
||||||
{
|
{
|
||||||
while (true)
|
while (true)
|
||||||
{
|
{
|
||||||
var keyEvents = OSTailoredCode.IsWindows()
|
var keyEvents = OSTailoredCode.IsUnixHost
|
||||||
? KeyInput.Update().Concat(IPCKeyInput.Update())
|
? OTK_Keyboard.Update()
|
||||||
: OTK_Keyboard.Update();
|
: KeyInput.Update().Concat(IPCKeyInput.Update());
|
||||||
if (OSTailoredCode.IsWindows())
|
if (OSTailoredCode.IsUnixHost)
|
||||||
{
|
{
|
||||||
GamePad.UpdateAll();
|
OTK_GamePad.UpdateAll();
|
||||||
GamePad360.UpdateAll();
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
OTK_GamePad.UpdateAll();
|
GamePad.UpdateAll();
|
||||||
|
GamePad360.UpdateAll();
|
||||||
}
|
}
|
||||||
|
|
||||||
//this block is going to massively modify data structures that the binding method uses, so we have to lock it all
|
//this block is going to massively modify data structures that the binding method uses, so we have to lock it all
|
||||||
|
|
|
@ -1436,7 +1436,7 @@ namespace BizHawk.Client.EmuHawk
|
||||||
private void RamSearchMenuItem_Click(object sender, EventArgs e)
|
private void RamSearchMenuItem_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
var ramSearch = GlobalWin.Tools.Load<RamSearch>();
|
var ramSearch = GlobalWin.Tools.Load<RamSearch>();
|
||||||
if (!OSTailoredCode.IsWindows())
|
if (OSTailoredCode.IsUnixHost)
|
||||||
{
|
{
|
||||||
// this is apparently needed for weird mono-forms-on-different-thread issues
|
// this is apparently needed for weird mono-forms-on-different-thread issues
|
||||||
// don't do .Show() within Load<T>() for RamSearch - instead put an instance of it here on MainForm, then show here
|
// don't do .Show() within Load<T>() for RamSearch - instead put an instance of it here on MainForm, then show here
|
||||||
|
|
|
@ -165,12 +165,11 @@ namespace BizHawk.Client.EmuHawk
|
||||||
Database.LoadDatabase(Path.Combine(PathManager.GetExeDirectoryAbsolute(), "gamedb", "gamedb.txt"));
|
Database.LoadDatabase(Path.Combine(PathManager.GetExeDirectoryAbsolute(), "gamedb", "gamedb.txt"));
|
||||||
|
|
||||||
// TODO GL - a lot of disorganized wiring-up here
|
// TODO GL - a lot of disorganized wiring-up here
|
||||||
CGC.CGCBinPath = OSTailoredCode.IsWindows()
|
// installed separately on Unix (via package manager or from https://developer.nvidia.com/cg-toolkit-download), look in $PATH
|
||||||
? Path.Combine(PathManager.GetDllDirectory(), "cgc.exe")
|
CGC.CGCBinPath = OSTailoredCode.IsUnixHost ? "cgc" : Path.Combine(PathManager.GetDllDirectory(), "cgc.exe");
|
||||||
: "cgc"; // installed separately (via package manager or from https://developer.nvidia.com/cg-toolkit-download), look in $PATH
|
|
||||||
PresentationPanel = new PresentationPanel
|
PresentationPanel = new PresentationPanel
|
||||||
{
|
{
|
||||||
GraphicsControl = {MainWindow = true}
|
GraphicsControl = { MainWindow = true }
|
||||||
};
|
};
|
||||||
GlobalWin.DisplayManager = new DisplayManager(PresentationPanel);
|
GlobalWin.DisplayManager = new DisplayManager(PresentationPanel);
|
||||||
Controls.Add(PresentationPanel);
|
Controls.Add(PresentationPanel);
|
||||||
|
@ -1049,7 +1048,7 @@ namespace BizHawk.Client.EmuHawk
|
||||||
// (this could be determined with more work; other side affects of the fullscreen mode include: corrupted TaskBar, no modal boxes on top of GL control, no screenshots)
|
// (this could be determined with more work; other side affects of the fullscreen mode include: corrupted TaskBar, no modal boxes on top of GL control, no screenshots)
|
||||||
// At any rate, we can solve this by adding a 1px black border around the GL control
|
// At any rate, we can solve this by adding a 1px black border around the GL control
|
||||||
// Please note: It is important to do this before resizing things, otherwise momentarily a GL control without WS_BORDER will be at the magic dimensions and cause the flakeout
|
// Please note: It is important to do this before resizing things, otherwise momentarily a GL control without WS_BORDER will be at the magic dimensions and cause the flakeout
|
||||||
if (OSTailoredCode.IsWindows()
|
if (!OSTailoredCode.IsUnixHost
|
||||||
&& Global.Config.DispFullscreenHacks
|
&& Global.Config.DispFullscreenHacks
|
||||||
&& Global.Config.DispMethod == Config.EDispMethod.OpenGL)
|
&& Global.Config.DispMethod == Config.EDispMethod.OpenGL)
|
||||||
{
|
{
|
||||||
|
@ -1078,7 +1077,7 @@ namespace BizHawk.Client.EmuHawk
|
||||||
|
|
||||||
WindowState = FormWindowState.Normal;
|
WindowState = FormWindowState.Normal;
|
||||||
|
|
||||||
if (OSTailoredCode.IsWindows())
|
if (!OSTailoredCode.IsUnixHost)
|
||||||
{
|
{
|
||||||
// do this even if DispFullscreenHacks aren't enabled, to restore it in case it changed underneath us or something
|
// do this even if DispFullscreenHacks aren't enabled, to restore it in case it changed underneath us or something
|
||||||
Padding = new Padding(0);
|
Padding = new Padding(0);
|
||||||
|
|
|
@ -21,7 +21,12 @@ namespace BizHawk.Client.EmuHawk
|
||||||
Application.EnableVisualStyles();
|
Application.EnableVisualStyles();
|
||||||
Application.SetCompatibleTextRenderingDefault(false);
|
Application.SetCompatibleTextRenderingDefault(false);
|
||||||
|
|
||||||
if (EXE_PROJECT.OSTailoredCode.IsWindows())
|
if (EXE_PROJECT.OSTailoredCode.IsUnixHost)
|
||||||
|
{
|
||||||
|
// for Unix, skip everything else and just wire up the event handler
|
||||||
|
AppDomain.CurrentDomain.AssemblyResolve += CurrentDomain_AssemblyResolve;
|
||||||
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
var libLoader = EXE_PROJECT.OSTailoredCode.LinkedLibManager;
|
var libLoader = EXE_PROJECT.OSTailoredCode.LinkedLibManager;
|
||||||
|
|
||||||
|
@ -72,18 +77,13 @@ namespace BizHawk.Client.EmuHawk
|
||||||
|
|
||||||
//We need to do it here too... otherwise people get exceptions when externaltools we distribute try to startup
|
//We need to do it here too... otherwise people get exceptions when externaltools we distribute try to startup
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
// for Unix, skip everything else and just wire up the event handler
|
|
||||||
AppDomain.CurrentDomain.AssemblyResolve += CurrentDomain_AssemblyResolve;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
[STAThread]
|
[STAThread]
|
||||||
private static int Main(string[] args)
|
private static int Main(string[] args)
|
||||||
{
|
{
|
||||||
var exitCode = SubMain(args);
|
var exitCode = SubMain(args);
|
||||||
if (EXE_PROJECT.OSTailoredCode.IsLinux())
|
if (EXE_PROJECT.OSTailoredCode.IsUnixHost)
|
||||||
{
|
{
|
||||||
Console.WriteLine("BizHawk has completed its shutdown routines, killing process...");
|
Console.WriteLine("BizHawk has completed its shutdown routines, killing process...");
|
||||||
Process.GetCurrentProcess().Kill();
|
Process.GetCurrentProcess().Kill();
|
||||||
|
@ -99,7 +99,7 @@ namespace BizHawk.Client.EmuHawk
|
||||||
// and there was a TypeLoadException before the first line of SubMain was reached (some static ColorType init?)
|
// and there was a TypeLoadException before the first line of SubMain was reached (some static ColorType init?)
|
||||||
// zero 25-dec-2012 - only do for public builds. its annoying during development
|
// zero 25-dec-2012 - only do for public builds. its annoying during development
|
||||||
// and don't bother when installed from a package manager i.e. not Windows --yoshi
|
// and don't bother when installed from a package manager i.e. not Windows --yoshi
|
||||||
if (!VersionInfo.DeveloperBuild && EXE_PROJECT.OSTailoredCode.IsWindows())
|
if (!VersionInfo.DeveloperBuild && !EXE_PROJECT.OSTailoredCode.IsUnixHost)
|
||||||
{
|
{
|
||||||
var thisversion = typeof(Program).Assembly.GetName().Version;
|
var thisversion = typeof(Program).Assembly.GetName().Version;
|
||||||
var utilversion = Assembly.Load(new AssemblyName("Bizhawk.Client.Common")).GetName().Version;
|
var utilversion = Assembly.Load(new AssemblyName("Bizhawk.Client.Common")).GetName().Version;
|
||||||
|
@ -150,10 +150,7 @@ namespace BizHawk.Client.EmuHawk
|
||||||
GlobalWin.GLManager = GLManager.Instance;
|
GlobalWin.GLManager = GLManager.Instance;
|
||||||
|
|
||||||
//now create the "GL" context for the display method. we can reuse the IGL_TK context if opengl display method is chosen
|
//now create the "GL" context for the display method. we can reuse the IGL_TK context if opengl display method is chosen
|
||||||
if (!EXE_PROJECT.OSTailoredCode.IsWindows())
|
REDO_DISPMETHOD:
|
||||||
Global.Config.DispMethod = Config.EDispMethod.GdiPlus;
|
|
||||||
|
|
||||||
REDO_DISPMETHOD:
|
|
||||||
if (Global.Config.DispMethod == Config.EDispMethod.GdiPlus)
|
if (Global.Config.DispMethod == Config.EDispMethod.GdiPlus)
|
||||||
GlobalWin.GL = new Bizware.BizwareGL.Drivers.GdiPlus.IGL_GdiPlus();
|
GlobalWin.GL = new Bizware.BizwareGL.Drivers.GdiPlus.IGL_GdiPlus();
|
||||||
else if (Global.Config.DispMethod == Config.EDispMethod.SlimDX9)
|
else if (Global.Config.DispMethod == Config.EDispMethod.SlimDX9)
|
||||||
|
@ -198,7 +195,7 @@ namespace BizHawk.Client.EmuHawk
|
||||||
goto REDO_DISPMETHOD;
|
goto REDO_DISPMETHOD;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (EXE_PROJECT.OSTailoredCode.IsWindows())
|
if (!EXE_PROJECT.OSTailoredCode.IsUnixHost)
|
||||||
{
|
{
|
||||||
//WHY do we have to do this? some intel graphics drivers (ig7icd64.dll 10.18.10.3304 on an unknown chip on win8.1) are calling SetDllDirectory() for the process, which ruins stuff.
|
//WHY do we have to do this? some intel graphics drivers (ig7icd64.dll 10.18.10.3304 on an unknown chip on win8.1) are calling SetDllDirectory() for the process, which ruins stuff.
|
||||||
//The relevant initialization happened just before in "create IGL context".
|
//The relevant initialization happened just before in "create IGL context".
|
||||||
|
@ -319,7 +316,7 @@ namespace BizHawk.Client.EmuHawk
|
||||||
//so.. we're going to resort to something really bad.
|
//so.. we're going to resort to something really bad.
|
||||||
//avert your eyes.
|
//avert your eyes.
|
||||||
var configPath = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "config.ini");
|
var configPath = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "config.ini");
|
||||||
if (EXE_PROJECT.OSTailoredCode.IsWindows() // LuaInterface is not currently working on Mono
|
if (!EXE_PROJECT.OSTailoredCode.IsUnixHost // LuaInterface is not currently working on Mono
|
||||||
&& File.Exists(configPath)
|
&& File.Exists(configPath)
|
||||||
&& (Array.Find(File.ReadAllLines(configPath), line => line.Contains(" \"UseNLua\": ")) ?? string.Empty)
|
&& (Array.Find(File.ReadAllLines(configPath), line => line.Contains(" \"UseNLua\": ")) ?? string.Empty)
|
||||||
.Contains("false"))
|
.Contains("false"))
|
||||||
|
|
|
@ -45,9 +45,9 @@ namespace BizHawk.Client.EmuHawk
|
||||||
public int Duration { get; set; } = 0; //TODO implementation
|
public int Duration { get; set; } = 0; //TODO implementation
|
||||||
}
|
}
|
||||||
|
|
||||||
private static readonly IScreenBlankTimer _screenBlankTimer = OSTailoredCode.IsWindows()
|
private static readonly IScreenBlankTimer _screenBlankTimer = OSTailoredCode.IsUnixHost
|
||||||
? (IScreenBlankTimer) new Win32ScreenBlankTimer()
|
? (IScreenBlankTimer) new UnixScreenBlankTimer()
|
||||||
: new UnixScreenBlankTimer();
|
: new Win32ScreenBlankTimer();
|
||||||
|
|
||||||
private static int ctr;
|
private static int ctr;
|
||||||
|
|
||||||
|
|
|
@ -23,7 +23,12 @@ namespace BizHawk.Client.EmuHawk
|
||||||
|
|
||||||
public Sound(IntPtr mainWindowHandle)
|
public Sound(IntPtr mainWindowHandle)
|
||||||
{
|
{
|
||||||
if (OSTailoredCode.IsWindows())
|
if (OSTailoredCode.IsUnixHost)
|
||||||
|
{
|
||||||
|
// at the moment unix/mono can only support OpenAL (so ignore whatever is set in the config)
|
||||||
|
_outputDevice = new OpenALSoundOutput(this);
|
||||||
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
if (Global.Config.SoundOutputMethod == Config.ESoundOutputMethod.OpenAL)
|
if (Global.Config.SoundOutputMethod == Config.ESoundOutputMethod.OpenAL)
|
||||||
_outputDevice = new OpenALSoundOutput(this);
|
_outputDevice = new OpenALSoundOutput(this);
|
||||||
|
@ -32,7 +37,6 @@ namespace BizHawk.Client.EmuHawk
|
||||||
if (Global.Config.SoundOutputMethod == Config.ESoundOutputMethod.XAudio2)
|
if (Global.Config.SoundOutputMethod == Config.ESoundOutputMethod.XAudio2)
|
||||||
_outputDevice = new XAudio2SoundOutput(this);
|
_outputDevice = new XAudio2SoundOutput(this);
|
||||||
}
|
}
|
||||||
else _outputDevice = new OpenALSoundOutput(this); // at the moment unix/mono can only support OpenAL (so ignore whatever is set in the config)
|
|
||||||
|
|
||||||
if (_outputDevice == null)
|
if (_outputDevice == null)
|
||||||
_outputDevice = new DummySoundOutput(this);
|
_outputDevice = new DummySoundOutput(this);
|
||||||
|
|
|
@ -160,9 +160,7 @@ namespace BizHawk.Client.EmuHawk
|
||||||
return ms;
|
return ms;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
static readonly PlatformSpecificSysTimer sysTimer = OSTailoredCode.IsWindows()
|
static readonly PlatformSpecificSysTimer sysTimer = OSTailoredCode.IsUnixHost ? (PlatformSpecificSysTimer) new UnixMonoSysTimer() : new WinSysTimer();
|
||||||
? (PlatformSpecificSysTimer) new WinSysTimer()
|
|
||||||
: new UnixMonoSysTimer();
|
|
||||||
static uint TimeBeginPeriod(uint ms)
|
static uint TimeBeginPeriod(uint ms)
|
||||||
{
|
{
|
||||||
return sysTimer.TimeBeginPeriod(ms);
|
return sysTimer.TimeBeginPeriod(ms);
|
||||||
|
|
|
@ -93,7 +93,7 @@ namespace BizHawk.Client.EmuHawk
|
||||||
|
|
||||||
RefreshAspectRatioOptions();
|
RefreshAspectRatioOptions();
|
||||||
|
|
||||||
if (!OSTailoredCode.IsWindows())
|
if (OSTailoredCode.IsUnixHost)
|
||||||
{
|
{
|
||||||
// Disable SlimDX on Unix
|
// Disable SlimDX on Unix
|
||||||
rbD3D9.Enabled = false;
|
rbD3D9.Enabled = false;
|
||||||
|
|
|
@ -356,16 +356,7 @@ namespace BizHawk.Client.EmuHawk
|
||||||
DoScan();
|
DoScan();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void tbbOpenFolder_Click(object sender, EventArgs e)
|
private void tbbOpenFolder_Click(object sender, EventArgs e) => System.Diagnostics.Process.Start(PathManager.MakeAbsolutePath(Global.Config.PathEntries.FirmwaresPathFragment, null));
|
||||||
{
|
|
||||||
var frmWares = PathManager.MakeAbsolutePath(Global.Config.PathEntries.FirmwaresPathFragment, null);
|
|
||||||
if (!OSTailoredCode.IsWindows() && !Directory.Exists(frmWares))
|
|
||||||
{
|
|
||||||
Directory.CreateDirectory(frmWares);
|
|
||||||
}
|
|
||||||
|
|
||||||
System.Diagnostics.Process.Start(frmWares);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void lvFirmwares_KeyDown(object sender, KeyEventArgs e)
|
private void lvFirmwares_KeyDown(object sender, KeyEventArgs e)
|
||||||
{
|
{
|
||||||
|
|
|
@ -67,11 +67,7 @@ namespace BizHawk.Client.EmuHawk
|
||||||
|
|
||||||
protected override void OnMouseClick(MouseEventArgs e)
|
protected override void OnMouseClick(MouseEventArgs e)
|
||||||
{
|
{
|
||||||
if (OSTailoredCode.IsWindows())
|
if (!OSTailoredCode.IsUnixHost) HideCaret(Handle);
|
||||||
{
|
|
||||||
HideCaret(Handle);
|
|
||||||
}
|
|
||||||
|
|
||||||
base.OnMouseClick(e);
|
base.OnMouseClick(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -263,10 +259,7 @@ namespace BizHawk.Client.EmuHawk
|
||||||
|
|
||||||
protected override void OnGotFocus(EventArgs e)
|
protected override void OnGotFocus(EventArgs e)
|
||||||
{
|
{
|
||||||
if (OSTailoredCode.IsWindows())
|
if (!OSTailoredCode.IsUnixHost) HideCaret(Handle);
|
||||||
{
|
|
||||||
HideCaret(Handle);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override bool ProcessCmdKey(ref Message msg, Keys keyData)
|
protected override bool ProcessCmdKey(ref Message msg, Keys keyData)
|
||||||
|
|
|
@ -220,9 +220,10 @@ namespace BizHawk.Client.EmuHawk
|
||||||
|
|
||||||
DialogResult result;
|
DialogResult result;
|
||||||
string selectedPath;
|
string selectedPath;
|
||||||
if (OSTailoredCode.CurrentOS == OSTailoredCode.DistinctOS.Windows)
|
if (OSTailoredCode.IsUnixHost)
|
||||||
{
|
{
|
||||||
using var f = new FolderBrowserEx
|
// FolderBrowserEx doesn't work in Mono for obvious reasons
|
||||||
|
using var f = new FolderBrowserDialog
|
||||||
{
|
{
|
||||||
Description = $"Set the directory for {name}",
|
Description = $"Set the directory for {name}",
|
||||||
SelectedPath = PathManager.MakeAbsolutePath(box.Text, system)
|
SelectedPath = PathManager.MakeAbsolutePath(box.Text, system)
|
||||||
|
@ -232,8 +233,7 @@ namespace BizHawk.Client.EmuHawk
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// FolderBrowserEx doesn't work in Mono for obvious reasons
|
using var f = new FolderBrowserEx
|
||||||
using var f = new FolderBrowserDialog
|
|
||||||
{
|
{
|
||||||
Description = $"Set the directory for {name}",
|
Description = $"Set the directory for {name}",
|
||||||
SelectedPath = PathManager.MakeAbsolutePath(box.Text, system)
|
SelectedPath = PathManager.MakeAbsolutePath(box.Text, system)
|
||||||
|
|
|
@ -26,7 +26,7 @@ namespace BizHawk.Client.EmuHawk
|
||||||
cbEnableRWFF.Checked = Global.Config.SoundEnabledRWFF;
|
cbEnableRWFF.Checked = Global.Config.SoundEnabledRWFF;
|
||||||
cbMuteFrameAdvance.Checked = Global.Config.MuteFrameAdvance;
|
cbMuteFrameAdvance.Checked = Global.Config.MuteFrameAdvance;
|
||||||
|
|
||||||
if (!OSTailoredCode.IsWindows())
|
if (OSTailoredCode.IsUnixHost)
|
||||||
{
|
{
|
||||||
// Disable DirectSound and XAudio2 on Mono
|
// Disable DirectSound and XAudio2 on Mono
|
||||||
rbOutputMethodDirectSound.Enabled = false;
|
rbOutputMethodDirectSound.Enabled = false;
|
||||||
|
@ -88,7 +88,7 @@ namespace BizHawk.Client.EmuHawk
|
||||||
private void PopulateDeviceList()
|
private void PopulateDeviceList()
|
||||||
{
|
{
|
||||||
IEnumerable<string> deviceNames = Enumerable.Empty<string>();
|
IEnumerable<string> deviceNames = Enumerable.Empty<string>();
|
||||||
if (OSTailoredCode.IsWindows())
|
if (!OSTailoredCode.IsUnixHost)
|
||||||
{
|
{
|
||||||
if (rbOutputMethodDirectSound.Checked) deviceNames = DirectSoundSoundOutput.GetDeviceNames();
|
if (rbOutputMethodDirectSound.Checked) deviceNames = DirectSoundSoundOutput.GetDeviceNames();
|
||||||
if (rbOutputMethodXAudio2.Checked) deviceNames = XAudio2SoundOutput.GetDeviceNames();
|
if (rbOutputMethodXAudio2.Checked) deviceNames = XAudio2SoundOutput.GetDeviceNames();
|
||||||
|
|
|
@ -17,8 +17,7 @@ namespace BizHawk.Client.EmuHawk
|
||||||
{
|
{
|
||||||
public EmuLuaLibrary()
|
public EmuLuaLibrary()
|
||||||
{
|
{
|
||||||
Docs = new LuaDocumentation();
|
// if (NLua.Lua.WhichLua == "NLua")
|
||||||
//if(NLua.Lua.WhichLua == "NLua")
|
|
||||||
_lua["keepalives"] = _lua.NewTable();
|
_lua["keepalives"] = _lua.NewTable();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -10,23 +10,15 @@ namespace BizHawk.Client.EmuHawk
|
||||||
{
|
{
|
||||||
public abstract class PlatformEmuLuaLibrary
|
public abstract class PlatformEmuLuaLibrary
|
||||||
{
|
{
|
||||||
public LuaDocumentation Docs { get; protected set; }
|
public readonly LuaDocumentation Docs = new LuaDocumentation();
|
||||||
|
|
||||||
public GuiLuaLibrary GuiLibrary => (GuiLuaLibrary) Libraries[typeof(GuiLuaLibrary)];
|
public GuiLuaLibrary GuiLibrary => (GuiLuaLibrary) Libraries[typeof(GuiLuaLibrary)];
|
||||||
|
protected readonly Dictionary<Type, LuaLibraryBase> Libraries = new Dictionary<Type, LuaLibraryBase>();
|
||||||
|
public IEnumerable<LuaFile> RunningScripts => ScriptList.Where(lf => lf.Enabled);
|
||||||
|
public readonly LuaFileList ScriptList = new LuaFileList();
|
||||||
|
|
||||||
public bool IsRebootingCore { get; set; } // pretty hacky.. we dont want a lua script to be able to restart itself by rebooting the core
|
public bool IsRebootingCore { get; set; } // pretty hacky.. we dont want a lua script to be able to restart itself by rebooting the core
|
||||||
|
|
||||||
protected readonly Dictionary<Type, LuaLibraryBase> Libraries = new Dictionary<Type, LuaLibraryBase>();
|
|
||||||
|
|
||||||
public EventWaitHandle LuaWait { get; protected set; }
|
public EventWaitHandle LuaWait { get; protected set; }
|
||||||
|
|
||||||
public IEnumerable<LuaFile> RunningScripts
|
|
||||||
{
|
|
||||||
get { return ScriptList.Where(lf => lf.Enabled); }
|
|
||||||
}
|
|
||||||
|
|
||||||
public readonly LuaFileList ScriptList = new LuaFileList();
|
|
||||||
|
|
||||||
public abstract void CallExitEvent(LuaFile lf);
|
public abstract void CallExitEvent(LuaFile lf);
|
||||||
public abstract void CallFrameAfterEvent();
|
public abstract void CallFrameAfterEvent();
|
||||||
public abstract void CallFrameBeforeEvent();
|
public abstract void CallFrameBeforeEvent();
|
||||||
|
|
|
@ -185,13 +185,8 @@ namespace BizHawk.Client.EmuHawk
|
||||||
}
|
}
|
||||||
|
|
||||||
var currentScripts = LuaImp?.ScriptList; // Temp fix for now
|
var currentScripts = LuaImp?.ScriptList; // Temp fix for now
|
||||||
LuaImp = OSTailoredCode.IsWindows()
|
LuaImp = OSTailoredCode.IsUnixHost ? (PlatformEmuLuaLibrary) new NotReallyLuaLibrary() : new EmuLuaLibrary(Emulator.ServiceProvider);
|
||||||
? (PlatformEmuLuaLibrary)new EmuLuaLibrary(Emulator.ServiceProvider)
|
LuaImp.ScriptList.AddRange(currentScripts ?? Enumerable.Empty<LuaFile>());
|
||||||
: (PlatformEmuLuaLibrary)new NotReallyLuaLibrary();
|
|
||||||
if (currentScripts != null)
|
|
||||||
{
|
|
||||||
LuaImp.ScriptList.AddRange(currentScripts);
|
|
||||||
}
|
|
||||||
|
|
||||||
InputBox.AutoCompleteCustomSource.AddRange(LuaImp.Docs.Select(a => $"{a.Library}.{a.Name}").ToArray());
|
InputBox.AutoCompleteCustomSource.AddRange(LuaImp.Docs.Select(a => $"{a.Library}.{a.Name}").ToArray());
|
||||||
|
|
||||||
|
|
|
@ -268,56 +268,31 @@ namespace BizHawk.Client.EmuHawk
|
||||||
/// <remarks>Algorithm for Windows taken from https://stackoverflow.com/a/485516/7467292</remarks>
|
/// <remarks>Algorithm for Windows taken from https://stackoverflow.com/a/485516/7467292</remarks>
|
||||||
public static string GetRelativePath(string fromPath, string toPath)
|
public static string GetRelativePath(string fromPath, string toPath)
|
||||||
{
|
{
|
||||||
if (OSTailoredCode.IsWindows())
|
if (OSTailoredCode.IsUnixHost)
|
||||||
{
|
{
|
||||||
Win32.FileAttributes fromAttr = GetPathAttribute(fromPath);
|
|
||||||
Win32.FileAttributes toAttr = GetPathAttribute(toPath);
|
|
||||||
|
|
||||||
var path = new StringBuilder(260); // MAX_PATH
|
|
||||||
if (Win32.PathRelativePathTo(
|
|
||||||
path,
|
|
||||||
fromPath,
|
|
||||||
fromAttr,
|
|
||||||
toPath,
|
|
||||||
toAttr) == false)
|
|
||||||
{
|
|
||||||
throw new ArgumentException("Paths must have a common prefix");
|
|
||||||
}
|
|
||||||
|
|
||||||
return path.ToString();
|
|
||||||
}
|
|
||||||
#if true
|
#if true
|
||||||
return PathManager.IsSubfolder(toPath, fromPath)
|
return PathManager.IsSubfolder(toPath, fromPath)
|
||||||
? "./" + OSTailoredCode.SimpleSubshell("realpath", $"--relative-to=\"{toPath}\" \"{fromPath}\"", $"invalid path {fromPath} or missing realpath binary")
|
? "./" + OSTailoredCode.SimpleSubshell("realpath", $"--relative-to=\"{toPath}\" \"{fromPath}\"", $"invalid path {fromPath} or missing realpath binary")
|
||||||
: fromPath;
|
: fromPath;
|
||||||
#else // written for Unix port but may be useful for .NET Core
|
#else // written for Unix port but may be useful for .NET Core
|
||||||
// algorithm taken from https://stackoverflow.com/a/340454/7467292
|
// algorithm taken from https://stackoverflow.com/a/340454/7467292
|
||||||
var dirSepChar = Path.DirectorySeparatorChar;
|
var dirSepChar = Path.DirectorySeparatorChar;
|
||||||
string from = !fromPath.EndsWith(dirSepChar.ToString())
|
var fromUri = new Uri(fromPath.EndsWith(dirSepChar.ToString()) ? fromPath : fromPath + dirSepChar);
|
||||||
? fromPath + dirSepChar
|
var toUri = new Uri(toPath.EndsWith(dirSepChar.ToString()) ? toPath : toPath + dirSepChar);
|
||||||
: fromPath;
|
if (fromUri.Scheme != toUri.Scheme) return toPath;
|
||||||
string to = !toPath.EndsWith(dirSepChar.ToString())
|
|
||||||
? toPath + dirSepChar
|
|
||||||
: toPath;
|
|
||||||
|
|
||||||
Uri fromUri = new Uri(from);
|
var relativePath = Uri.UnescapeDataString(fromUri.MakeRelativeUri(toUri).ToString());
|
||||||
Uri toUri = new Uri(to);
|
return (toUri.Scheme.Equals(Uri.UriSchemeFile, StringComparison.OrdinalIgnoreCase)
|
||||||
|
? relativePath.Replace(Path.AltDirectorySeparatorChar, Path.DirectorySeparatorChar)
|
||||||
if (fromUri.Scheme != toUri.Scheme)
|
: relativePath
|
||||||
{
|
).TrimEnd(dirSepChar);
|
||||||
return toPath;
|
|
||||||
}
|
|
||||||
|
|
||||||
Uri relativeUri = fromUri.MakeRelativeUri(toUri);
|
|
||||||
string relativePath = Uri.UnescapeDataString(relativeUri.ToString());
|
|
||||||
|
|
||||||
if (string.Equals(toUri.Scheme, Uri.UriSchemeFile, StringComparison.OrdinalIgnoreCase))
|
|
||||||
{
|
|
||||||
relativePath = relativePath.Replace(Path.AltDirectorySeparatorChar, Path.DirectorySeparatorChar);
|
|
||||||
}
|
|
||||||
|
|
||||||
return relativePath.TrimEnd(dirSepChar);
|
|
||||||
#endif
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
var path = new StringBuilder(260 /* = MAX_PATH */);
|
||||||
|
return Win32.PathRelativePathTo(path, fromPath, GetPathAttribute(fromPath), toPath, GetPathAttribute(toPath))
|
||||||
|
? path.ToString()
|
||||||
|
: throw new ArgumentException("Paths must have a common prefix");
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <seealso cref="GetRelativePath"/>
|
/// <seealso cref="GetRelativePath"/>
|
||||||
|
|
|
@ -157,7 +157,7 @@ namespace BizHawk.Client.EmuHawk
|
||||||
}
|
}
|
||||||
|
|
||||||
newTool.Restart();
|
newTool.Restart();
|
||||||
if (!OSTailoredCode.IsWindows() && newTool is RamSearch)
|
if (OSTailoredCode.IsUnixHost && newTool is RamSearch)
|
||||||
{
|
{
|
||||||
// the mono winforms implementation is buggy, skip to the return statement and call Show in MainForm instead
|
// the mono winforms implementation is buggy, skip to the return statement and call Show in MainForm instead
|
||||||
}
|
}
|
||||||
|
@ -748,8 +748,7 @@ namespace BizHawk.Client.EmuHawk
|
||||||
public bool IsAvailable(Type tool)
|
public bool IsAvailable(Type tool)
|
||||||
{
|
{
|
||||||
if (!ServiceInjector.IsAvailable(Global.Emulator.ServiceProvider, tool)
|
if (!ServiceInjector.IsAvailable(Global.Emulator.ServiceProvider, tool)
|
||||||
|| !lazyAsmTypes.Value.Contains(tool.AssemblyQualifiedName) // not a tool
|
|| !lazyAsmTypes.Value.Contains(tool.AssemblyQualifiedName)) // not a tool
|
||||||
|| (tool == typeof(LuaConsole) && !OSTailoredCode.IsWindows())) // simply doesn't work (for now)
|
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -95,9 +95,9 @@ namespace BizHawk.Common.BizInvoke
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>allocate <paramref name="size"/> bytes starting at a particular address <paramref name="start"/></summary>
|
/// <summary>allocate <paramref name="size"/> bytes starting at a particular address <paramref name="start"/></summary>
|
||||||
public static MemoryBlockBase CallPlatformCtor(ulong start, ulong size) => OSTailoredCode.CurrentOS == OSTailoredCode.DistinctOS.Windows
|
public static MemoryBlockBase CallPlatformCtor(ulong start, ulong size) => OSTailoredCode.IsUnixHost
|
||||||
? (MemoryBlockBase) new MemoryBlock(start, size)
|
? (MemoryBlockBase) new MemoryBlockUnix(start, size)
|
||||||
: new MemoryBlockUnix(start, size);
|
: new MemoryBlock(start, size);
|
||||||
|
|
||||||
/// <summary>allocate <paramref name="size"/> bytes at any address</summary>
|
/// <summary>allocate <paramref name="size"/> bytes at any address</summary>
|
||||||
public static MemoryBlockBase CallPlatformCtor(ulong size) => CallPlatformCtor(0, size);
|
public static MemoryBlockBase CallPlatformCtor(ulong size) => CallPlatformCtor(0, size);
|
||||||
|
|
|
@ -17,15 +17,7 @@ namespace BizHawk.Common
|
||||||
? SimpleSubshell("uname", "-s", "Can't determine OS") == "Darwin" ? DistinctOS.macOS : DistinctOS.Linux
|
? SimpleSubshell("uname", "-s", "Can't determine OS") == "Darwin" ? DistinctOS.macOS : DistinctOS.Linux
|
||||||
: DistinctOS.Windows;
|
: DistinctOS.Windows;
|
||||||
|
|
||||||
public static bool IsWindows()
|
public static readonly bool IsUnixHost = CurrentOS != DistinctOS.Windows;
|
||||||
{
|
|
||||||
return CurrentOS == DistinctOS.Windows;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static bool IsLinux()
|
|
||||||
{
|
|
||||||
return CurrentOS == DistinctOS.Linux;
|
|
||||||
}
|
|
||||||
|
|
||||||
private static readonly Lazy<ILinkedLibManager> _LinkedLibManager = new Lazy<ILinkedLibManager>(() =>
|
private static readonly Lazy<ILinkedLibManager> _LinkedLibManager = new Lazy<ILinkedLibManager>(() =>
|
||||||
{
|
{
|
||||||
|
|
|
@ -93,13 +93,13 @@ namespace BizHawk.Common
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
if (OSTailoredCode.IsWindows())
|
if (OSTailoredCode.IsUnixHost)
|
||||||
{
|
{
|
||||||
DeleteFileW(fi.FullName); // SHUT. UP. THE. EXCEPTIONS.
|
fi.Delete(); // naive deletion, Mono doesn't care
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
fi.Delete();
|
DeleteFileW(fi.FullName); // SHUT. UP. THE. EXCEPTIONS.
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch
|
catch
|
||||||
|
|
|
@ -22,7 +22,7 @@ namespace BizHawk.Emulation.Cores.Consoles.Nintendo.QuickNES
|
||||||
{
|
{
|
||||||
static QuickNES()
|
static QuickNES()
|
||||||
{
|
{
|
||||||
Resolver = new DynamicLibraryImportResolver($"libquicknes{(OSTailoredCode.CurrentOS == OSTailoredCode.DistinctOS.Windows ? ".dll" : ".dll.so.0.7.0")}");
|
Resolver = new DynamicLibraryImportResolver($"libquicknes{(OSTailoredCode.IsUnixHost ? ".dll.so.0.7.0" : ".dll")}");
|
||||||
QN = BizInvoker.GetInvoker<LibQuickNES>(Resolver, CallingConventionAdapters.Native);
|
QN = BizInvoker.GetInvoker<LibQuickNES>(Resolver, CallingConventionAdapters.Native);
|
||||||
QN.qn_setup_mappers();
|
QN.qn_setup_mappers();
|
||||||
}
|
}
|
||||||
|
@ -30,9 +30,9 @@ namespace BizHawk.Emulation.Cores.Consoles.Nintendo.QuickNES
|
||||||
[CoreConstructor("NES")]
|
[CoreConstructor("NES")]
|
||||||
public QuickNES(CoreComm comm, byte[] file, object settings, object syncSettings)
|
public QuickNES(CoreComm comm, byte[] file, object settings, object syncSettings)
|
||||||
{
|
{
|
||||||
FP = OSTailoredCode.CurrentOS == OSTailoredCode.DistinctOS.Windows
|
FP = OSTailoredCode.IsUnixHost
|
||||||
? (IFPCtrl) new Win32_FPCtrl()
|
? (IFPCtrl) new Unix_FPCtrl()
|
||||||
: new Unix_FPCtrl();
|
: new Win32_FPCtrl();
|
||||||
|
|
||||||
using (FP.Save())
|
using (FP.Save())
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue