From f3d13fe6dc7759d611f04bedc498624a535448ca Mon Sep 17 00:00:00 2001 From: Susko3 Date: Sat, 6 Apr 2024 14:12:44 +0200 Subject: [PATCH] Add C# type-friendly properties/getters to some structs --- SDL3-CS/SDL3/SDL_events.cs | 37 ++++++++++++++++++++++++++++++++++++ SDL3-CS/SDL3/SDL_keyboard.cs | 5 +++++ 2 files changed, 42 insertions(+) create mode 100644 SDL3-CS/SDL3/SDL_events.cs diff --git a/SDL3-CS/SDL3/SDL_events.cs b/SDL3-CS/SDL3/SDL_events.cs new file mode 100644 index 0000000..fc8a7cd --- /dev/null +++ b/SDL3-CS/SDL3/SDL_events.cs @@ -0,0 +1,37 @@ +// Copyright (c) ppy Pty Ltd . 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; + } +} diff --git a/SDL3-CS/SDL3/SDL_keyboard.cs b/SDL3-CS/SDL3/SDL_keyboard.cs index 1082027..885fbc9 100644 --- a/SDL3-CS/SDL3/SDL_keyboard.cs +++ b/SDL3-CS/SDL3/SDL_keyboard.cs @@ -7,4 +7,9 @@ namespace SDL { [Typedef] public enum SDL_KeyboardID : UInt32; + + public partial struct SDL_Keysym + { + public SDL_Keymod Mod => (SDL_Keymod)mod; + } }