60 lines
2.5 KiB
C#
60 lines
2.5 KiB
C#
using System;
|
|
using System.Runtime.InteropServices;
|
|
|
|
namespace LayersShell;
|
|
|
|
internal static class LayersNative
|
|
{
|
|
private const string Dll = "layers_native";
|
|
|
|
private static bool _startedUp;
|
|
public static void StartupIfNeeded()
|
|
{
|
|
if (_startedUp) return;
|
|
_startedUp = true;
|
|
_ = layers_startup();
|
|
}
|
|
|
|
[DllImport(Dll, CallingConvention = CallingConvention.Cdecl)]
|
|
public static extern int layers_startup();
|
|
|
|
[DllImport(Dll, CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)]
|
|
public static extern void layers_set_plugin_root([MarshalAs(UnmanagedType.LPStr)] string path);
|
|
|
|
[DllImport(Dll, CallingConvention = CallingConvention.Cdecl)]
|
|
public static extern IntPtr layers_create_from_swap_chain_panel(IntPtr swapChainPanel, float width, float height, float scale);
|
|
|
|
[DllImport(Dll, CallingConvention = CallingConvention.Cdecl)]
|
|
public static extern void layers_destroy(IntPtr handle);
|
|
|
|
[DllImport(Dll, CallingConvention = CallingConvention.Cdecl)]
|
|
public static extern void layers_render(IntPtr handle);
|
|
|
|
[DllImport(Dll, CallingConvention = CallingConvention.Cdecl)]
|
|
public static extern void layers_resize(IntPtr handle, float width, float height, float scale);
|
|
|
|
[DllImport(Dll, CallingConvention = CallingConvention.Cdecl)]
|
|
public static extern void layers_mouse_move(IntPtr handle, float x, float y);
|
|
|
|
[DllImport(Dll, CallingConvention = CallingConvention.Cdecl)]
|
|
public static extern void layers_mouse_left(IntPtr handle);
|
|
|
|
[DllImport(Dll, CallingConvention = CallingConvention.Cdecl)]
|
|
public static extern void layers_mouse_button(IntPtr handle, float x, float y, uint button, [MarshalAs(UnmanagedType.I1)] bool pressed);
|
|
|
|
[DllImport(Dll, CallingConvention = CallingConvention.Cdecl)]
|
|
public static extern void layers_mouse_scroll(IntPtr handle, float x, float y, float dx, float dy);
|
|
|
|
[DllImport(Dll, CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)]
|
|
public static extern void layers_key_event(IntPtr handle, uint named, [MarshalAs(UnmanagedType.LPStr)] string? utf8, uint mods, ushort nativeKeycode, [MarshalAs(UnmanagedType.I1)] bool pressed);
|
|
}
|
|
|
|
[System.Runtime.InteropServices.ComImport]
|
|
[System.Runtime.InteropServices.Guid("63aad0b8-7c24-40ff-85a8-640d944cc325")]
|
|
[System.Runtime.InteropServices.InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
|
|
public interface ISwapChainPanelNative
|
|
{
|
|
[PreserveSig]
|
|
int SetSwapChain(IntPtr swapChain);
|
|
}
|