Rename classes from SDL2* to SDL3*

This commit is contained in:
Susko3
2024-04-08 15:50:55 +02:00
parent d16105ab25
commit 2ea78bb6f7
30 changed files with 63 additions and 63 deletions

View File

@@ -24,7 +24,7 @@ namespace osu.Framework.Tests.Visual.Platform
private readonly SpriteText currentWindowMode = new SpriteText();
private readonly SpriteText currentDisplay = new SpriteText();
private SDL2Window? window;
private SDL3Window? window;
private readonly Bindable<WindowMode> windowMode = new Bindable<WindowMode>();
public TestSceneBorderless()
@@ -57,7 +57,7 @@ namespace osu.Framework.Tests.Visual.Platform
[BackgroundDependencyLoader]
private void load(FrameworkConfigManager config, GameHost host)
{
window = host.Window as SDL2Window;
window = host.Window as SDL3Window;
config.BindWith(FrameworkSetting.WindowMode, windowMode);
windowMode.BindValueChanged(mode => currentWindowMode.Text = $"Window Mode: {mode.NewValue}", true);

View File

@@ -129,7 +129,7 @@ namespace osu.Framework.Tests.Visual.Platform
if (window.SupportedWindowModes.Contains(WindowMode.Fullscreen))
{
AddStep("change to fullscreen", () => windowMode.Value = WindowMode.Fullscreen);
AddAssert("window position updated", () => ((SDL2Window)window).Position, () => Is.EqualTo(window.CurrentDisplayBindable.Value.Bounds.Location));
AddAssert("window position updated", () => ((SDL3Window)window).Position, () => Is.EqualTo(window.CurrentDisplayBindable.Value.Bounds.Location));
testResolution(1920, 1080);
testResolution(1280, 960);
testResolution(9999, 9999);

View File

@@ -31,12 +31,12 @@ namespace osu.Framework.Tests.Visual.Platform
[Resolved]
private FrameworkConfigManager config { get; set; }
private SDL2Window sdlWindow;
private SDL3Window sdlWindow;
[BackgroundDependencyLoader]
private void load()
{
sdlWindow = (SDL2Window)host.Window;
sdlWindow = (SDL3Window)host.Window;
Children = new Drawable[]
{
new FillFlowContainer

View File

@@ -36,7 +36,7 @@ namespace osu.Framework.Tests.Visual.Platform
private static readonly Color4 window_fill = new Color4(95, 113, 197, 255);
private static readonly Color4 window_stroke = new Color4(36, 59, 166, 255);
private SDL2Window? window;
private SDL3Window? window;
private readonly Bindable<WindowMode> windowMode = new Bindable<WindowMode>();
private readonly Bindable<Display> currentDisplay = new Bindable<Display>();
@@ -90,7 +90,7 @@ namespace osu.Framework.Tests.Visual.Platform
[BackgroundDependencyLoader]
private void load(FrameworkConfigManager config, GameHost host)
{
window = host.Window as SDL2Window;
window = host.Window as SDL3Window;
config.BindWith(FrameworkSetting.WindowMode, windowMode);
if (window != null)

View File

@@ -21,7 +21,7 @@ using UIKit;
namespace osu.Framework.iOS
{
public class IOSGameHost : SDL2GameHost
public class IOSGameHost : SDL3GameHost
{
public IOSGameHost()
: base(string.Empty)

View File

@@ -15,7 +15,7 @@ using UIKit;
namespace osu.Framework.iOS
{
internal class IOSWindow : SDL2Window
internal class IOSWindow : SDL3Window
{
private UIWindow? window;

View File

@@ -29,7 +29,7 @@ namespace osu.Framework.Input.Handlers.Joystick
if (!base.Initialize(host))
return false;
if (!(host.Window is SDL2Window window))
if (!(host.Window is SDL3Window window))
return false;
Enabled.BindValueChanged(e =>

View File

@@ -21,7 +21,7 @@ namespace osu.Framework.Input.Handlers.Keyboard
if (!base.Initialize(host))
return false;
if (!(host.Window is SDL2Window window))
if (!(host.Window is SDL3Window window))
return false;
Enabled.BindValueChanged(e =>

View File

@@ -15,7 +15,7 @@ using osuTK.Input;
namespace osu.Framework.Input.Handlers.Mouse
{
/// <summary>
/// Handles mouse events from an <see cref="SDL2Window"/>.
/// Handles mouse events from an <see cref="SDL3Window"/>.
/// Will use relative mouse mode where possible.
/// </summary>
public class MouseHandler : InputHandler, IHasCursorSensitivity, INeedsMousePositionFeedback
@@ -41,7 +41,7 @@ namespace osu.Framework.Input.Handlers.Mouse
public override bool IsActive => true;
private SDL2Window window;
private SDL3Window window;
private Vector2? lastPosition;
@@ -76,7 +76,7 @@ namespace osu.Framework.Input.Handlers.Mouse
if (!base.Initialize(host))
return false;
if (!(host.Window is SDL2Window desktopWindow))
if (!(host.Window is SDL3Window desktopWindow))
return false;
window = desktopWindow;

View File

@@ -18,7 +18,7 @@ namespace osu.Framework.Input.Handlers.Touch
if (!base.Initialize(host))
return false;
if (!(host.Window is SDL2Window window))
if (!(host.Window is SDL3Window window))
return false;
Enabled.BindValueChanged(enabled =>

View File

@@ -6,11 +6,11 @@ using osu.Framework.Platform;
namespace osu.Framework.Input
{
internal class SDL2WindowTextInput : TextInputSource
internal class SDL3WindowTextInput : TextInputSource
{
private readonly SDL2Window window;
private readonly SDL3Window window;
public SDL2WindowTextInput(SDL2Window window)
public SDL3WindowTextInput(SDL3Window window)
{
this.window = window;
}

View File

@@ -90,7 +90,7 @@ namespace osu.Framework.Input
switch (Host.Window.WindowMode.Value)
{
case WindowMode.Windowed:
windowLocation = Host.Window is SDL2Window sdlWindow ? sdlWindow.Position : Point.Empty;
windowLocation = Host.Window is SDL3Window sdlWindow ? sdlWindow.Position : Point.Empty;
break;
default:

View File

@@ -13,7 +13,7 @@ using osu.Framework.Logging;
namespace osu.Framework.Platform
{
public abstract class DesktopGameHost : SDL2GameHost
public abstract class DesktopGameHost : SDL3GameHost
{
private TcpIpcProvider ipcProvider;
private readonly int? ipcPort;

View File

@@ -780,7 +780,7 @@ namespace osu.Framework.Platform
{
switch (Window)
{
case SDL2Window window:
case SDL3Window window:
window.Update += windowUpdate;
break;

View File

@@ -33,7 +33,7 @@ namespace osu.Framework.Platform.Linux
base.SetupForRun();
}
protected override IWindow CreateWindow(GraphicsSurfaceType preferredSurface) => new SDL2DesktopWindow(preferredSurface);
protected override IWindow CreateWindow(GraphicsSurfaceType preferredSurface) => new SDL3DesktopWindow(preferredSurface);
protected override ReadableKeyCombinationProvider CreateReadableKeyCombinationProvider() => new LinuxReadableKeyCombinationProvider();

View File

@@ -7,7 +7,7 @@ using SDL;
namespace osu.Framework.Platform.Linux
{
public class LinuxReadableKeyCombinationProvider : SDL2ReadableKeyCombinationProvider
public class LinuxReadableKeyCombinationProvider : SDL3ReadableKeyCombinationProvider
{
protected override string GetReadableKey(InputKey key)
{

View File

@@ -7,7 +7,7 @@ using SDL;
namespace osu.Framework.Platform.MacOS
{
public class MacOSReadableKeyCombinationProvider : SDL2ReadableKeyCombinationProvider
public class MacOSReadableKeyCombinationProvider : SDL3ReadableKeyCombinationProvider
{
protected override string GetReadableKey(InputKey key)
{

View File

@@ -10,9 +10,9 @@ using osuTK;
namespace osu.Framework.Platform.MacOS
{
/// <summary>
/// macOS-specific subclass of <see cref="SDL2Window"/>.
/// macOS-specific subclass of <see cref="SDL3Window"/>.
/// </summary>
internal class MacOSWindow : SDL2DesktopWindow
internal class MacOSWindow : SDL3DesktopWindow
{
private static readonly IntPtr sel_hasprecisescrollingdeltas = Selector.Get("hasPreciseScrollingDeltas");
private static readonly IntPtr sel_scrollingdeltax = Selector.Get("scrollingDeltaX");

View File

@@ -7,7 +7,7 @@ using SixLabors.ImageSharp;
namespace osu.Framework.Platform.SDL
{
public class SDL2Clipboard : Clipboard
public class SDL3Clipboard : Clipboard
{
// 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.

View File

@@ -12,7 +12,7 @@ namespace osu.Framework.Platform.SDL
/// Maintain a copy of the SDL-provided bindings for the given controller.
/// Used to determine whether a given event's joystick button or axis is unmapped.
/// </summary>
internal unsafe class SDL2ControllerBindings
internal unsafe class SDL3ControllerBindings
{
public readonly SDL_Joystick* JoystickHandle;
public readonly SDL_Gamepad* GamepadHandle;
@@ -23,7 +23,7 @@ namespace osu.Framework.Platform.SDL
/// </summary>
public SDL_GamepadBinding[] Bindings;
public SDL2ControllerBindings(SDL_Joystick* joystickHandle, SDL_Gamepad* gamepadHandle)
public SDL3ControllerBindings(SDL_Joystick* joystickHandle, SDL_Gamepad* gamepadHandle)
{
JoystickHandle = joystickHandle;
GamepadHandle = gamepadHandle;

View File

@@ -13,7 +13,7 @@ using SDL;
namespace osu.Framework.Platform.SDL
{
public static class SDL2Extensions
public static class SDL3Extensions
{
public static Key ToKey(this SDL_Keysym sdlKeysym)
{

View File

@@ -14,9 +14,9 @@ using SDL;
namespace osu.Framework.Platform.SDL
{
internal unsafe class SDL2GraphicsSurface : IGraphicsSurface, IOpenGLGraphicsSurface, IMetalGraphicsSurface, ILinuxGraphicsSurface
internal unsafe class SDL3GraphicsSurface : IGraphicsSurface, IOpenGLGraphicsSurface, IMetalGraphicsSurface, ILinuxGraphicsSurface
{
private readonly SDL2Window window;
private readonly SDL3Window window;
private IntPtr context;
@@ -25,7 +25,7 @@ namespace osu.Framework.Platform.SDL
public GraphicsSurfaceType Type { get; }
public SDL2GraphicsSurface(SDL2Window window, GraphicsSurfaceType surfaceType)
public SDL3GraphicsSurface(SDL3Window window, GraphicsSurfaceType surfaceType)
{
this.window = window;
Type = surfaceType;

View File

@@ -8,7 +8,7 @@ using SDL;
namespace osu.Framework.Platform.SDL
{
public class SDL2ReadableKeyCombinationProvider : ReadableKeyCombinationProvider
public class SDL3ReadableKeyCombinationProvider : ReadableKeyCombinationProvider
{
protected override string GetReadableKey(InputKey key)
{

View File

@@ -5,9 +5,9 @@ using SDL;
namespace osu.Framework.Platform
{
internal class SDL2DesktopWindow : SDL2Window
internal class SDL3DesktopWindow : SDL3Window
{
public SDL2DesktopWindow(GraphicsSurfaceType surfaceType)
public SDL3DesktopWindow(GraphicsSurfaceType surfaceType)
: base(surfaceType)
{
}

View File

@@ -14,24 +14,24 @@ using osu.Framework.Platform.SDL;
namespace osu.Framework.Platform
{
public abstract class SDL2GameHost : GameHost
public abstract class SDL3GameHost : GameHost
{
public override bool CapsLockEnabled => (Window as SDL2Window)?.CapsLockPressed == true;
public override bool CapsLockEnabled => (Window as SDL3Window)?.CapsLockPressed == true;
protected SDL2GameHost(string gameName, HostOptions? options = null)
protected SDL3GameHost(string gameName, HostOptions? options = null)
: base(gameName, options)
{
}
protected override TextInputSource CreateTextInput()
{
if (Window is SDL2Window window)
return new SDL2WindowTextInput(window);
if (Window is SDL3Window window)
return new SDL3WindowTextInput(window);
return base.CreateTextInput();
}
protected override Clipboard CreateClipboard() => new SDL2Clipboard();
protected override Clipboard CreateClipboard() => new SDL3Clipboard();
protected override IEnumerable<InputHandler> CreateAvailableInputHandlers() =>
new InputHandler[]

View File

@@ -25,11 +25,11 @@ namespace osu.Framework.Platform
/// <summary>
/// Default implementation of a window, using SDL for windowing and graphics support.
/// </summary>
internal abstract unsafe partial class SDL2Window : IWindow
internal abstract unsafe partial class SDL3Window : IWindow
{
internal SDL_Window* SDLWindowHandle { get; private set; } = null;
private readonly SDL2GraphicsSurface graphicsSurface;
private readonly SDL3GraphicsSurface graphicsSurface;
IGraphicsSurface IWindow.GraphicsSurface => graphicsSurface;
/// <summary>
@@ -142,13 +142,13 @@ namespace osu.Framework.Platform
public bool CapsLockPressed => SDL3.SDL_GetModState().HasFlagFast(SDL_Keymod.SDL_KMOD_CAPS);
/// <summary>
/// Represents a handle to this <see cref="SDL2Window"/> instance, used for unmanaged callbacks.
/// Represents a handle to this <see cref="SDL3Window"/> instance, used for unmanaged callbacks.
/// </summary>
protected ObjectHandle<SDL2Window> ObjectHandle { get; private set; }
protected ObjectHandle<SDL3Window> ObjectHandle { get; private set; }
protected SDL2Window(GraphicsSurfaceType surfaceType)
protected SDL3Window(GraphicsSurfaceType surfaceType)
{
ObjectHandle = new ObjectHandle<SDL2Window>(this, GCHandleType.Normal);
ObjectHandle = new ObjectHandle<SDL3Window>(this, GCHandleType.Normal);
if (SDL3.SDL_Init(SDL_InitFlags.SDL_INIT_VIDEO | SDL_InitFlags.SDL_INIT_GAMEPAD) < 0)
{
@@ -158,7 +158,7 @@ namespace osu.Framework.Platform
SDL3.SDL_LogSetPriority(SDL_LogCategory.SDL_LOG_CATEGORY_ERROR, SDL_LogPriority.SDL_LOG_PRIORITY_DEBUG);
SDL3.SDL_SetLogOutputFunction(&logOutput, IntPtr.Zero);
graphicsSurface = new SDL2GraphicsSurface(this, surfaceType);
graphicsSurface = new SDL3GraphicsSurface(this, surfaceType);
CursorStateBindable.ValueChanged += evt =>
{
@@ -311,8 +311,8 @@ namespace osu.Framework.Platform
[UnmanagedCallersOnly(CallConvs = new[] { typeof(CallConvCdecl) })]
private static int eventFilter(IntPtr userdata, SDL_Event* eventPtr)
{
var handle = new ObjectHandle<SDL2Window>(userdata);
if (handle.GetTarget(out SDL2Window window))
var handle = new ObjectHandle<SDL3Window>(userdata);
if (handle.GetTarget(out SDL3Window window))
window.HandleEventFromFilter(*eventPtr);
return 1;
@@ -321,8 +321,8 @@ namespace osu.Framework.Platform
[UnmanagedCallersOnly(CallConvs = new[] { typeof(CallConvCdecl) })]
private static int eventWatch(IntPtr userdata, SDL_Event* eventPtr)
{
var handle = new ObjectHandle<SDL2Window>(userdata);
if (handle.GetTarget(out SDL2Window window))
var handle = new ObjectHandle<SDL3Window>(userdata);
if (handle.GetTarget(out SDL3Window window))
window.HandleEventFromWatch(*eventPtr);
return 1;

View File

@@ -20,7 +20,7 @@ using RectangleF = osu.Framework.Graphics.Primitives.RectangleF;
namespace osu.Framework.Platform
{
internal partial class SDL2Window
internal partial class SDL3Window
{
private void setupInput(FrameworkConfigManager config)
{
@@ -93,7 +93,7 @@ namespace osu.Framework.Platform
}
}
private readonly Dictionary<SDL_JoystickID, SDL2ControllerBindings> controllers = new Dictionary<SDL_JoystickID, SDL2ControllerBindings>();
private readonly Dictionary<SDL_JoystickID, SDL3ControllerBindings> controllers = new Dictionary<SDL_JoystickID, SDL3ControllerBindings>();
private void updateCursorVisibility(bool cursorVisible) =>
ScheduleCommand(() =>
@@ -329,7 +329,7 @@ namespace osu.Framework.Platform
if (SDL3.SDL_IsGamepad(instanceID) == SDL_bool.SDL_TRUE)
controller = SDL3.SDL_OpenGamepad(instanceID);
controllers[instanceID] = new SDL2ControllerBindings(joystick, controller);
controllers[instanceID] = new SDL3ControllerBindings(joystick, controller);
}
/// <summary>

View File

@@ -17,7 +17,7 @@ using SDL;
namespace osu.Framework.Platform
{
internal partial class SDL2Window
internal partial class SDL3Window
{
private unsafe void setupWindowing(FrameworkConfigManager config)
{
@@ -870,28 +870,28 @@ namespace osu.Framework.Platform
if (mode != null)
return *mode;
else
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: {SDL2Extensions.GetAndClearError()}");
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
mode = SDL3.SDL_GetClosestFullscreenDisplayMode(displayID, display.Bounds.Width, display.Bounds.Height, 0f, SDL_bool.SDL_TRUE);
if (mode != null)
return *mode;
else
Logger.Log($"Unable to get preferred display mode (try #2/2). Target display: {display.Index}, mode: {display.Bounds.Width}x{display.Bounds.Height}@default. SDL error: {SDL2Extensions.GetAndClearError()}");
Logger.Log($"Unable to get preferred display mode (try #2/2). Target display: {display.Index}, mode: {display.Bounds.Width}x{display.Bounds.Height}@default. SDL error: {SDL3Extensions.GetAndClearError()}");
// try the display's native display mode.
mode = SDL3.SDL_GetDesktopDisplayMode(displayID);
if (mode != null)
return *mode;
else
Logger.Log($"Failed to get desktop display mode (try #1/1). Target display: {display.Index}. SDL error: {SDL2Extensions.GetAndClearError()}", level: LogLevel.Error);
Logger.Log($"Failed to get desktop display mode (try #1/1). Target display: {display.Index}. SDL error: {SDL3Extensions.GetAndClearError()}", level: LogLevel.Error);
// finally return the current mode if everything else fails.
mode = SDL3.SDL_GetWindowFullscreenMode(windowHandle);
if (mode != null)
return *mode;
else
Logger.Log($"Failed to get window display mode. SDL error: {SDL2Extensions.GetAndClearError()}", level: LogLevel.Error);
Logger.Log($"Failed to get window display mode. SDL error: {SDL3Extensions.GetAndClearError()}", level: LogLevel.Error);
throw new InvalidOperationException("couldn't retrieve valid display mode");
}

View File

@@ -7,7 +7,7 @@ using SDL;
namespace osu.Framework.Platform.Windows
{
public class WindowsReadableKeyCombinationProvider : SDL2ReadableKeyCombinationProvider
public class WindowsReadableKeyCombinationProvider : SDL3ReadableKeyCombinationProvider
{
protected override string GetReadableKey(InputKey key)
{

View File

@@ -19,7 +19,7 @@ using Icon = osu.Framework.Platform.Windows.Native.Icon;
namespace osu.Framework.Platform.Windows
{
[SupportedOSPlatform("windows")]
internal class WindowsWindow : SDL2DesktopWindow
internal class WindowsWindow : SDL3DesktopWindow
{
private const int seticon_message = 0x0080;
private const int icon_big = 1;