Skip to content

Commit 7c5b248

Browse files
authored
Merge pull request #5753 from Susko3/fix-windows-touch-feedback
Fix touch feedback breaking Direct3D 11 exclusive/optimised fullscreen
2 parents 542d34e + 38decf3 commit 7c5b248

File tree

2 files changed

+29
-0
lines changed

2 files changed

+29
-0
lines changed

osu.Framework/Platform/Windows/Native/Input.cs

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,16 @@ public static extern bool RegisterRawInputDevices(
6767

6868
[DllImport("user32.dll", SetLastError = false)]
6969
public static extern long GetMessageExtraInfo();
70+
71+
[DllImport("user32.dll", SetLastError = true)]
72+
[return: MarshalAs(UnmanagedType.Bool)]
73+
private static extern unsafe bool SetWindowFeedbackSetting(IntPtr hwnd, FeedbackType feedback, ulong flags, uint size, int* configuration);
74+
75+
public static unsafe void SetWindowFeedbackSetting(IntPtr hwnd, FeedbackType feedback, bool configuration)
76+
{
77+
int config = configuration ? 1 : 0; // mimics win32 BOOL type.
78+
SetWindowFeedbackSetting(hwnd, feedback, 0, sizeof(int), &config);
79+
}
7080
}
7181

7282
/// <summary>
@@ -339,4 +349,19 @@ public enum HIDUsagePage : ushort
339349
Scale = 0x8D,
340350
MSR = 0x8E
341351
}
352+
353+
public enum FeedbackType
354+
{
355+
TouchContactVisualization = 1,
356+
PenBarrelVisualization = 2,
357+
PenTap = 3,
358+
PenDoubleTap = 4,
359+
PenPressAndHold = 5,
360+
PenRightTap = 6,
361+
TouchTap = 7,
362+
TouchDoubleTap = 8,
363+
TouchPressAndHold = 9,
364+
TouchRightTap = 10,
365+
GesturePressAndTap = 11,
366+
}
342367
}

osu.Framework/Platform/Windows/WindowsWindow.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,10 @@ public override void Create()
6464
{
6565
base.Create();
6666

67+
// disable all pen and touch feedback as this causes issues when running "optimised" fullscreen under Direct3D11.
68+
foreach (var feedbackType in Enum.GetValues<FeedbackType>())
69+
Native.Input.SetWindowFeedbackSetting(WindowHandle, feedbackType, false);
70+
6771
// enable window message events to use with `OnSDLEvent` below.
6872
SDL.SDL_EventState(SDL.SDL_EventType.SDL_SYSWMEVENT, SDL.SDL_ENABLE);
6973
}

0 commit comments

Comments
 (0)