Simplify OS checks with some helpful methods
This commit is contained in:
parent
e1075d1006
commit
942d9fc75e
|
@ -410,7 +410,7 @@ namespace BizHawk.Client.Common
|
||||||
#if true
|
#if true
|
||||||
if (!IsSubfolder(parentPath, absolutePath)) return absolutePath;
|
if (!IsSubfolder(parentPath, absolutePath)) return absolutePath;
|
||||||
|
|
||||||
return OSTailoredCode.CurrentOS == OSTailoredCode.DistinctOS.Windows
|
return OSTailoredCode.IsWindows()
|
||||||
? absolutePath.Replace(parentPath, ".")
|
? 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");
|
||||||
#else // written for Unix port but may be useful for .NET Core
|
#else // written for Unix port but may be useful for .NET Core
|
||||||
|
@ -441,7 +441,7 @@ 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.CurrentOS == OSTailoredCode.DistinctOS.Windows)
|
if (OSTailoredCode.IsWindows())
|
||||||
{
|
{
|
||||||
var parentUri = new Uri(parentPath);
|
var parentUri = new Uri(parentPath);
|
||||||
|
|
||||||
|
|
|
@ -348,7 +348,7 @@ namespace BizHawk.Client.Common
|
||||||
/// 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 GDI+ for Unix when a new config is generated
|
||||||
/// </remarks>
|
/// </remarks>
|
||||||
public EDispMethod DispMethod = OSTailoredCode.CurrentOS == OSTailoredCode.DistinctOS.Windows
|
public EDispMethod DispMethod = OSTailoredCode.IsWindows()
|
||||||
? EDispMethod.SlimDX9
|
? EDispMethod.SlimDX9
|
||||||
: EDispMethod.GdiPlus;
|
: EDispMethod.GdiPlus;
|
||||||
|
|
||||||
|
@ -378,7 +378,7 @@ namespace BizHawk.Client.Common
|
||||||
public int DispCropBottom = 0;
|
public int DispCropBottom = 0;
|
||||||
|
|
||||||
// Sound options
|
// Sound options
|
||||||
public ESoundOutputMethod SoundOutputMethod = OSTailoredCode.CurrentOS == OSTailoredCode.DistinctOS.Windows
|
public ESoundOutputMethod SoundOutputMethod = OSTailoredCode.IsWindows()
|
||||||
? ESoundOutputMethod.DirectSound
|
? ESoundOutputMethod.DirectSound
|
||||||
: ESoundOutputMethod.OpenAL; // force OpenAL for Unix when config is generated
|
: ESoundOutputMethod.OpenAL; // force OpenAL for Unix when config is generated
|
||||||
public bool SoundEnabled = true;
|
public bool SoundEnabled = true;
|
||||||
|
|
|
@ -43,30 +43,26 @@ namespace BizHawk.Client.Common
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (OSTailoredCode.CurrentOS == OSTailoredCode.DistinctOS.Windows)
|
if (OSTailoredCode.IsWindows())
|
||||||
{
|
{
|
||||||
// WARNING: setting the current directory is SLOW!!! security checks for some reason.
|
// WARNING: setting the current directory is SLOW!!! security checks for some reason.
|
||||||
// so we're bypassing it with windows hacks
|
// so we're bypassing it with windows hacks
|
||||||
fixed (byte* pstr = &System.Text.Encoding.Unicode.GetBytes($"{target}\0")[0])
|
fixed (byte* pstr = &System.Text.Encoding.Unicode.GetBytes($"{target}\0")[0])
|
||||||
return SetCurrentDirectoryW(pstr);
|
return SetCurrentDirectoryW(pstr);
|
||||||
}
|
}
|
||||||
else
|
|
||||||
|
if (System.IO.Directory.Exists(_currentDirectory)) // race condition for great justice
|
||||||
{
|
{
|
||||||
if (System.IO.Directory.Exists(_currentDirectory)) // race condition for great justice
|
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 true;
|
||||||
Environment.CurrentDirectory = _currentDirectory; // thats 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 true;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
private string CoolGetCurrentDirectory()
|
private string CoolGetCurrentDirectory()
|
||||||
{
|
{
|
||||||
if (OSTailoredCode.CurrentOS == OSTailoredCode.DistinctOS.Windows)
|
if (OSTailoredCode.IsWindows())
|
||||||
{
|
{
|
||||||
// GUESS WHAT!
|
// GUESS WHAT!
|
||||||
// .NET DOES A SECURITY CHECK ON THE DIRECTORY WE JUST RETRIEVED
|
// .NET DOES A SECURITY CHECK ON THE DIRECTORY WE JUST RETRIEVED
|
||||||
|
@ -76,10 +72,8 @@ namespace BizHawk.Client.Common
|
||||||
fixed (byte* pBuf = &buf[0])
|
fixed (byte* pBuf = &buf[0])
|
||||||
return System.Text.Encoding.Unicode.GetString(buf, 0, 2 * (int) GetCurrentDirectoryW(32767, pBuf));
|
return System.Text.Encoding.Unicode.GetString(buf, 0, 2 * (int) GetCurrentDirectoryW(32767, pBuf));
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
return Environment.CurrentDirectory;
|
||||||
return Environment.CurrentDirectory;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void Sandbox(Action callback, Action exceptionCallback)
|
private void Sandbox(Action callback, Action exceptionCallback)
|
||||||
|
|
|
@ -86,7 +86,7 @@ namespace BizHawk.Client.EmuHawk
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
_ffmpeg = OSTailoredCode.ConstructSubshell(
|
_ffmpeg = OSTailoredCode.ConstructSubshell(
|
||||||
OSTailoredCode.CurrentOS == OSTailoredCode.DistinctOS.Windows
|
OSTailoredCode.IsWindows()
|
||||||
? Path.Combine(PathManager.GetDllDirectory(), "ffmpeg.exe")
|
? Path.Combine(PathManager.GetDllDirectory(), "ffmpeg.exe")
|
||||||
: "ffmpeg",
|
: "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}\"",
|
||||||
|
|
|
@ -83,7 +83,7 @@ namespace BizHawk.Client.EmuHawk
|
||||||
SetStyle(ControlStyles.Opaque, true);
|
SetStyle(ControlStyles.Opaque, true);
|
||||||
SetStyle(ControlStyles.OptimizedDoubleBuffer, true);
|
SetStyle(ControlStyles.OptimizedDoubleBuffer, true);
|
||||||
|
|
||||||
if (OSTailoredCode.CurrentOS == OSTailoredCode.DistinctOS.Windows)
|
if (OSTailoredCode.IsWindows())
|
||||||
{
|
{
|
||||||
_renderer = new GdiRenderer();
|
_renderer = new GdiRenderer();
|
||||||
}
|
}
|
||||||
|
|
|
@ -128,7 +128,7 @@ namespace BizHawk.Client.EmuHawk
|
||||||
|
|
||||||
public static void Initialize()
|
public static void Initialize()
|
||||||
{
|
{
|
||||||
if (OSTailoredCode.CurrentOS == OSTailoredCode.DistinctOS.Windows)
|
if (OSTailoredCode.IsWindows())
|
||||||
{
|
{
|
||||||
KeyInput.Initialize();
|
KeyInput.Initialize();
|
||||||
IPCKeyInput.Initialize();
|
IPCKeyInput.Initialize();
|
||||||
|
@ -145,7 +145,7 @@ namespace BizHawk.Client.EmuHawk
|
||||||
|
|
||||||
public static void Cleanup()
|
public static void Cleanup()
|
||||||
{
|
{
|
||||||
if (OSTailoredCode.CurrentOS == OSTailoredCode.DistinctOS.Windows)
|
if (OSTailoredCode.IsWindows())
|
||||||
{
|
{
|
||||||
KeyInput.Cleanup();
|
KeyInput.Cleanup();
|
||||||
GamePad.Cleanup();
|
GamePad.Cleanup();
|
||||||
|
@ -339,10 +339,10 @@ namespace BizHawk.Client.EmuHawk
|
||||||
{
|
{
|
||||||
while (true)
|
while (true)
|
||||||
{
|
{
|
||||||
var keyEvents = OSTailoredCode.CurrentOS == OSTailoredCode.DistinctOS.Windows
|
var keyEvents = OSTailoredCode.IsWindows()
|
||||||
? KeyInput.Update().Concat(IPCKeyInput.Update())
|
? KeyInput.Update().Concat(IPCKeyInput.Update())
|
||||||
: OTK_Keyboard.Update();
|
: OTK_Keyboard.Update();
|
||||||
if (OSTailoredCode.CurrentOS == OSTailoredCode.DistinctOS.Windows)
|
if (OSTailoredCode.IsWindows())
|
||||||
{
|
{
|
||||||
GamePad.UpdateAll();
|
GamePad.UpdateAll();
|
||||||
GamePad360.UpdateAll();
|
GamePad360.UpdateAll();
|
||||||
|
|
|
@ -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.CurrentOS != OSTailoredCode.DistinctOS.Windows)
|
if (!OSTailoredCode.IsWindows())
|
||||||
{
|
{
|
||||||
// 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,11 +165,13 @@ 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.CurrentOS == OSTailoredCode.DistinctOS.Windows
|
CGC.CGCBinPath = OSTailoredCode.IsWindows()
|
||||||
? Path.Combine(PathManager.GetDllDirectory(), "cgc.exe")
|
? Path.Combine(PathManager.GetDllDirectory(), "cgc.exe")
|
||||||
: "cgc"; // installed separately (via package manager or from https://developer.nvidia.com/cg-toolkit-download), look in $PATH
|
: "cgc"; // installed separately (via package manager or from https://developer.nvidia.com/cg-toolkit-download), look in $PATH
|
||||||
PresentationPanel = new PresentationPanel();
|
PresentationPanel = new PresentationPanel
|
||||||
PresentationPanel.GraphicsControl.MainWindow = true;
|
{
|
||||||
|
GraphicsControl = {MainWindow = true}
|
||||||
|
};
|
||||||
GlobalWin.DisplayManager = new DisplayManager(PresentationPanel);
|
GlobalWin.DisplayManager = new DisplayManager(PresentationPanel);
|
||||||
Controls.Add(PresentationPanel);
|
Controls.Add(PresentationPanel);
|
||||||
Controls.SetChildIndex(PresentationPanel, 0);
|
Controls.SetChildIndex(PresentationPanel, 0);
|
||||||
|
@ -1047,7 +1049,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.CurrentOS == OSTailoredCode.DistinctOS.Windows
|
if (OSTailoredCode.IsWindows()
|
||||||
&& Global.Config.DispFullscreenHacks
|
&& Global.Config.DispFullscreenHacks
|
||||||
&& Global.Config.DispMethod == Config.EDispMethod.OpenGL)
|
&& Global.Config.DispMethod == Config.EDispMethod.OpenGL)
|
||||||
{
|
{
|
||||||
|
@ -1076,7 +1078,7 @@ namespace BizHawk.Client.EmuHawk
|
||||||
|
|
||||||
WindowState = FormWindowState.Normal;
|
WindowState = FormWindowState.Normal;
|
||||||
|
|
||||||
if (OSTailoredCode.CurrentOS == OSTailoredCode.DistinctOS.Windows)
|
if (OSTailoredCode.IsWindows())
|
||||||
{
|
{
|
||||||
// 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,7 @@ namespace BizHawk.Client.EmuHawk
|
||||||
Application.EnableVisualStyles();
|
Application.EnableVisualStyles();
|
||||||
Application.SetCompatibleTextRenderingDefault(false);
|
Application.SetCompatibleTextRenderingDefault(false);
|
||||||
|
|
||||||
if (EXE_PROJECT.OSTailoredCode.CurrentOS == EXE_PROJECT.OSTailoredCode.DistinctOS.Windows)
|
if (EXE_PROJECT.OSTailoredCode.IsWindows())
|
||||||
{
|
{
|
||||||
var libLoader = EXE_PROJECT.OSTailoredCode.LinkedLibManager;
|
var libLoader = EXE_PROJECT.OSTailoredCode.LinkedLibManager;
|
||||||
|
|
||||||
|
@ -78,7 +78,7 @@ namespace BizHawk.Client.EmuHawk
|
||||||
private static int Main(string[] args)
|
private static int Main(string[] args)
|
||||||
{
|
{
|
||||||
var exitCode = SubMain(args);
|
var exitCode = SubMain(args);
|
||||||
if (EXE_PROJECT.OSTailoredCode.CurrentOS == EXE_PROJECT.OSTailoredCode.DistinctOS.Linux)
|
if (EXE_PROJECT.OSTailoredCode.IsLinux())
|
||||||
{
|
{
|
||||||
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();
|
||||||
|
@ -94,7 +94,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.CurrentOS == EXE_PROJECT.OSTailoredCode.DistinctOS.Windows)
|
if (!VersionInfo.DeveloperBuild && EXE_PROJECT.OSTailoredCode.IsWindows())
|
||||||
{
|
{
|
||||||
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;
|
||||||
|
@ -145,7 +145,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.CurrentOS != EXE_PROJECT.OSTailoredCode.DistinctOS.Windows)
|
if (!EXE_PROJECT.OSTailoredCode.IsWindows())
|
||||||
Global.Config.DispMethod = Config.EDispMethod.GdiPlus;
|
Global.Config.DispMethod = Config.EDispMethod.GdiPlus;
|
||||||
|
|
||||||
REDO_DISPMETHOD:
|
REDO_DISPMETHOD:
|
||||||
|
@ -193,7 +193,7 @@ REDO_DISPMETHOD:
|
||||||
goto REDO_DISPMETHOD;
|
goto REDO_DISPMETHOD;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (EXE_PROJECT.OSTailoredCode.CurrentOS == EXE_PROJECT.OSTailoredCode.DistinctOS.Windows)
|
if (EXE_PROJECT.OSTailoredCode.IsWindows())
|
||||||
{
|
{
|
||||||
//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".
|
||||||
|
@ -314,7 +314,7 @@ REDO_DISPMETHOD:
|
||||||
//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.CurrentOS == EXE_PROJECT.OSTailoredCode.DistinctOS.Windows // LuaInterface is not currently working on Mono
|
if (EXE_PROJECT.OSTailoredCode.IsWindows() // 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,7 +45,7 @@ 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.CurrentOS == OSTailoredCode.DistinctOS.Windows
|
private static readonly IScreenBlankTimer _screenBlankTimer = OSTailoredCode.IsWindows()
|
||||||
? (IScreenBlankTimer) new Win32ScreenBlankTimer()
|
? (IScreenBlankTimer) new Win32ScreenBlankTimer()
|
||||||
: new UnixScreenBlankTimer();
|
: new UnixScreenBlankTimer();
|
||||||
|
|
||||||
|
|
|
@ -23,7 +23,7 @@ namespace BizHawk.Client.EmuHawk
|
||||||
|
|
||||||
public Sound(IntPtr mainWindowHandle)
|
public Sound(IntPtr mainWindowHandle)
|
||||||
{
|
{
|
||||||
if (OSTailoredCode.CurrentOS == OSTailoredCode.DistinctOS.Windows)
|
if (OSTailoredCode.IsWindows())
|
||||||
{
|
{
|
||||||
if (Global.Config.SoundOutputMethod == Config.ESoundOutputMethod.OpenAL)
|
if (Global.Config.SoundOutputMethod == Config.ESoundOutputMethod.OpenAL)
|
||||||
_outputDevice = new OpenALSoundOutput(this);
|
_outputDevice = new OpenALSoundOutput(this);
|
||||||
|
|
|
@ -160,7 +160,7 @@ namespace BizHawk.Client.EmuHawk
|
||||||
return ms;
|
return ms;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
static PlatformSpecificSysTimer sysTimer = OSTailoredCode.CurrentOS == OSTailoredCode.DistinctOS.Windows
|
static readonly PlatformSpecificSysTimer sysTimer = OSTailoredCode.IsWindows()
|
||||||
? (PlatformSpecificSysTimer) new WinSysTimer()
|
? (PlatformSpecificSysTimer) new WinSysTimer()
|
||||||
: new UnixMonoSysTimer();
|
: new UnixMonoSysTimer();
|
||||||
static uint TimeBeginPeriod(uint ms)
|
static uint TimeBeginPeriod(uint ms)
|
||||||
|
|
|
@ -93,7 +93,7 @@ namespace BizHawk.Client.EmuHawk
|
||||||
|
|
||||||
RefreshAspectRatioOptions();
|
RefreshAspectRatioOptions();
|
||||||
|
|
||||||
if (OSTailoredCode.CurrentOS != OSTailoredCode.DistinctOS.Windows)
|
if (!OSTailoredCode.IsWindows())
|
||||||
{
|
{
|
||||||
// Disable SlimDX on Unix
|
// Disable SlimDX on Unix
|
||||||
rbD3D9.Enabled = false;
|
rbD3D9.Enabled = false;
|
||||||
|
|
|
@ -356,15 +356,18 @@ namespace BizHawk.Client.EmuHawk
|
||||||
DoScan();
|
DoScan();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void tbbOpenFolder_Click(object sender, EventArgs e)
|
private void tbbOpenFolder_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
var frmWares = PathManager.MakeAbsolutePath(Global.Config.PathEntries.FirmwaresPathFragment, null);
|
var frmWares = PathManager.MakeAbsolutePath(Global.Config.PathEntries.FirmwaresPathFragment, null);
|
||||||
if (OSTailoredCode.CurrentOS != OSTailoredCode.DistinctOS.Windows && !Directory.Exists(frmWares))
|
if (!OSTailoredCode.IsWindows() && !Directory.Exists(frmWares))
|
||||||
|
{
|
||||||
Directory.CreateDirectory(frmWares);
|
Directory.CreateDirectory(frmWares);
|
||||||
System.Diagnostics.Process.Start(frmWares);
|
}
|
||||||
}
|
|
||||||
|
|
||||||
private void lvFirmwares_KeyDown(object sender, KeyEventArgs e)
|
System.Diagnostics.Process.Start(frmWares);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void lvFirmwares_KeyDown(object sender, KeyEventArgs e)
|
||||||
{
|
{
|
||||||
if (e.KeyCode == Keys.C && e.Control && !e.Alt && !e.Shift)
|
if (e.KeyCode == Keys.C && e.Control && !e.Alt && !e.Shift)
|
||||||
{
|
{
|
||||||
|
|
|
@ -67,7 +67,11 @@ namespace BizHawk.Client.EmuHawk
|
||||||
|
|
||||||
protected override void OnMouseClick(MouseEventArgs e)
|
protected override void OnMouseClick(MouseEventArgs e)
|
||||||
{
|
{
|
||||||
if (OSTailoredCode.CurrentOS == OSTailoredCode.DistinctOS.Windows) HideCaret(Handle);
|
if (OSTailoredCode.IsWindows())
|
||||||
|
{
|
||||||
|
HideCaret(Handle);
|
||||||
|
}
|
||||||
|
|
||||||
base.OnMouseClick(e);
|
base.OnMouseClick(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -259,7 +263,10 @@ namespace BizHawk.Client.EmuHawk
|
||||||
|
|
||||||
protected override void OnGotFocus(EventArgs e)
|
protected override void OnGotFocus(EventArgs e)
|
||||||
{
|
{
|
||||||
if (OSTailoredCode.CurrentOS == OSTailoredCode.DistinctOS.Windows) HideCaret(Handle);
|
if (OSTailoredCode.IsWindows())
|
||||||
|
{
|
||||||
|
HideCaret(Handle);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override bool ProcessCmdKey(ref Message msg, Keys keyData)
|
protected override bool ProcessCmdKey(ref Message msg, Keys keyData)
|
||||||
|
|
|
@ -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.CurrentOS != OSTailoredCode.DistinctOS.Windows)
|
if (!OSTailoredCode.IsWindows())
|
||||||
{
|
{
|
||||||
// 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.CurrentOS == OSTailoredCode.DistinctOS.Windows)
|
if (OSTailoredCode.IsWindows())
|
||||||
{
|
{
|
||||||
if (rbOutputMethodDirectSound.Checked) deviceNames = DirectSoundSoundOutput.GetDeviceNames();
|
if (rbOutputMethodDirectSound.Checked) deviceNames = DirectSoundSoundOutput.GetDeviceNames();
|
||||||
if (rbOutputMethodXAudio2.Checked) deviceNames = XAudio2SoundOutput.GetDeviceNames();
|
if (rbOutputMethodXAudio2.Checked) deviceNames = XAudio2SoundOutput.GetDeviceNames();
|
||||||
|
|
|
@ -185,7 +185,7 @@ namespace BizHawk.Client.EmuHawk
|
||||||
}
|
}
|
||||||
|
|
||||||
var currentScripts = LuaImp?.ScriptList; // Temp fix for now
|
var currentScripts = LuaImp?.ScriptList; // Temp fix for now
|
||||||
LuaImp = OSTailoredCode.CurrentOS == OSTailoredCode.DistinctOS.Windows
|
LuaImp = OSTailoredCode.IsWindows()
|
||||||
? (PlatformEmuLuaLibrary)new EmuLuaLibrary(Emulator.ServiceProvider)
|
? (PlatformEmuLuaLibrary)new EmuLuaLibrary(Emulator.ServiceProvider)
|
||||||
: (PlatformEmuLuaLibrary)new NotReallyLuaLibrary();
|
: (PlatformEmuLuaLibrary)new NotReallyLuaLibrary();
|
||||||
if (currentScripts != null)
|
if (currentScripts != null)
|
||||||
|
|
|
@ -268,7 +268,7 @@ 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.CurrentOS == OSTailoredCode.DistinctOS.Windows)
|
if (OSTailoredCode.IsWindows())
|
||||||
{
|
{
|
||||||
Win32.FileAttributes fromAttr = GetPathAttribute(fromPath);
|
Win32.FileAttributes fromAttr = GetPathAttribute(fromPath);
|
||||||
Win32.FileAttributes toAttr = GetPathAttribute(toPath);
|
Win32.FileAttributes toAttr = GetPathAttribute(toPath);
|
||||||
|
|
|
@ -157,8 +157,7 @@ namespace BizHawk.Client.EmuHawk
|
||||||
}
|
}
|
||||||
|
|
||||||
newTool.Restart();
|
newTool.Restart();
|
||||||
if (OSTailoredCode.CurrentOS != OSTailoredCode.DistinctOS.Windows
|
if (!OSTailoredCode.IsWindows() && newTool is RamSearch)
|
||||||
&& 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
|
||||||
}
|
}
|
||||||
|
@ -750,7 +749,7 @@ namespace BizHawk.Client.EmuHawk
|
||||||
{
|
{
|
||||||
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.CurrentOS != OSTailoredCode.DistinctOS.Windows)) // simply doesn't work (for now)
|
|| (tool == typeof(LuaConsole) && !OSTailoredCode.IsWindows())) // simply doesn't work (for now)
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -76,7 +76,7 @@ namespace BizHawk.Common.BizInvoke
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public MemoryBlock(ulong start, ulong size)
|
public MemoryBlock(ulong start, ulong size)
|
||||||
{
|
{
|
||||||
if (OSTailoredCode.CurrentOS != OSTailoredCode.DistinctOS.Windows)
|
if (!OSTailoredCode.IsWindows())
|
||||||
throw new InvalidOperationException("MemoryBlock ctor called on Unix");
|
throw new InvalidOperationException("MemoryBlock ctor called on Unix");
|
||||||
|
|
||||||
if (!WaterboxUtils.Aligned(start))
|
if (!WaterboxUtils.Aligned(start))
|
||||||
|
|
|
@ -10,11 +10,23 @@ namespace BizHawk.Common
|
||||||
{
|
{
|
||||||
public static class OSTailoredCode
|
public static class OSTailoredCode
|
||||||
{
|
{
|
||||||
/// <remarks>macOS doesn't use <see cref="PlatformID.MacOSX">PlatformID.MacOSX</see></remarks>
|
/// <remarks>
|
||||||
|
/// macOS doesn't use <see cref="PlatformID.MacOSX">PlatformID.MacOSX</see>
|
||||||
|
/// </remarks>
|
||||||
public static readonly DistinctOS CurrentOS = Environment.OSVersion.Platform == PlatformID.Unix
|
public static readonly DistinctOS CurrentOS = Environment.OSVersion.Platform == PlatformID.Unix
|
||||||
? 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()
|
||||||
|
{
|
||||||
|
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>(() =>
|
||||||
{
|
{
|
||||||
switch (CurrentOS)
|
switch (CurrentOS)
|
||||||
|
@ -141,13 +153,11 @@ namespace BizHawk.Common
|
||||||
/// <remarks>OS is implicit and needs to be checked at callsite</remarks>
|
/// <remarks>OS is implicit and needs to be checked at callsite</remarks>
|
||||||
public static string SimpleSubshell(string cmd, string args, string noOutputMsg)
|
public static string SimpleSubshell(string cmd, string args, string noOutputMsg)
|
||||||
{
|
{
|
||||||
using (var proc = ConstructSubshell(cmd, args))
|
using var proc = ConstructSubshell(cmd, args);
|
||||||
{
|
proc.Start();
|
||||||
proc.Start();
|
var stdout = proc.StandardOutput;
|
||||||
var stdout = proc.StandardOutput;
|
if (stdout.EndOfStream) throw new Exception($"{noOutputMsg} ({cmd} wrote nothing to stdout)");
|
||||||
if (stdout.EndOfStream) throw new Exception($"{noOutputMsg} ({cmd} wrote nothing to stdout)");
|
return stdout.ReadLine();
|
||||||
return stdout.ReadLine();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -86,16 +86,21 @@ namespace BizHawk.Common
|
||||||
catch
|
catch
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
if(fis != null)
|
if(fis != null)
|
||||||
{
|
{
|
||||||
foreach (var fi in fis)
|
foreach (var fi in fis)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
if (OSTailoredCode.CurrentOS == OSTailoredCode.DistinctOS.Windows)
|
if (OSTailoredCode.IsWindows())
|
||||||
|
{
|
||||||
DeleteFileW(fi.FullName); // SHUT. UP. THE. EXCEPTIONS.
|
DeleteFileW(fi.FullName); // SHUT. UP. THE. EXCEPTIONS.
|
||||||
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
fi.Delete();
|
fi.Delete();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
catch
|
catch
|
||||||
{
|
{
|
||||||
|
@ -107,7 +112,7 @@ namespace BizHawk.Common
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// try not to slam the filesystem too hard, we dont want this to cause any hiccups
|
// try not to slam the filesystem too hard, we don't want this to cause any hiccups
|
||||||
Thread.Sleep(5000);
|
Thread.Sleep(5000);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -211,6 +211,7 @@
|
||||||
<s:Boolean x:Key="/Default/UserDictionary/Words/=Fairchild/@EntryIndexedValue">True</s:Boolean>
|
<s:Boolean x:Key="/Default/UserDictionary/Words/=Fairchild/@EntryIndexedValue">True</s:Boolean>
|
||||||
<s:Boolean x:Key="/Default/UserDictionary/Words/=Famtasia/@EntryIndexedValue">True</s:Boolean>
|
<s:Boolean x:Key="/Default/UserDictionary/Words/=Famtasia/@EntryIndexedValue">True</s:Boolean>
|
||||||
<s:Boolean x:Key="/Default/UserDictionary/Words/=FCEU/@EntryIndexedValue">True</s:Boolean>
|
<s:Boolean x:Key="/Default/UserDictionary/Words/=FCEU/@EntryIndexedValue">True</s:Boolean>
|
||||||
|
<s:Boolean x:Key="/Default/UserDictionary/Words/=ffmpeg/@EntryIndexedValue">True</s:Boolean>
|
||||||
<s:Boolean x:Key="/Default/UserDictionary/Words/=frameadvance/@EntryIndexedValue">True</s:Boolean>
|
<s:Boolean x:Key="/Default/UserDictionary/Words/=frameadvance/@EntryIndexedValue">True</s:Boolean>
|
||||||
<s:Boolean x:Key="/Default/UserDictionary/Words/=FCEUX/@EntryIndexedValue">True</s:Boolean>
|
<s:Boolean x:Key="/Default/UserDictionary/Words/=FCEUX/@EntryIndexedValue">True</s:Boolean>
|
||||||
<s:Boolean x:Key="/Default/UserDictionary/Words/=feos/@EntryIndexedValue">True</s:Boolean>
|
<s:Boolean x:Key="/Default/UserDictionary/Words/=feos/@EntryIndexedValue">True</s:Boolean>
|
||||||
|
@ -274,6 +275,7 @@
|
||||||
<s:Boolean x:Key="/Default/UserDictionary/Words/=Statable/@EntryIndexedValue">True</s:Boolean>
|
<s:Boolean x:Key="/Default/UserDictionary/Words/=Statable/@EntryIndexedValue">True</s:Boolean>
|
||||||
<s:Boolean x:Key="/Default/UserDictionary/Words/=Stateable/@EntryIndexedValue">True</s:Boolean>
|
<s:Boolean x:Key="/Default/UserDictionary/Words/=Stateable/@EntryIndexedValue">True</s:Boolean>
|
||||||
<s:Boolean x:Key="/Default/UserDictionary/Words/=subframe/@EntryIndexedValue">True</s:Boolean>
|
<s:Boolean x:Key="/Default/UserDictionary/Words/=subframe/@EntryIndexedValue">True</s:Boolean>
|
||||||
|
<s:Boolean x:Key="/Default/UserDictionary/Words/=Subshell/@EntryIndexedValue">True</s:Boolean>
|
||||||
<s:Boolean x:Key="/Default/UserDictionary/Words/=Syncless/@EntryIndexedValue">True</s:Boolean>
|
<s:Boolean x:Key="/Default/UserDictionary/Words/=Syncless/@EntryIndexedValue">True</s:Boolean>
|
||||||
<s:Boolean x:Key="/Default/UserDictionary/Words/=taseditor/@EntryIndexedValue">True</s:Boolean>
|
<s:Boolean x:Key="/Default/UserDictionary/Words/=taseditor/@EntryIndexedValue">True</s:Boolean>
|
||||||
<s:Boolean x:Key="/Default/UserDictionary/Words/=tasproj/@EntryIndexedValue">True</s:Boolean>
|
<s:Boolean x:Key="/Default/UserDictionary/Words/=tasproj/@EntryIndexedValue">True</s:Boolean>
|
||||||
|
|
Loading…
Reference in New Issue