diff --git a/osu.Framework.iOS/IOSGameHost.cs b/osu.Framework.iOS/IOSGameHost.cs index 813d6133e6..7b696fd97f 100644 --- a/osu.Framework.iOS/IOSGameHost.cs +++ b/osu.Framework.iOS/IOSGameHost.cs @@ -38,8 +38,6 @@ protected override void SetupConfig(IDictionary defaul base.SetupConfig(defaultOverrides); } - public override bool OnScreenKeyboardOverlapsGameWindow => true; - public override bool CanExit => false; public override Storage GetStorage(string path) => new IOSStorage(path, this); diff --git a/osu.Framework.iOS/IOSWindow.cs b/osu.Framework.iOS/IOSWindow.cs index 5444664a88..1583ffccb8 100644 --- a/osu.Framework.iOS/IOSWindow.cs +++ b/osu.Framework.iOS/IOSWindow.cs @@ -11,7 +11,6 @@ using osu.Framework.Graphics; using osu.Framework.Platform; using osu.Framework.Platform.SDL3; -using SDL; using static SDL.SDL3; using UIKit; diff --git a/osu.Framework/Platform/GameHost.cs b/osu.Framework/Platform/GameHost.cs index e5ed5aa6b5..4eab59a416 100644 --- a/osu.Framework/Platform/GameHost.cs +++ b/osu.Framework/Platform/GameHost.cs @@ -122,7 +122,8 @@ public abstract class GameHost : IIpcHost, IDisposable public event Func MessageReceived; /// - /// Whether the on screen keyboard covers a portion of the game window when presented to the user. + /// Whether the on-screen keyboard covers a portion of the game window when presented to the user. + /// This is usually true on mobile platforms, but may change to false if a hardware keyboard is connected. /// public virtual bool OnScreenKeyboardOverlapsGameWindow => false; diff --git a/osu.Framework/Platform/ISDLWindow.cs b/osu.Framework/Platform/ISDLWindow.cs index 66f627e28e..640cd8b099 100644 --- a/osu.Framework/Platform/ISDLWindow.cs +++ b/osu.Framework/Platform/ISDLWindow.cs @@ -39,6 +39,7 @@ internal interface ISDLWindow : IWindow bool MouseAutoCapture { set; } bool RelativeMouseMode { get; set; } bool CapsLockPressed { get; } + bool KeyboardAttached { get; } void UpdateMousePosition(Vector2 position); diff --git a/osu.Framework/Platform/SDL2/SDL2Window.cs b/osu.Framework/Platform/SDL2/SDL2Window.cs index 7a62f84d7c..1efa878477 100644 --- a/osu.Framework/Platform/SDL2/SDL2Window.cs +++ b/osu.Framework/Platform/SDL2/SDL2Window.cs @@ -165,6 +165,8 @@ internal SDL_SysWMinfo GetWindowSystemInformation() public bool CapsLockPressed => SDL_GetModState().HasFlagFast(SDL_Keymod.KMOD_CAPS); + public bool KeyboardAttached => true; // SDL2 has no way of knowing whether a keyboard is attached, assume true. + // references must be kept to avoid GC, see https://stackoverflow.com/a/6193914 [UsedImplicitly] diff --git a/osu.Framework/Platform/SDL3/SDL3Window.cs b/osu.Framework/Platform/SDL3/SDL3Window.cs index 5944581b10..62b9594bf9 100644 --- a/osu.Framework/Platform/SDL3/SDL3Window.cs +++ b/osu.Framework/Platform/SDL3/SDL3Window.cs @@ -145,6 +145,8 @@ public IntPtr DisplayHandle public bool CapsLockPressed => SDL_GetModState().HasFlagFast(SDL_Keymod.SDL_KMOD_CAPS); + public bool KeyboardAttached => SDL_HasKeyboard(); + /// /// Represents a handle to this instance, used for unmanaged callbacks. /// diff --git a/osu.Framework/Platform/SDLGameHost.cs b/osu.Framework/Platform/SDLGameHost.cs index 41e237db9b..042a7fc9a9 100644 --- a/osu.Framework/Platform/SDLGameHost.cs +++ b/osu.Framework/Platform/SDLGameHost.cs @@ -20,6 +20,8 @@ public abstract class SDLGameHost : GameHost { public override bool CapsLockEnabled => (Window as ISDLWindow)?.CapsLockPressed == true; + public override bool OnScreenKeyboardOverlapsGameWindow => (Window as ISDLWindow)?.KeyboardAttached == false; + protected SDLGameHost(string gameName, HostOptions? options = null) : base(gameName, options) {