mirror of
https://github.com/libretro/RetroArch
synced 2025-01-30 03:32:46 +00:00
iOS: Add @available tags to enable compilation back to iOS 12 (#16969)
This commit is contained in:
parent
17fefa7891
commit
e34b57fd97
@ -16,6 +16,7 @@ protocol HelperBarActionDelegate: AnyObject {
|
||||
var isOrientationLocked: Bool { get }
|
||||
}
|
||||
|
||||
@available(iOS 13, *)
|
||||
extension CocoaView {
|
||||
@objc func setupHelperBar() {
|
||||
let helperVC = HelperBarViewController()
|
||||
@ -34,6 +35,7 @@ extension CocoaView {
|
||||
}
|
||||
}
|
||||
|
||||
@available(iOS 13, *)
|
||||
extension CocoaView: HelperBarActionDelegate {
|
||||
func keyboardButtonTapped() {
|
||||
toggleCustomKeyboard()
|
||||
|
@ -6,6 +6,7 @@
|
||||
// Copyright © 2022 RetroArch. All rights reserved.
|
||||
//
|
||||
|
||||
@available(iOS 13, *)
|
||||
protocol HelperBarItem {
|
||||
var image: UIImage? { get }
|
||||
var selectedImage: UIImage? { get }
|
||||
@ -16,10 +17,12 @@ protocol HelperBarItem {
|
||||
func action()
|
||||
}
|
||||
|
||||
@available(iOS 13, *)
|
||||
extension HelperBarItem {
|
||||
var tintColorOnSelection: UIColor? { nil }
|
||||
}
|
||||
|
||||
@available(iOS 13, *)
|
||||
struct KeyboardBarItem: HelperBarItem {
|
||||
let image = UIImage(systemName: "keyboard")
|
||||
let selectedImage = UIImage(systemName: "keyboard.fill")
|
||||
@ -42,6 +45,7 @@ struct KeyboardBarItem: HelperBarItem {
|
||||
}
|
||||
}
|
||||
|
||||
@available(iOS 13, *)
|
||||
struct MouseBarItem: HelperBarItem {
|
||||
let image = UIImage(systemName: "computermouse")
|
||||
let selectedImage = UIImage(systemName: "computermouse.fill")
|
||||
@ -59,6 +63,7 @@ struct MouseBarItem: HelperBarItem {
|
||||
}
|
||||
}
|
||||
|
||||
@available(iOS 13, *)
|
||||
struct LockOrientationBarItem: HelperBarItem {
|
||||
let image = UIImage(systemName: "lock.rotation")
|
||||
let selectedImage = UIImage(systemName: "lock.rotation")
|
||||
|
@ -6,6 +6,7 @@
|
||||
// Copyright © 2022 RetroArch. All rights reserved.
|
||||
//
|
||||
|
||||
@available(iOS 13, *)
|
||||
class HelperBarViewController: UIViewController {
|
||||
var viewModel = HelperBarViewModel()
|
||||
|
||||
@ -137,12 +138,14 @@ class HelperBarViewController: UIViewController {
|
||||
}
|
||||
}
|
||||
|
||||
@available(iOS 13, *)
|
||||
extension HelperBarViewController: UIGestureRecognizerDelegate {
|
||||
func gestureRecognizer(_ gestureRecognizer: UIGestureRecognizer, shouldRecognizeSimultaneouslyWith otherGestureRecognizer: UIGestureRecognizer) -> Bool {
|
||||
true
|
||||
}
|
||||
}
|
||||
|
||||
@available(iOS 13, *)
|
||||
extension HelperBarViewController: HelperBarViewModelDelegate {
|
||||
func setNavigationBarHidden(_ isHidden: Bool) {
|
||||
navigationBar.isHidden = isHidden
|
||||
@ -152,6 +155,7 @@ extension HelperBarViewController: HelperBarViewModelDelegate {
|
||||
}
|
||||
}
|
||||
|
||||
@available(iOS 13, *)
|
||||
extension HelperBarViewController: UINavigationBarDelegate {
|
||||
func position(for bar: UIBarPositioning) -> UIBarPosition {
|
||||
return .topAttached
|
||||
|
@ -8,11 +8,13 @@
|
||||
|
||||
import Combine
|
||||
|
||||
@available(iOS 13, *)
|
||||
protocol HelperBarViewModelDelegate: AnyObject {
|
||||
func setNavigationBarHidden(_ isHidden: Bool)
|
||||
func updateNavigationBarItems()
|
||||
}
|
||||
|
||||
@available(iOS 13, *)
|
||||
class HelperBarViewModel {
|
||||
@Published var didInteractWithBar = false
|
||||
private var cancellable: AnyCancellable?
|
||||
|
@ -7,6 +7,7 @@
|
||||
//
|
||||
|
||||
extension CocoaView {
|
||||
@available(iOS 13, *)
|
||||
@objc func setupMouseSupport() {
|
||||
mouseHandler = EmulatorTouchMouseHandler(view: view, delegate: self as? EmulatorTouchMouseHandlerDelegate)
|
||||
}
|
||||
|
@ -19,11 +19,13 @@
|
||||
import Combine
|
||||
import UIKit
|
||||
|
||||
@available(iOS 13, *)
|
||||
@objc public protocol EmulatorTouchMouseHandlerDelegate: AnyObject {
|
||||
func handleMouseClick(isLeftClick: Bool, isPressed: Bool)
|
||||
func handleMouseMove(x: CGFloat, y: CGFloat)
|
||||
}
|
||||
|
||||
@available(iOS 13, *)
|
||||
@objcMembers public class EmulatorTouchMouseHandler: NSObject, UIPointerInteractionDelegate {
|
||||
enum MouseHoldState {
|
||||
case notHeld, wait, held
|
||||
|
@ -8,6 +8,7 @@
|
||||
|
||||
import Foundation
|
||||
|
||||
@available(iOS 13, *)
|
||||
extension CocoaView {
|
||||
var leftKeyboardModel: EmulatorKeyboardViewModel {
|
||||
return EmulatorKeyboardViewModel(keys: [
|
||||
@ -173,6 +174,7 @@ extension CocoaView {
|
||||
}
|
||||
}
|
||||
|
||||
@available(iOS 13, *)
|
||||
extension CocoaView: EmulatorKeyboardKeyPressedDelegate {
|
||||
func keyUp(_ key: KeyCoded) {
|
||||
print("keyUp: code=\(key.keyCode) keyboardModifierState = \(keyboardModifierState)")
|
||||
@ -185,6 +187,7 @@ extension CocoaView: EmulatorKeyboardKeyPressedDelegate {
|
||||
}
|
||||
}
|
||||
|
||||
@available(iOS 13, *)
|
||||
extension CocoaView: EmulatorKeyboardModifierPressedDelegate {
|
||||
func modifierPressedWithKey(_ key: KeyCoded, enable: Bool) {
|
||||
switch UInt32(key.keyCode) {
|
||||
|
@ -6,11 +6,13 @@
|
||||
// Copyright © 2022 RetroArch. All rights reserved.
|
||||
//
|
||||
|
||||
@available(iOS 13, *)
|
||||
@objc enum KeySize: Int {
|
||||
case standard = 1, wide, wider
|
||||
}
|
||||
|
||||
// represents a key that has an underlying code that gets sent to the emulator
|
||||
@available(iOS 13, *)
|
||||
@objc protocol KeyCoded: AnyObject {
|
||||
var keyLabel: String { get }
|
||||
var keyImageName: String? { get }
|
||||
@ -20,10 +22,12 @@
|
||||
var isModifier: Bool { get }
|
||||
}
|
||||
|
||||
@available(iOS 13, *)
|
||||
protocol KeyRowsDataSource {
|
||||
func keyForPositionAt(_ position: KeyPosition) -> KeyCoded?
|
||||
}
|
||||
|
||||
@available(iOS 13, *)
|
||||
@objc class EmulatorKeyboardKey: NSObject, KeyCoded {
|
||||
let keyLabel: String
|
||||
var keyImageName: String?
|
||||
@ -45,6 +49,7 @@ protocol KeyRowsDataSource {
|
||||
}
|
||||
}
|
||||
|
||||
@available(iOS 13, *)
|
||||
class SpacerKey: KeyCoded {
|
||||
let keyLabel = ""
|
||||
let keyCode = 0
|
||||
@ -57,6 +62,7 @@ class SpacerKey: KeyCoded {
|
||||
}
|
||||
}
|
||||
|
||||
@available(iOS 13, *)
|
||||
class SliderKey: KeyCoded {
|
||||
let keyLabel = ""
|
||||
let keyCode = 0
|
||||
|
@ -8,6 +8,7 @@
|
||||
|
||||
import UIKit
|
||||
|
||||
@available(iOS 13, *)
|
||||
class EmulatorKeyboardButton: UIButton {
|
||||
let key: KeyCoded
|
||||
var toggleState = false
|
||||
|
@ -7,22 +7,26 @@
|
||||
// TODO: shift key should change the label of the keys to uppercase (need callback mechanism?)
|
||||
// pan gesture to outer edges of keyboard view for better dragging
|
||||
|
||||
@available(iOS 13, *)
|
||||
@objc protocol EmulatorKeyboardKeyPressedDelegate: AnyObject {
|
||||
func keyDown(_ key: KeyCoded)
|
||||
func keyUp(_ key: KeyCoded)
|
||||
}
|
||||
|
||||
@available(iOS 13, *)
|
||||
@objc protocol EmulatorKeyboardModifierPressedDelegate: AnyObject {
|
||||
func modifierPressedWithKey(_ key: KeyCoded, enable: Bool)
|
||||
func isModifierEnabled(key: KeyCoded) -> Bool
|
||||
}
|
||||
|
||||
@available(iOS 13, *)
|
||||
protocol EmulatorKeyboardViewDelegate: AnyObject {
|
||||
func toggleAlternateKeys()
|
||||
func refreshModifierStates()
|
||||
func updateTransparency(toAlpha alpha: Float)
|
||||
}
|
||||
|
||||
@available(iOS 13, *)
|
||||
class EmulatorKeyboardView: UIView {
|
||||
|
||||
static var keyboardBackgroundColor = UIColor.systemGray6.withAlphaComponent(0.5)
|
||||
@ -273,6 +277,7 @@ class EmulatorKeyboardView: UIView {
|
||||
}
|
||||
}
|
||||
|
||||
@available(iOS 13, *)
|
||||
extension UIImage {
|
||||
static func dot(size:CGSize, color:UIColor) -> UIImage {
|
||||
return UIGraphicsImageRenderer(size: size).image { context in
|
||||
|
@ -6,6 +6,7 @@
|
||||
// Copyright © 2022 RetroArch. All rights reserved.
|
||||
//
|
||||
|
||||
@available(iOS 13, *)
|
||||
@objc class EmulatorKeyboardController: UIViewController {
|
||||
|
||||
class EmulatorKeyboardPassthroughView: UIView {
|
||||
@ -118,6 +119,7 @@
|
||||
}
|
||||
}
|
||||
|
||||
@available(iOS 13, *)
|
||||
extension EmulatorKeyboardController: EmulatorKeyboardViewDelegate {
|
||||
func toggleAlternateKeys() {
|
||||
for keyboard in [leftKeyboardView, rightKeyboardView] {
|
||||
|
@ -6,11 +6,13 @@
|
||||
// Copyright © 2022 RetroArch. All rights reserved.
|
||||
//
|
||||
|
||||
@available(iOS 13, *)
|
||||
struct KeyPosition {
|
||||
let row: Int
|
||||
let column: Int
|
||||
}
|
||||
|
||||
@available(iOS 13, *)
|
||||
@objc class EmulatorKeyboardViewModel: NSObject, KeyRowsDataSource {
|
||||
var keys = [[KeyCoded]]()
|
||||
var alternateKeys: [[KeyCoded]]?
|
||||
|
@ -1795,7 +1795,7 @@
|
||||
ASSETCATALOG_COMPILER_INCLUDE_ALL_APPICON_ASSETS = YES;
|
||||
CODE_SIGN_ENTITLEMENTS = "$(IOS_CODE_SIGN_ENTITLEMENTS)";
|
||||
INFOPLIST_FILE = "$(SRCROOT)/iOS/Info.plist";
|
||||
IPHONEOS_DEPLOYMENT_TARGET = "$(RA_IPHONEOS_DEPLOYMENT_TARGET:default=13.0)";
|
||||
IPHONEOS_DEPLOYMENT_TARGET = "$(RA_IPHONEOS_DEPLOYMENT_TARGET:default=12.0)";
|
||||
LD_RUNPATH_SEARCH_PATHS = (
|
||||
"$(inherited)",
|
||||
"@executable_path/Frameworks",
|
||||
@ -1815,7 +1815,7 @@
|
||||
ASSETCATALOG_COMPILER_INCLUDE_ALL_APPICON_ASSETS = YES;
|
||||
CODE_SIGN_ENTITLEMENTS = "$(IOS_CODE_SIGN_ENTITLEMENTS)";
|
||||
INFOPLIST_FILE = "$(SRCROOT)/iOS/Info.plist";
|
||||
IPHONEOS_DEPLOYMENT_TARGET = "$(RA_IPHONEOS_DEPLOYMENT_TARGET:default=13.0)";
|
||||
IPHONEOS_DEPLOYMENT_TARGET = "$(RA_IPHONEOS_DEPLOYMENT_TARGET:default=12.0)";
|
||||
LD_RUNPATH_SEARCH_PATHS = (
|
||||
"$(inherited)",
|
||||
"@executable_path/Frameworks",
|
||||
|
Loading…
x
Reference in New Issue
Block a user