mirror of
https://github.com/SK-la/osu-framework.git
synced 2026-03-13 11:20:31 +00:00
Target iOS 13.4 and remove no longer used logic
This commit is contained in:
@@ -3,7 +3,6 @@
|
||||
|
||||
#nullable disable
|
||||
|
||||
using osu.Framework.iOS;
|
||||
using UIKit;
|
||||
|
||||
namespace SampleGame.iOS
|
||||
@@ -13,9 +12,7 @@ namespace SampleGame.iOS
|
||||
// This is the main entry point of the application.
|
||||
public static void Main(string[] args)
|
||||
{
|
||||
// if you want to use a different Application Delegate class from "AppDelegate"
|
||||
// you can specify it here.
|
||||
UIApplication.Main(args, typeof(GameUIApplication), typeof(AppDelegate));
|
||||
UIApplication.Main(args, null, typeof(AppDelegate));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
<key>LSRequiresIPhoneOS</key>
|
||||
<true/>
|
||||
<key>MinimumOSVersion</key>
|
||||
<string>11.0</string>
|
||||
<string>13.4</string>
|
||||
<key>UIDeviceFamily</key>
|
||||
<array>
|
||||
<integer>1</integer>
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
<PropertyGroup>
|
||||
<OutputType>Exe</OutputType>
|
||||
<TargetFramework>net6.0-ios</TargetFramework>
|
||||
<SupportedOSPlatformVersion>11.0</SupportedOSPlatformVersion>
|
||||
<SupportedOSPlatformVersion>13.4</SupportedOSPlatformVersion>
|
||||
</PropertyGroup>
|
||||
<Import Project="..\osu.Framework.iOS.props" />
|
||||
<ItemGroup>
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
||||
// See the LICENCE file in the repository root for full licence text.
|
||||
|
||||
using osu.Framework.iOS;
|
||||
using UIKit;
|
||||
|
||||
namespace TemplateGame.iOS
|
||||
@@ -10,7 +9,7 @@ namespace TemplateGame.iOS
|
||||
{
|
||||
public static void Main(string[] args)
|
||||
{
|
||||
UIApplication.Main(args, typeof(GameUIApplication), typeof(AppDelegate));
|
||||
UIApplication.Main(args, null, typeof(AppDelegate));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
<key>LSRequiresIPhoneOS</key>
|
||||
<true/>
|
||||
<key>MinimumOSVersion</key>
|
||||
<string>11.0</string>
|
||||
<string>13.4</string>
|
||||
<key>UIDeviceFamily</key>
|
||||
<array>
|
||||
<integer>1</integer>
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
<PropertyGroup>
|
||||
<OutputType>Exe</OutputType>
|
||||
<TargetFramework>net6.0-ios</TargetFramework>
|
||||
<SupportedOSPlatformVersion>11.0</SupportedOSPlatformVersion>
|
||||
<SupportedOSPlatformVersion>13.4</SupportedOSPlatformVersion>
|
||||
<CodesignKey>iPhone Developer</CodesignKey>
|
||||
</PropertyGroup>
|
||||
<Import Project="..\..\..\..\osu.Framework.iOS.props" />
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
using osu.Framework.iOS;
|
||||
using UIKit;
|
||||
using UIKit;
|
||||
|
||||
namespace FlappyDon.iOS
|
||||
{
|
||||
@@ -7,7 +6,7 @@ namespace FlappyDon.iOS
|
||||
{
|
||||
public static void Main(string[] args)
|
||||
{
|
||||
UIApplication.Main(args, typeof(GameUIApplication), typeof(AppDelegate));
|
||||
UIApplication.Main(args, null, typeof(AppDelegate));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
<PropertyGroup>
|
||||
<OutputType>Exe</OutputType>
|
||||
<TargetFramework>net6.0-ios</TargetFramework>
|
||||
<SupportedOSPlatformVersion>11.0</SupportedOSPlatformVersion>
|
||||
<SupportedOSPlatformVersion>13.4</SupportedOSPlatformVersion>
|
||||
<CodesignKey>iPhone Developer</CodesignKey>
|
||||
</PropertyGroup>
|
||||
<Import Project="..\..\..\..\osu.Framework.iOS.props" />
|
||||
|
||||
@@ -43,7 +43,7 @@
|
||||
<string>UIInterfaceOrientationLandscapeRight</string>
|
||||
</array>
|
||||
<key>MinimumOSVersion</key>
|
||||
<string>11.0</string>
|
||||
<string>13.4</string>
|
||||
<key>UIApplicationSupportsIndirectInputEvents</key>
|
||||
<true/>
|
||||
<key>CADisableMinimumFrameDurationOnPhone</key>
|
||||
|
||||
@@ -3,7 +3,6 @@
|
||||
|
||||
#nullable disable
|
||||
|
||||
using osu.Framework.iOS;
|
||||
using UIKit;
|
||||
|
||||
namespace osu.Framework.Tests
|
||||
@@ -13,9 +12,7 @@ namespace osu.Framework.Tests
|
||||
// This is the main entry point of the application.
|
||||
public static void Main(string[] args)
|
||||
{
|
||||
// if you want to use a different Application Delegate class from "AppDelegate"
|
||||
// you can specify it here.
|
||||
UIApplication.Main(args, typeof(GameUIApplication), typeof(AppDelegate));
|
||||
UIApplication.Main(args, null, typeof(AppDelegate));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
<key>LSRequiresIPhoneOS</key>
|
||||
<true/>
|
||||
<key>MinimumOSVersion</key>
|
||||
<string>11.0</string>
|
||||
<string>13.4</string>
|
||||
<key>UIDeviceFamily</key>
|
||||
<array>
|
||||
<integer>1</integer>
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
<PropertyGroup>
|
||||
<OutputType>Exe</OutputType>
|
||||
<TargetFramework>net6.0-ios</TargetFramework>
|
||||
<SupportedOSPlatformVersion>11.0</SupportedOSPlatformVersion>
|
||||
<SupportedOSPlatformVersion>13.4</SupportedOSPlatformVersion>
|
||||
<RootNamespace>osu.Framework.Tests</RootNamespace>
|
||||
<AssemblyName>osu.Framework.Tests</AssemblyName>
|
||||
</PropertyGroup>
|
||||
|
||||
@@ -1,74 +0,0 @@
|
||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
||||
// See the LICENCE file in the repository root for full licence text.
|
||||
|
||||
#nullable disable
|
||||
|
||||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
using Foundation;
|
||||
using ObjCRuntime;
|
||||
using UIKit;
|
||||
|
||||
namespace osu.Framework.iOS
|
||||
{
|
||||
[Register("GameUIApplication")]
|
||||
public class GameUIApplication : UIApplication
|
||||
{
|
||||
private const int gsevent_type = 2;
|
||||
private const int gsevent_flags = 10;
|
||||
|
||||
private const int gsevent_keycode = 13;
|
||||
|
||||
private const int gsevent_type_keydown = 10;
|
||||
private const int gsevent_type_keyup = 11;
|
||||
private const int gsevent_type_modifier = 12;
|
||||
|
||||
public delegate void GsKeyEventHandler(int keyCode, bool isDown);
|
||||
|
||||
public event GsKeyEventHandler HandleGsKeyEvent;
|
||||
|
||||
// https://github.com/xamarin/xamarin-macios/blob/master/src/ObjCRuntime/Messaging.iOS.cs
|
||||
[DllImport("/usr/lib/libobjc.dylib", EntryPoint = "objc_msgSendSuper")]
|
||||
private static extern void send_super(IntPtr receiver, IntPtr selector, IntPtr arg1);
|
||||
|
||||
private int lastEventFlags;
|
||||
|
||||
private unsafe void decodeKeyEvent(NSObject eventMem)
|
||||
{
|
||||
if (eventMem == null) return;
|
||||
|
||||
var eventPtr = (IntPtr*)eventMem.Handle.Handle.ToPointer();
|
||||
|
||||
int eventType = (int)eventPtr[gsevent_type];
|
||||
int eventModifier = (int)eventPtr[gsevent_flags];
|
||||
int eventScanCode = (int)eventPtr[gsevent_keycode];
|
||||
int eventLastModifier = lastEventFlags;
|
||||
|
||||
switch (eventType)
|
||||
{
|
||||
case gsevent_type_keydown:
|
||||
case gsevent_type_keyup:
|
||||
HandleGsKeyEvent?.Invoke(eventScanCode, eventType == gsevent_type_keydown);
|
||||
break;
|
||||
|
||||
case gsevent_type_modifier:
|
||||
HandleGsKeyEvent?.Invoke(eventScanCode, eventModifier != 0 && eventModifier > eventLastModifier);
|
||||
lastEventFlags = eventModifier;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
private readonly Selector gsSelector = new Selector("_gsEvent");
|
||||
private readonly Selector handleSelector = new Selector("handleKeyUIEvent:");
|
||||
|
||||
[Export("handleKeyUIEvent:")]
|
||||
private void handleKeyUIEvent(UIEvent evt)
|
||||
{
|
||||
send_super(SuperHandle, handleSelector.Handle, evt.Handle);
|
||||
|
||||
// On later iOS versions, hardware keyboard events are handled from UIPressesEvents instead.
|
||||
if (!UIDevice.CurrentDevice.CheckSystemVersion(13, 4) && evt.RespondsToSelector(gsSelector))
|
||||
decodeKeyEvent(evt.PerformSelector(gsSelector));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -73,28 +73,19 @@ namespace osu.Framework.iOS
|
||||
public override void PressesBegan(NSSet<UIPress> presses, UIPressesEvent evt)
|
||||
{
|
||||
base.PressesBegan(presses, evt);
|
||||
|
||||
// On early iOS versions, hardware keyboard events are handled from GSEvents in GameUIApplication instead.
|
||||
if (UIDevice.CurrentDevice.CheckSystemVersion(13, 4))
|
||||
HandlePresses?.Invoke(presses, evt);
|
||||
HandlePresses?.Invoke(presses, evt);
|
||||
}
|
||||
|
||||
public override void PressesCancelled(NSSet<UIPress> presses, UIPressesEvent evt)
|
||||
{
|
||||
base.PressesCancelled(presses, evt);
|
||||
|
||||
// On early iOS versions, hardware keyboard events are handled from GSEvents in GameUIApplication instead.
|
||||
if (UIDevice.CurrentDevice.CheckSystemVersion(13, 4))
|
||||
HandlePresses?.Invoke(presses, evt);
|
||||
HandlePresses?.Invoke(presses, evt);
|
||||
}
|
||||
|
||||
public override void PressesEnded(NSSet<UIPress> presses, UIPressesEvent evt)
|
||||
{
|
||||
base.PressesEnded(presses, evt);
|
||||
|
||||
// On early iOS versions, hardware keyboard events are handled from GSEvents in GameUIApplication instead.
|
||||
if (UIDevice.CurrentDevice.CheckSystemVersion(13, 4))
|
||||
HandlePresses?.Invoke(presses, evt);
|
||||
HandlePresses?.Invoke(presses, evt);
|
||||
}
|
||||
|
||||
public override void TouchesBegan(NSSet touches, UIEvent evt) => HandleTouches?.Invoke(touches, evt);
|
||||
|
||||
@@ -15,7 +15,6 @@ namespace osu.Framework.iOS.Input
|
||||
{
|
||||
public class IOSHardwareKeyboardHandler : InputHandler
|
||||
{
|
||||
private readonly GameUIApplication application;
|
||||
private readonly IOSGameView view;
|
||||
private IOSGameHost host;
|
||||
|
||||
@@ -24,8 +23,6 @@ namespace osu.Framework.iOS.Input
|
||||
public IOSHardwareKeyboardHandler(IOSGameView view)
|
||||
{
|
||||
this.view = view;
|
||||
|
||||
application = (GameUIApplication)UIApplication.SharedApplication;
|
||||
}
|
||||
|
||||
public override bool Initialize(GameHost host)
|
||||
@@ -33,7 +30,6 @@ namespace osu.Framework.iOS.Input
|
||||
this.host = (IOSGameHost)host;
|
||||
|
||||
view.HandlePresses += handlePresses;
|
||||
application.HandleGsKeyEvent += handleGsKeyEvent;
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -68,30 +64,9 @@ namespace osu.Framework.iOS.Input
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Handles GSEvents and enqueues corresponding <see cref="KeyboardKeyInput"/>s.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// This is still existing as an alternative to <see cref="handlePresses"/>
|
||||
/// for early iOS versions in which <see cref="UIPress.Key"/> is unavailable.
|
||||
/// </remarks>
|
||||
private void handleGsKeyEvent(int keyCode, bool isDown)
|
||||
{
|
||||
if (!IsActive)
|
||||
return;
|
||||
|
||||
var key = keyFromCode((UIKeyboardHidUsage)keyCode);
|
||||
if (key == Key.Unknown || host.TextFieldHandler.Handled(key))
|
||||
return;
|
||||
|
||||
PendingInputs.Enqueue(new KeyboardKeyInput(key, isDown));
|
||||
}
|
||||
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
view.HandlePresses -= handlePresses;
|
||||
application.HandleGsKeyEvent -= handleGsKeyEvent;
|
||||
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
|
||||
@@ -38,10 +38,6 @@ namespace osu.Framework.iOS.Input
|
||||
|
||||
public override bool Initialize(GameHost host)
|
||||
{
|
||||
// UIPointerInteraction is only available on iOS 13.4 and up
|
||||
if (!UIDevice.CurrentDevice.CheckSystemVersion(13, 4))
|
||||
return false;
|
||||
|
||||
view.AddInteraction(pointerInteraction = new UIPointerInteraction(mouseDelegate = new IOSMouseDelegate()));
|
||||
mouseDelegate.LocationUpdated += locationUpdated;
|
||||
|
||||
|
||||
@@ -22,8 +22,6 @@ namespace osu.Framework.iOS.Input
|
||||
|
||||
private UIEventButtonMask? lastButtonMask;
|
||||
|
||||
private readonly bool indirectPointerSupported = UIDevice.CurrentDevice.CheckSystemVersion(13, 4);
|
||||
|
||||
private readonly UITouch[] activeTouches = new UITouch[TouchState.MAX_TOUCH_COUNT];
|
||||
|
||||
public IOSTouchHandler(IOSGameView view)
|
||||
@@ -43,7 +41,7 @@ namespace osu.Framework.iOS.Input
|
||||
var cgLocation = touch.LocationInView(null);
|
||||
Vector2 location = new Vector2((float)cgLocation.X * view.Scale, (float)cgLocation.Y * view.Scale);
|
||||
|
||||
if (indirectPointerSupported && touch.Type == UITouchType.IndirectPointer)
|
||||
if (touch.Type == UITouchType.IndirectPointer)
|
||||
handleIndirectPointer(touch, e.ButtonMask, location);
|
||||
else
|
||||
handleTouch(touch, location);
|
||||
@@ -141,8 +139,6 @@ namespace osu.Framework.iOS.Input
|
||||
|
||||
private MouseButton buttonFromMask(UIEventButtonMask buttonMask)
|
||||
{
|
||||
Debug.Assert(indirectPointerSupported);
|
||||
|
||||
switch (buttonMask)
|
||||
{
|
||||
default:
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
<PropertyGroup Label="Project">
|
||||
<TargetFramework>net6.0-ios</TargetFramework>
|
||||
<SupportedOSPlatformVersion>11.0</SupportedOSPlatformVersion>
|
||||
<SupportedOSPlatformVersion>13.4</SupportedOSPlatformVersion>
|
||||
<OutputType>Library</OutputType>
|
||||
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
||||
<AssemblyTitle>osu!framework iOS</AssemblyTitle>
|
||||
|
||||
Reference in New Issue
Block a user