Skip to content

Commit 6bbcfd8

Browse files
authored
Merge pull request #6511 from Susko3/update-SDL3
Update SDL3, bringing in support for Windows Ink pen input, and enable it on desktop platforms once again
2 parents f6c6177 + b33e6a6 commit 6bbcfd8

File tree

6 files changed

+8
-45
lines changed

6 files changed

+8
-45
lines changed

osu.Framework/FrameworkEnvironment.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ static FrameworkEnvironment()
5353
if (DebugUtils.IsDebugBuild)
5454
AllowInsecureRequests = parseBool(Environment.GetEnvironmentVariable("OSU_INSECURE_REQUESTS")) ?? false;
5555

56-
UseSDL3 = RuntimeInfo.IsMobile || (parseBool(Environment.GetEnvironmentVariable("OSU_SDL3")) ?? false);
56+
UseSDL3 = RuntimeInfo.IsMobile || (parseBool(Environment.GetEnvironmentVariable("OSU_SDL3")) ?? true);
5757
}
5858

5959
private static bool? parseBool(string? value)

osu.Framework/Platform/SDL3/SDL3Extensions.cs

-13
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
// Copyright (c) ppy Pty Ltd <[email protected]>. Licensed under the MIT Licence.
22
// See the LICENCE file in the repository root for full licence text.
33

4-
using System.Diagnostics.CodeAnalysis;
54
using System.Drawing;
65
using osu.Framework.Extensions.EnumExtensions;
76
using osu.Framework.Graphics.Primitives;
@@ -1128,17 +1127,5 @@ public static string ReadableName(this SDL_LogPriority priority)
11281127
SDL_ClearError();
11291128
return error;
11301129
}
1131-
1132-
/// <summary>
1133-
/// Gets the <paramref name="name"/> of the touch device for this <see cref="SDL_TouchFingerEvent"/>.
1134-
/// </summary>
1135-
/// <remarks>
1136-
/// On Windows, this will return <c>"touch"</c> for touchscreen events or <c>"pen"</c> for pen/tablet events.
1137-
/// </remarks>
1138-
public static bool TryGetTouchName(this SDL_TouchFingerEvent e, [NotNullWhen(true)] out string? name)
1139-
{
1140-
name = SDL_GetTouchDeviceName(e.touchID);
1141-
return name != null;
1142-
}
11431130
}
11441131
}

osu.Framework/Platform/SDL3/SDL3Window.cs

+4-1
Original file line numberDiff line numberDiff line change
@@ -210,6 +210,8 @@ public virtual void Create()
210210
SDL_SetHint(SDL_HINT_MOUSE_RELATIVE_MODE_CENTER, "0"u8);
211211
SDL_SetHint(SDL_HINT_TOUCH_MOUSE_EVENTS, "0"u8); // disable touch events generating synthetic mouse events on desktop platforms
212212
SDL_SetHint(SDL_HINT_MOUSE_TOUCH_EVENTS, "0"u8); // disable mouse events generating synthetic touch events on mobile platforms
213+
SDL_SetHint(SDL_HINT_PEN_TOUCH_EVENTS, "0"u8);
214+
SDL_SetHint(SDL_HINT_PEN_MOUSE_EVENTS, "0"u8);
213215
SDL_SetHint(SDL_HINT_IME_IMPLEMENTED_UI, "composition"u8);
214216

215217
SDLWindowHandle = SDL_CreateWindow(title, Size.Width, Size.Height, flags);
@@ -570,7 +572,8 @@ protected virtual void HandleEvent(SDL_Event e)
570572
case SDL_EventType.SDL_EVENT_FINGER_DOWN:
571573
case SDL_EventType.SDL_EVENT_FINGER_UP:
572574
case SDL_EventType.SDL_EVENT_FINGER_MOTION:
573-
HandleTouchFingerEvent(e.tfinger);
575+
case SDL_EventType.SDL_EVENT_FINGER_CANCELED:
576+
handleTouchFingerEvent(e.tfinger);
574577
break;
575578

576579
case SDL_EventType.SDL_EVENT_DROP_FILE:

osu.Framework/Platform/SDL3/SDL3Window_Input.cs

+2-1
Original file line numberDiff line numberDiff line change
@@ -274,7 +274,7 @@ private void handleDropEvent(SDL_DropEvent evtDrop)
274274
return null;
275275
}
276276

277-
protected virtual void HandleTouchFingerEvent(SDL_TouchFingerEvent evtTfinger)
277+
private void handleTouchFingerEvent(SDL_TouchFingerEvent evtTfinger)
278278
{
279279
var existingSource = getTouchSource(evtTfinger.fingerID);
280280

@@ -305,6 +305,7 @@ protected virtual void HandleTouchFingerEvent(SDL_TouchFingerEvent evtTfinger)
305305
break;
306306

307307
case SDL_EventType.SDL_EVENT_FINGER_UP:
308+
case SDL_EventType.SDL_EVENT_FINGER_CANCELED:
308309
TouchUp?.Invoke(touch);
309310
activeTouches[(int)existingSource] = null;
310311
break;

osu.Framework/Platform/Windows/SDL3WindowsWindow.cs

-28
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
using osu.Framework.Platform.SDL3;
1111
using osu.Framework.Platform.Windows.Native;
1212
using osuTK;
13-
using osuTK.Input;
1413
using SDL;
1514
using Icon = osu.Framework.Platform.Windows.Native.Icon;
1615
using static SDL.SDL3;
@@ -101,33 +100,6 @@ public override void StartTextInput(TextInputProperties properties)
101100

102101
public override void ResetIme() => ScheduleCommand(() => Imm.CancelComposition(WindowHandle));
103102

104-
protected override void HandleTouchFingerEvent(SDL_TouchFingerEvent evtTfinger)
105-
{
106-
if (evtTfinger.TryGetTouchName(out string? name) && name == "pen")
107-
{
108-
// Windows Ink tablet/pen handling
109-
// InputManager expects to receive this as mouse events, to have proper `mouseSource` input priority (see InputManager.GetPendingInputs)
110-
// 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)
111-
112-
TriggerMouseMove(evtTfinger.x * ClientSize.Width, evtTfinger.y * ClientSize.Height);
113-
114-
switch (evtTfinger.type)
115-
{
116-
case SDL_EventType.SDL_EVENT_FINGER_DOWN:
117-
TriggerMouseDown(MouseButton.Left);
118-
break;
119-
120-
case SDL_EventType.SDL_EVENT_FINGER_UP:
121-
TriggerMouseUp(MouseButton.Left);
122-
break;
123-
}
124-
125-
return;
126-
}
127-
128-
base.HandleTouchFingerEvent(evtTfinger);
129-
}
130-
131103
public override Size Size
132104
{
133105
protected set

osu.Framework/osu.Framework.csproj

+1-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
<PackageReference Include="ppy.osuTK.NS20" Version="1.0.211" />
3939
<PackageReference Include="StbiSharp" Version="1.1.0" />
4040
<PackageReference Include="ppy.SDL2-CS" Version="1.0.741-alpha" />
41-
<PackageReference Include="ppy.SDL3-CS" Version="2025.104.0" />
41+
<PackageReference Include="ppy.SDL3-CS" Version="2025.127.0" />
4242
<PackageReference Include="ppy.osu.Framework.SourceGeneration" Version="2024.1128.0" />
4343

4444
<!-- DO NOT use ProjectReference for native packaging project.

0 commit comments

Comments
 (0)