2019-02-12 22:13:09 -05:00
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.IO;
|
|
|
|
|
using System.IO.Compression;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Runtime.InteropServices;
|
|
|
|
|
using System.Text;
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
using System.Windows.Forms;
|
|
|
|
|
using Mesen.GUI.Config;
|
|
|
|
|
using Mesen.GUI.Forms;
|
|
|
|
|
|
|
|
|
|
namespace Mesen.GUI
|
|
|
|
|
{
|
|
|
|
|
public class EmuApi
|
|
|
|
|
{
|
|
|
|
|
private const string DllPath = "MesenSCore.dll";
|
|
|
|
|
[DllImport(DllPath)] [return: MarshalAs(UnmanagedType.I1)] public static extern bool TestDll();
|
|
|
|
|
[DllImport(DllPath)] public static extern void InitDll();
|
|
|
|
|
|
|
|
|
|
[DllImport(DllPath, EntryPoint = "GetMesenVersion")] private static extern UInt32 GetMesenVersionWrapper();
|
|
|
|
|
|
2019-02-15 21:33:13 -05:00
|
|
|
|
[DllImport(DllPath)] public static extern IntPtr RegisterNotificationCallback(NotificationListener.NotificationCallback callback);
|
|
|
|
|
[DllImport(DllPath)] public static extern void UnregisterNotificationCallback(IntPtr notificationListener);
|
|
|
|
|
|
2019-02-12 22:13:09 -05:00
|
|
|
|
[DllImport(DllPath)] public static extern void InitializeEmu([MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(Utf8Marshaler))]string homeFolder, IntPtr windowHandle, IntPtr dxViewerHandle, [MarshalAs(UnmanagedType.I1)]bool noAudio, [MarshalAs(UnmanagedType.I1)]bool noVideo, [MarshalAs(UnmanagedType.I1)]bool noInput);
|
|
|
|
|
[DllImport(DllPath)] public static extern void Release();
|
|
|
|
|
|
|
|
|
|
[DllImport(DllPath)] public static extern void Run();
|
2019-02-16 01:22:31 -05:00
|
|
|
|
[DllImport(DllPath)] public static extern void Stop();
|
2019-02-12 22:13:09 -05:00
|
|
|
|
|
2019-03-11 17:56:54 -04:00
|
|
|
|
[DllImport(DllPath)] public static extern void TakeScreenshot();
|
|
|
|
|
|
2019-02-12 22:13:09 -05:00
|
|
|
|
[DllImport(DllPath)] public static extern void LoadRom(
|
|
|
|
|
[MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(Utf8Marshaler))]string filepath,
|
|
|
|
|
[MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(Utf8Marshaler))]string patchFile = ""
|
|
|
|
|
);
|
|
|
|
|
|
2019-03-11 17:56:54 -04:00
|
|
|
|
[DllImport(DllPath)] public static extern void AddKnownGameFolder([MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(Utf8Marshaler))]string folder);
|
|
|
|
|
|
|
|
|
|
[DllImport(DllPath)] public static extern void SetFolderOverrides(
|
|
|
|
|
[MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(Utf8Marshaler))]string saveDataFolder,
|
|
|
|
|
[MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(Utf8Marshaler))]string saveStateFolder,
|
|
|
|
|
[MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(Utf8Marshaler))]string screenshotFolder
|
|
|
|
|
);
|
2019-02-12 22:13:09 -05:00
|
|
|
|
|
|
|
|
|
[DllImport(DllPath)] public static extern void SetDisplayLanguage(Language lang);
|
2019-02-17 14:42:35 -05:00
|
|
|
|
|
2019-03-10 11:12:50 -04:00
|
|
|
|
[DllImport(DllPath)] public static extern ScreenSize GetScreenSize([MarshalAs(UnmanagedType.I1)]bool ignoreScale);
|
|
|
|
|
|
2019-02-17 14:42:35 -05:00
|
|
|
|
[DllImport(DllPath, EntryPoint = "GetLog")] private static extern IntPtr GetLogWrapper();
|
|
|
|
|
public static string GetLog() { return Utf8Marshaler.PtrToStringUtf8(EmuApi.GetLogWrapper()).Replace("\n", Environment.NewLine); }
|
2019-03-11 17:56:54 -04:00
|
|
|
|
[DllImport(DllPath)] public static extern void WriteLogEntry([MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(Utf8Marshaler))]string message);
|
|
|
|
|
[DllImport(DllPath)] public static extern void DisplayMessage([MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(Utf8Marshaler))]string title, [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(Utf8Marshaler))]string message, [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(Utf8Marshaler))]string param1 = null);
|
2019-03-10 23:45:56 -04:00
|
|
|
|
|
|
|
|
|
[DllImport(DllPath)] public static extern IntPtr GetArchiveRomList([MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(Utf8Marshaler))]string filename);
|
2019-02-12 22:13:09 -05:00
|
|
|
|
}
|
2019-03-10 11:12:50 -04:00
|
|
|
|
|
|
|
|
|
public struct ScreenSize
|
|
|
|
|
{
|
|
|
|
|
public Int32 Width;
|
|
|
|
|
public Int32 Height;
|
|
|
|
|
public double Scale;
|
|
|
|
|
}
|
2019-02-12 22:13:09 -05:00
|
|
|
|
}
|