Add custom definition for win32 MSG struct

The win32 types are kinda cursed, but it makes it easy to copy&paste and check.
This commit is contained in:
Susko3 2024-04-06 01:42:45 +02:00
parent ba561098e7
commit 52d13f2972
3 changed files with 45 additions and 5 deletions

View File

@ -28,10 +28,6 @@ using System.Runtime.Versioning;
namespace SDL
{
public partial struct tagMSG
{
}
public partial struct XTaskQueueObject
{
}
@ -44,7 +40,7 @@ namespace SDL
{
[DllImport("SDL3", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
[SupportedOSPlatform("Windows")]
public static extern void SDL_SetWindowsMessageHook([NativeTypeName("SDL_WindowsMessageHook")] delegate* unmanaged[Cdecl]<void*, tagMSG*, int> callback, void* userdata);
public static extern void SDL_SetWindowsMessageHook([NativeTypeName("SDL_WindowsMessageHook")] delegate* unmanaged[Cdecl]<void*, MSG*, int> callback, void* userdata);
[DllImport("SDL3", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
[SupportedOSPlatform("Windows")]

View File

@ -0,0 +1,34 @@
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.
using System;
namespace SDL
{
// https://learn.microsoft.com/en-us/dotnet/standard/native-interop/best-practices#common-windows-data-types
using LONG = int;
using DWORD = uint;
using UINT = uint;
using HWND = IntPtr;
using WPARAM = UIntPtr;
using LPARAM = IntPtr;
// https://learn.microsoft.com/en-us/windows/win32/api/windef/ns-windef-point
public struct POINT
{
public LONG x;
public LONG y;
}
// https://learn.microsoft.com/en-us/windows/win32/api/winuser/ns-winuser-msg
public struct MSG
{
public HWND hwnd;
public UINT message;
public WPARAM wParam;
public LPARAM lParam;
public DWORD time;
public POINT pt;
public DWORD lPrivate;
}
}

View File

@ -0,0 +1,10 @@
# Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
# See the LICENCE file in the repository root for full licence text.
# Exclude struct forward declaration
--exclude
tagMSG
# ClangSharp recommended remapping
--remap
tagMSG=MSG