Skip to content

Commit

Permalink
Move on-screen keyboard check to SDLGameHost
Browse files Browse the repository at this point in the history
  • Loading branch information
frenzibyte committed Nov 9, 2024
1 parent 141f9b0 commit 456b586
Show file tree
Hide file tree
Showing 6 changed files with 7 additions and 4 deletions.
3 changes: 0 additions & 3 deletions osu.Framework.iOS/IOSGameHost.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
using System.Collections.Generic;
using System.IO;
using Foundation;
using GameController;
using osu.Framework.Configuration;
using osu.Framework.Extensions;
using osu.Framework.Extensions.ObjectExtensions;
Expand Down Expand Up @@ -39,8 +38,6 @@ protected override void SetupConfig(IDictionary<FrameworkSetting, object> defaul
base.SetupConfig(defaultOverrides);
}

public override bool OnScreenKeyboardOverlapsGameWindow => !OperatingSystem.IsIOSVersionAtLeast(14) || GCKeyboard.CoalescedKeyboard == null;

public override bool CanExit => false;

public override Storage GetStorage(string path) => new IOSStorage(path, this);
Expand Down
1 change: 0 additions & 1 deletion osu.Framework.iOS/IOSWindow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
1 change: 1 addition & 0 deletions osu.Framework/Platform/ISDLWindow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
2 changes: 2 additions & 0 deletions osu.Framework/Platform/SDL2/SDL2Window.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
2 changes: 2 additions & 0 deletions osu.Framework/Platform/SDL3/SDL3Window.cs
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,8 @@ public IntPtr DisplayHandle

public bool CapsLockPressed => SDL_GetModState().HasFlagFast(SDL_Keymod.SDL_KMOD_CAPS);

public bool KeyboardAttached => SDL_HasKeyboard();

/// <summary>
/// Represents a handle to this <see cref="SDL3Window"/> instance, used for unmanaged callbacks.
/// </summary>
Expand Down
2 changes: 2 additions & 0 deletions osu.Framework/Platform/SDLGameHost.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down

0 comments on commit 456b586

Please sign in to comment.