Add C# type-friendly properties/getters to some structs

This commit is contained in:
Susko3 2024-04-06 14:12:44 +02:00
parent 711e004ecd
commit 9a5d2e4dbc
2 changed files with 42 additions and 0 deletions

View File

@ -0,0 +1,37 @@
// 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.
namespace SDL
{
public unsafe partial struct SDL_TextInputEvent
{
public string? GetText() => SDL3.PtrToStringUTF8(text);
}
public unsafe partial struct SDL_TextEditingEvent
{
public string? GetText() => SDL3.PtrToStringUTF8(text);
}
public unsafe partial struct SDL_DropEvent
{
public string? GetSource() => SDL3.PtrToStringUTF8(source);
public string? GetData() => SDL3.PtrToStringUTF8(data);
}
public partial struct SDL_MouseButtonEvent
{
public SDLButton Button => (SDLButton)button;
}
public partial struct SDL_GamepadAxisEvent
{
public SDL_GamepadAxis Axis => (SDL_GamepadAxis)axis;
}
public partial struct SDL_GamepadButtonEvent
{
public SDL_GamepadButton Button => (SDL_GamepadButton)button;
}
}

View File

@ -7,4 +7,9 @@ namespace SDL
{
[Typedef]
public enum SDL_KeyboardID : UInt32;
public partial struct SDL_Keysym
{
public SDL_Keymod Mod => (SDL_Keymod)mod;
}
}