diff --git a/osu.Framework.Android/osu.Framework.Android.csproj b/osu.Framework.Android/osu.Framework.Android.csproj index f19e7b3450..968c6888a7 100644 --- a/osu.Framework.Android/osu.Framework.Android.csproj +++ b/osu.Framework.Android/osu.Framework.Android.csproj @@ -18,7 +18,7 @@ - + diff --git a/osu.Framework.iOS/IOSWindow.cs b/osu.Framework.iOS/IOSWindow.cs index 1fc0ca9f89..5444664a88 100644 --- a/osu.Framework.iOS/IOSWindow.cs +++ b/osu.Framework.iOS/IOSWindow.cs @@ -59,7 +59,7 @@ protected override unsafe void RunMainLoop() // frame rate with multi-threaded mode turned on, but it is going to give them worse input latency // and higher power usage. - SDL_SetiOSEventPump(SDL_bool.SDL_FALSE); + SDL_SetiOSEventPump(false); SDL_SetiOSAnimationCallback(SDLWindowHandle, 1, &runFrame, ObjectHandle.Handle); } diff --git a/osu.Framework/Platform/SDL3/SDL3Clipboard.cs b/osu.Framework/Platform/SDL3/SDL3Clipboard.cs index e2d3277b39..1c2b08fdfe 100644 --- a/osu.Framework/Platform/SDL3/SDL3Clipboard.cs +++ b/osu.Framework/Platform/SDL3/SDL3Clipboard.cs @@ -12,7 +12,6 @@ using System.Text; using osu.Framework.Allocation; using osu.Framework.Logging; -using SDL; using SixLabors.ImageSharp; using SixLabors.ImageSharp.Formats; using static SDL.SDL3; @@ -41,7 +40,7 @@ public SDL3Clipboard(IImageFormat imageFormat) // SDL cannot differentiate between string.Empty and no text (eg. empty clipboard or an image) // doesn't matter as text editors don't really allow copying empty strings. // assume that empty text means no text. - public override string? GetText() => SDL_HasClipboardText() == SDL_bool.SDL_TRUE ? SDL_GetClipboardText() : null; + public override string? GetText() => SDL_HasClipboardText() ? SDL_GetClipboardText() : null; public override void SetText(string text) => SDL_SetClipboardText(text); @@ -86,7 +85,7 @@ public override bool SetImage(Image image) private static unsafe bool tryGetData(string mimeType, SpanDecoder decoder, out T? data) { - if (SDL_HasClipboardData(mimeType) == SDL_bool.SDL_FALSE) + if (!SDL_HasClipboardData(mimeType)) { data = default; return false; @@ -128,7 +127,7 @@ private static unsafe bool trySetData(string mimeType, Func // TODO: support multiple mime types in a single callback fixed (byte* ptr = Encoding.UTF8.GetBytes(mimeType + '\0')) { - if (SDL_SetClipboardData(&dataCallback, &cleanupCallback, objectHandle.Handle, &ptr, 1) == SDL_bool.SDL_FALSE) + if (!SDL_SetClipboardData(&dataCallback, &cleanupCallback, objectHandle.Handle, &ptr, 1)) { objectHandle.Dispose(); Logger.Log($"Failed to set clipboard data callback. SDL error: {SDL_GetError()}"); diff --git a/osu.Framework/Platform/SDL3/SDL3DesktopWindow.cs b/osu.Framework/Platform/SDL3/SDL3DesktopWindow.cs index 14fe14c0fe..ca86b8affc 100644 --- a/osu.Framework/Platform/SDL3/SDL3DesktopWindow.cs +++ b/osu.Framework/Platform/SDL3/SDL3DesktopWindow.cs @@ -1,7 +1,6 @@ // Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. // See the LICENCE file in the repository root for full licence text. -using SDL; using static SDL.SDL3; namespace osu.Framework.Platform.SDL3 @@ -18,8 +17,8 @@ protected override unsafe void UpdateWindowStateAndSize(WindowState state, Displ // this reset is required even on changing from one fullscreen resolution to another. // if it is not included, the GL context will not get the correct size. // this is mentioned by multiple sources as an SDL issue, which seems to resolve by similar means (see https://discourse.libsdl.org/t/sdl-setwindowsize-does-not-work-in-fullscreen/20711/4). - SDL_SetWindowBordered(SDLWindowHandle, SDL_bool.SDL_TRUE); - SDL_SetWindowFullscreen(SDLWindowHandle, SDL_bool.SDL_FALSE); + SDL_SetWindowBordered(SDLWindowHandle, true); + SDL_SetWindowFullscreen(SDLWindowHandle, false); SDL_RestoreWindow(SDLWindowHandle); base.UpdateWindowStateAndSize(state, display, displayMode); diff --git a/osu.Framework/Platform/SDL3/SDL3MobileWindow.cs b/osu.Framework/Platform/SDL3/SDL3MobileWindow.cs index ba57f6ab79..cae21ec3b8 100644 --- a/osu.Framework/Platform/SDL3/SDL3MobileWindow.cs +++ b/osu.Framework/Platform/SDL3/SDL3MobileWindow.cs @@ -1,7 +1,6 @@ // Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. // See the LICENCE file in the repository root for full licence text. -using SDL; using static SDL.SDL3; namespace osu.Framework.Platform.SDL3 @@ -16,7 +15,7 @@ public SDL3MobileWindow(GraphicsSurfaceType surfaceType, string appName) protected override unsafe void UpdateWindowStateAndSize(WindowState state, Display display, DisplayMode displayMode) { // This sets the status bar to hidden. - SDL_SetWindowFullscreen(SDLWindowHandle, SDL_bool.SDL_TRUE); + SDL_SetWindowFullscreen(SDLWindowHandle, true); // Don't run base logic at all. Let's keep things simple. } diff --git a/osu.Framework/Platform/SDL3/SDL3ReadableKeyCombinationProvider.cs b/osu.Framework/Platform/SDL3/SDL3ReadableKeyCombinationProvider.cs index b2e431a6ba..6ce945f708 100644 --- a/osu.Framework/Platform/SDL3/SDL3ReadableKeyCombinationProvider.cs +++ b/osu.Framework/Platform/SDL3/SDL3ReadableKeyCombinationProvider.cs @@ -14,7 +14,7 @@ public class SDL3ReadableKeyCombinationProvider : ReadableKeyCombinationProvider private static SDL_Keycode getKeyFromScancode(SDL_Scancode scancode, SDL_Keymod modstate) { if (FrameworkEnvironment.UseSDL3) - return SDL_GetKeyFromScancode(scancode, modstate, SDL_FALSE); // third parameter is not useful unless SDL_HINT_KEYCODE_OPTIONS is set + return SDL_GetKeyFromScancode(scancode, modstate, false); // third parameter is not useful unless SDL_HINT_KEYCODE_OPTIONS is set return (SDL_Keycode)global::SDL2.SDL.SDL_GetKeyFromScancode((global::SDL2.SDL.SDL_Scancode)scancode); } diff --git a/osu.Framework/Platform/SDL3/SDL3Window.cs b/osu.Framework/Platform/SDL3/SDL3Window.cs index 3c985cda3a..ad30b20ad9 100644 --- a/osu.Framework/Platform/SDL3/SDL3Window.cs +++ b/osu.Framework/Platform/SDL3/SDL3Window.cs @@ -156,7 +156,7 @@ protected SDL3Window(GraphicsSurfaceType surfaceType, string appName) SDL_SetHint(SDL_HINT_APP_NAME, appName); - if (SDL_Init(SDL_InitFlags.SDL_INIT_VIDEO | SDL_InitFlags.SDL_INIT_GAMEPAD) == SDL_bool.SDL_FALSE) + if (!SDL_Init(SDL_InitFlags.SDL_INIT_VIDEO | SDL_InitFlags.SDL_INIT_GAMEPAD)) { throw new InvalidOperationException($"Failed to initialise SDL: {SDL_GetError()}"); } @@ -182,10 +182,11 @@ protected SDL3Window(GraphicsSurfaceType surfaceType, string appName) } [UnmanagedCallersOnly(CallConvs = new[] { typeof(CallConvCdecl) })] - private static void logOutput(IntPtr _, SDL_LogCategory category, SDL_LogPriority priority, byte* messagePtr) + private static void logOutput(IntPtr _, int category, SDL_LogPriority priority, byte* messagePtr) { + SDL_LogCategory categoryEnum = (SDL_LogCategory)category; string? message = PtrToStringUTF8(messagePtr); - Logger.Log($@"SDL {category.ReadableName()} log [{priority.ReadableName()}]: {message}"); + Logger.Log($@"SDL {categoryEnum.ReadableName()} log [{priority.ReadableName()}]: {message}"); } public void SetupWindow(FrameworkConfigManager config) @@ -320,23 +321,23 @@ protected void HandleEventFromWatch(SDL_Event evt) } [UnmanagedCallersOnly(CallConvs = new[] { typeof(CallConvCdecl) })] - private static SDL_bool eventFilter(IntPtr userdata, SDL_Event* eventPtr) + private static SDLBool eventFilter(IntPtr userdata, SDL_Event* eventPtr) { var handle = new ObjectHandle(userdata); if (handle.GetTarget(out SDL3Window window)) window.HandleEventFromFilter(*eventPtr); - return SDL_bool.SDL_TRUE; + return true; } [UnmanagedCallersOnly(CallConvs = new[] { typeof(CallConvCdecl) })] - private static SDL_bool eventWatch(IntPtr userdata, SDL_Event* eventPtr) + private static SDLBool eventWatch(IntPtr userdata, SDL_Event* eventPtr) { var handle = new ObjectHandle(userdata); if (handle.GetTarget(out SDL3Window window)) window.HandleEventFromWatch(*eventPtr); - return SDL_bool.SDL_TRUE; + return true; } private bool firstDraw = true; diff --git a/osu.Framework/Platform/SDL3/SDL3Window_Input.cs b/osu.Framework/Platform/SDL3/SDL3Window_Input.cs index 4a887d1735..5c340f8e37 100644 --- a/osu.Framework/Platform/SDL3/SDL3Window_Input.cs +++ b/osu.Framework/Platform/SDL3/SDL3Window_Input.cs @@ -49,7 +49,7 @@ public bool RelativeMouseMode throw new InvalidOperationException($"Cannot set {nameof(RelativeMouseMode)} to true when the cursor is not hidden via {nameof(CursorState)}."); relativeMouseMode = value; - ScheduleCommand(() => SDL_SetWindowRelativeMouseMode(SDLWindowHandle, value ? SDL_bool.SDL_TRUE : SDL_bool.SDL_FALSE)); + ScheduleCommand(() => SDL_SetWindowRelativeMouseMode(SDLWindowHandle, value)); updateCursorConfinement(); } } @@ -111,7 +111,7 @@ private void updateCursorConfinement() { bool confined = CursorState.HasFlagFast(CursorState.Confined); - ScheduleCommand(() => SDL_SetWindowMouseGrab(SDLWindowHandle, confined ? SDL_bool.SDL_TRUE : SDL_bool.SDL_FALSE)); + ScheduleCommand(() => SDL_SetWindowMouseGrab(SDLWindowHandle, confined)); // Don't use SDL_SetWindowMouseRect when relative mode is enabled, as relative mode already confines the OS cursor to the window. // This is fine for our use case, as UserInputManager will clamp the mouse position. @@ -336,7 +336,7 @@ private void addJoystick(SDL_JoystickID instanceID) SDL_Joystick* joystick = SDL_OpenJoystick(instanceID); SDL_Gamepad* controller = null; - if (SDL_IsGamepad(instanceID) == SDL_bool.SDL_TRUE) + if (SDL_IsGamepad(instanceID)) controller = SDL_OpenGamepad(instanceID); controllers[instanceID] = new SDL3ControllerBindings(joystick, controller); @@ -466,7 +466,7 @@ private void handleMouseButtonEvent(SDL_MouseButtonEvent evtButton) private void handleMouseMotionEvent(SDL_MouseMotionEvent evtMotion) { - if (SDL_GetWindowRelativeMouseMode(SDLWindowHandle) == SDL_bool.SDL_FALSE) + if (!SDL_GetWindowRelativeMouseMode(SDLWindowHandle)) MouseMove?.Invoke(new Vector2(evtMotion.x * Scale, evtMotion.y * Scale)); else MouseMoveRelative?.Invoke(new Vector2(evtMotion.xrel * Scale, evtMotion.yrel * Scale)); @@ -517,15 +517,15 @@ private void handlePenMotionEvent(SDL_PenMotionEvent evtPenMotion) private void handlePenTouchEvent(SDL_PenTouchEvent evtPenTouch) { - if (evtPenTouch.eraser == SDL_bool.SDL_TRUE) + if (evtPenTouch.eraser) return; - handlePenPressEvent(0, evtPenTouch.down == SDL_bool.SDL_TRUE); + handlePenPressEvent(0, evtPenTouch.down); } private void handlePenButtonEvent(SDL_PenButtonEvent evtPenButton) { - handlePenPressEvent(evtPenButton.button, evtPenButton.down == SDL_bool.SDL_TRUE); + handlePenPressEvent(evtPenButton.button, evtPenButton.down); } private void handlePenPressEvent(byte penButton, bool pressed) diff --git a/osu.Framework/Platform/SDL3/SDL3Window_Windowing.cs b/osu.Framework/Platform/SDL3/SDL3Window_Windowing.cs index fd5c54a650..a32d9af91c 100644 --- a/osu.Framework/Platform/SDL3/SDL3Window_Windowing.cs +++ b/osu.Framework/Platform/SDL3/SDL3Window_Windowing.cs @@ -185,7 +185,7 @@ public unsafe bool Resizable return; resizable = value; - ScheduleCommand(() => SDL_SetWindowResizable(SDLWindowHandle, value ? SDL_bool.SDL_TRUE : SDL_bool.SDL_FALSE)); + ScheduleCommand(() => SDL_SetWindowResizable(SDLWindowHandle, value)); } } @@ -356,7 +356,7 @@ private static unsafe bool tryGetDisplayFromSDL(int displayIndex, SDL_DisplayID SDL_Rect rect; - if (SDL_GetDisplayBounds(displayID, &rect) == SDL_bool.SDL_FALSE) + if (!SDL_GetDisplayBounds(displayID, &rect)) { Logger.Log($"Failed to get display bounds for display at index ({displayIndex}). SDL Error: {SDL_GetError()}"); display = null; @@ -644,7 +644,7 @@ protected virtual unsafe void UpdateWindowStateAndSize(WindowState state, Displa SDL_RestoreWindow(SDLWindowHandle); SDL_SetWindowSize(SDLWindowHandle, Size.Width, Size.Height); - SDL_SetWindowResizable(SDLWindowHandle, Resizable ? SDL_bool.SDL_TRUE : SDL_bool.SDL_FALSE); + SDL_SetWindowResizable(SDLWindowHandle, Resizable); readWindowPositionFromConfig(state, display); break; @@ -657,7 +657,7 @@ protected virtual unsafe void UpdateWindowStateAndSize(WindowState state, Displa ensureWindowOnDisplay(display); SDL_SetWindowFullscreenMode(SDLWindowHandle, &closestMode); - SDL_SetWindowFullscreen(SDLWindowHandle, SDL_bool.SDL_TRUE); + SDL_SetWindowFullscreen(SDLWindowHandle, true); break; case WindowState.FullscreenBorderless: @@ -874,14 +874,14 @@ private static unsafe SDL_DisplayMode getClosestDisplayMode(SDL_Window* windowHa SDL_DisplayMode mode; - if (SDL_GetClosestFullscreenDisplayMode(displayID, size.Width, size.Height, requestedMode.RefreshRate, SDL_bool.SDL_TRUE, &mode) == SDL_bool.SDL_TRUE) + if (SDL_GetClosestFullscreenDisplayMode(displayID, size.Width, size.Height, requestedMode.RefreshRate, true, &mode)) return mode; Logger.Log( $"Unable to get preferred display mode (try #1/2). Target display: {display.Index}, mode: {size.Width}x{size.Height}@{requestedMode.RefreshRate}. SDL error: {SDL3Extensions.GetAndClearError()}"); // fallback to current display's native bounds - if (SDL_GetClosestFullscreenDisplayMode(displayID, display.Bounds.Width, display.Bounds.Height, 0f, SDL_bool.SDL_TRUE, &mode) == SDL_bool.SDL_TRUE) + if (SDL_GetClosestFullscreenDisplayMode(displayID, display.Bounds.Width, display.Bounds.Height, 0f, true, &mode)) return mode; Logger.Log( diff --git a/osu.Framework/Platform/Windows/SDL3WindowsWindow.cs b/osu.Framework/Platform/Windows/SDL3WindowsWindow.cs index 698c3a4192..7c065b98f2 100644 --- a/osu.Framework/Platform/Windows/SDL3WindowsWindow.cs +++ b/osu.Framework/Platform/Windows/SDL3WindowsWindow.cs @@ -69,16 +69,16 @@ public override unsafe void Run() } [UnmanagedCallersOnly(CallConvs = new[] { typeof(CallConvCdecl) })] - private static unsafe SDL_bool messageHook(IntPtr userdata, MSG* msg) + private static unsafe SDLBool messageHook(IntPtr userdata, MSG* msg) { var handle = new ObjectHandle(userdata); if (handle.GetTarget(out SDL3WindowsWindow window)) return window.handleEventFromHook(*msg); - return SDL_bool.SDL_TRUE; + return true; } - private SDL_bool handleEventFromHook(MSG msg) + private SDLBool handleEventFromHook(MSG msg) { switch (msg.message) { @@ -89,7 +89,7 @@ private SDL_bool handleEventFromHook(MSG msg) break; } - return SDL_bool.SDL_TRUE; + return true; } protected override void HandleEventFromFilter(SDL_Event evt) @@ -259,7 +259,7 @@ protected set protected override unsafe Size SetBorderless(Display display) { - SDL_SetWindowBordered(SDLWindowHandle, SDL_bool.SDL_FALSE); + SDL_SetWindowBordered(SDLWindowHandle, false); var newSize = display.Bounds.Size; diff --git a/osu.Framework/osu.Framework.csproj b/osu.Framework/osu.Framework.csproj index 936331f50f..0133948419 100644 --- a/osu.Framework/osu.Framework.csproj +++ b/osu.Framework/osu.Framework.csproj @@ -40,7 +40,7 @@ - +