diff --git a/osu.Framework/FrameworkEnvironment.cs b/osu.Framework/FrameworkEnvironment.cs index 5b4b5ee8ee..f5c4369bbc 100644 --- a/osu.Framework/FrameworkEnvironment.cs +++ b/osu.Framework/FrameworkEnvironment.cs @@ -53,7 +53,7 @@ static FrameworkEnvironment() if (DebugUtils.IsDebugBuild) AllowInsecureRequests = parseBool(Environment.GetEnvironmentVariable("OSU_INSECURE_REQUESTS")) ?? false; - UseSDL3 = RuntimeInfo.IsMobile || (parseBool(Environment.GetEnvironmentVariable("OSU_SDL3")) ?? false); + UseSDL3 = RuntimeInfo.IsMobile || (parseBool(Environment.GetEnvironmentVariable("OSU_SDL3")) ?? true); } private static bool? parseBool(string? value) diff --git a/osu.Framework/Platform/SDL3/SDL3Extensions.cs b/osu.Framework/Platform/SDL3/SDL3Extensions.cs index 4735890bb3..7f8e795959 100644 --- a/osu.Framework/Platform/SDL3/SDL3Extensions.cs +++ b/osu.Framework/Platform/SDL3/SDL3Extensions.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 System.Diagnostics.CodeAnalysis; using System.Drawing; using osu.Framework.Extensions.EnumExtensions; using osu.Framework.Graphics.Primitives; @@ -1128,17 +1127,5 @@ public static string ReadableName(this SDL_LogPriority priority) SDL_ClearError(); return error; } - - /// - /// Gets the of the touch device for this . - /// - /// - /// On Windows, this will return "touch" for touchscreen events or "pen" for pen/tablet events. - /// - public static bool TryGetTouchName(this SDL_TouchFingerEvent e, [NotNullWhen(true)] out string? name) - { - name = SDL_GetTouchDeviceName(e.touchID); - return name != null; - } } } diff --git a/osu.Framework/Platform/SDL3/SDL3Window.cs b/osu.Framework/Platform/SDL3/SDL3Window.cs index 67f3b5b3ff..8f7783571a 100644 --- a/osu.Framework/Platform/SDL3/SDL3Window.cs +++ b/osu.Framework/Platform/SDL3/SDL3Window.cs @@ -210,6 +210,8 @@ public virtual void Create() SDL_SetHint(SDL_HINT_MOUSE_RELATIVE_MODE_CENTER, "0"u8); SDL_SetHint(SDL_HINT_TOUCH_MOUSE_EVENTS, "0"u8); // disable touch events generating synthetic mouse events on desktop platforms SDL_SetHint(SDL_HINT_MOUSE_TOUCH_EVENTS, "0"u8); // disable mouse events generating synthetic touch events on mobile platforms + SDL_SetHint(SDL_HINT_PEN_TOUCH_EVENTS, "0"u8); + SDL_SetHint(SDL_HINT_PEN_MOUSE_EVENTS, "0"u8); SDL_SetHint(SDL_HINT_IME_IMPLEMENTED_UI, "composition"u8); SDLWindowHandle = SDL_CreateWindow(title, Size.Width, Size.Height, flags); @@ -570,7 +572,8 @@ protected virtual void HandleEvent(SDL_Event e) case SDL_EventType.SDL_EVENT_FINGER_DOWN: case SDL_EventType.SDL_EVENT_FINGER_UP: case SDL_EventType.SDL_EVENT_FINGER_MOTION: - HandleTouchFingerEvent(e.tfinger); + case SDL_EventType.SDL_EVENT_FINGER_CANCELED: + handleTouchFingerEvent(e.tfinger); break; case SDL_EventType.SDL_EVENT_DROP_FILE: diff --git a/osu.Framework/Platform/SDL3/SDL3Window_Input.cs b/osu.Framework/Platform/SDL3/SDL3Window_Input.cs index 803f55285a..0e9307fe4b 100644 --- a/osu.Framework/Platform/SDL3/SDL3Window_Input.cs +++ b/osu.Framework/Platform/SDL3/SDL3Window_Input.cs @@ -274,7 +274,7 @@ private void handleDropEvent(SDL_DropEvent evtDrop) return null; } - protected virtual void HandleTouchFingerEvent(SDL_TouchFingerEvent evtTfinger) + private void handleTouchFingerEvent(SDL_TouchFingerEvent evtTfinger) { var existingSource = getTouchSource(evtTfinger.fingerID); @@ -305,6 +305,7 @@ protected virtual void HandleTouchFingerEvent(SDL_TouchFingerEvent evtTfinger) break; case SDL_EventType.SDL_EVENT_FINGER_UP: + case SDL_EventType.SDL_EVENT_FINGER_CANCELED: TouchUp?.Invoke(touch); activeTouches[(int)existingSource] = null; break; diff --git a/osu.Framework/Platform/Windows/SDL3WindowsWindow.cs b/osu.Framework/Platform/Windows/SDL3WindowsWindow.cs index 52af756f4b..ad651d80a0 100644 --- a/osu.Framework/Platform/Windows/SDL3WindowsWindow.cs +++ b/osu.Framework/Platform/Windows/SDL3WindowsWindow.cs @@ -10,7 +10,6 @@ using osu.Framework.Platform.SDL3; using osu.Framework.Platform.Windows.Native; using osuTK; -using osuTK.Input; using SDL; using Icon = osu.Framework.Platform.Windows.Native.Icon; using static SDL.SDL3; @@ -101,33 +100,6 @@ public override void StartTextInput(TextInputProperties properties) public override void ResetIme() => ScheduleCommand(() => Imm.CancelComposition(WindowHandle)); - protected override void HandleTouchFingerEvent(SDL_TouchFingerEvent evtTfinger) - { - if (evtTfinger.TryGetTouchName(out string? name) && name == "pen") - { - // Windows Ink tablet/pen handling - // InputManager expects to receive this as mouse events, to have proper `mouseSource` input priority (see InputManager.GetPendingInputs) - // osu! expects to get tablet events as mouse events, and touch events as touch events for touch device (TD mod) handling (see https://github.com/ppy/osu/issues/25590) - - TriggerMouseMove(evtTfinger.x * ClientSize.Width, evtTfinger.y * ClientSize.Height); - - switch (evtTfinger.type) - { - case SDL_EventType.SDL_EVENT_FINGER_DOWN: - TriggerMouseDown(MouseButton.Left); - break; - - case SDL_EventType.SDL_EVENT_FINGER_UP: - TriggerMouseUp(MouseButton.Left); - break; - } - - return; - } - - base.HandleTouchFingerEvent(evtTfinger); - } - public override Size Size { protected set diff --git a/osu.Framework/osu.Framework.csproj b/osu.Framework/osu.Framework.csproj index fd2172ef05..19a3ce9aab 100644 --- a/osu.Framework/osu.Framework.csproj +++ b/osu.Framework/osu.Framework.csproj @@ -38,7 +38,7 @@ - +