diff --git a/CGame.xcworkspace/xcuserdata/aaa.xcuserdatad/UserInterfaceState.xcuserstate b/CGame.xcworkspace/xcuserdata/aaa.xcuserdatad/UserInterfaceState.xcuserstate index 7bd3c06c..21845586 100644 Binary files a/CGame.xcworkspace/xcuserdata/aaa.xcuserdatad/UserInterfaceState.xcuserstate and b/CGame.xcworkspace/xcuserdata/aaa.xcuserdatad/UserInterfaceState.xcuserstate differ diff --git a/CGame/AppDelegate.swift b/CGame/AppDelegate.swift index 119c9b96..95cf911a 100644 --- a/CGame/AppDelegate.swift +++ b/CGame/AppDelegate.swift @@ -40,7 +40,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate self.configureAppearance() // Controllers - ExternalGameControllerManager.shared.startMonitoring() + ELUxGameControllerManager.shared.startMonitoring() // JIT ServerManager.shared.prepare() diff --git a/CGame/Emulation/GameViewController.swift b/CGame/Emulation/GameViewController.swift index 60d91a1a..3c3ad1f9 100644 --- a/CGame/Emulation/GameViewController.swift +++ b/CGame/Emulation/GameViewController.swift @@ -607,14 +607,14 @@ private extension GameViewController { @objc func updateControllers() { - let isExternalGameControllerConnected = ExternalGameControllerManager.shared.connectedControllers.contains(where: { $0.playerIndex != nil }) + let isExternalGameControllerConnected = ELUxGameControllerManager.shared.connectedControllers.contains(where: { $0.playerIndex != nil }) if !isExternalGameControllerConnected && Settings.localControllerPlayerIndex == nil { Settings.localControllerPlayerIndex = 0 } // If Settings.localControllerPlayerIndex is non-nil, and there isn't a connected controller with same playerIndex, show controller view. - if let index = Settings.localControllerPlayerIndex, !ExternalGameControllerManager.shared.connectedControllers.contains(where: { $0.playerIndex == index }) + if let index = Settings.localControllerPlayerIndex, !ELUxGameControllerManager.shared.connectedControllers.contains(where: { $0.playerIndex == index }) { self.controllerView.playerIndex = index self.controllerView.isHidden = false @@ -644,7 +644,7 @@ private extension GameViewController // Roundabout way of combining arrays to prevent rare runtime crash in + operator :( var controllers = [GameController]() controllers.append(self.controllerView) - controllers.append(contentsOf: ExternalGameControllerManager.shared.connectedControllers) + controllers.append(contentsOf: ELUxGameControllerManager.shared.connectedControllers) if let emulatorCore = self.emulatorCore, let game = self.game { diff --git a/CGame/Settings/Controllers/ControllersSettingsViewController.swift b/CGame/Settings/Controllers/ControllersSettingsViewController.swift index b0b22386..060d341e 100644 --- a/CGame/Settings/Controllers/ControllersSettingsViewController.swift +++ b/CGame/Settings/Controllers/ControllersSettingsViewController.swift @@ -57,7 +57,7 @@ class ControllersSettingsViewController: UITableViewController else { // Ensure it's still a discovered controller, or else it might crash when setting player index. - if ExternalGameControllerManager.shared.connectedControllers.contains(where: { $0 === oldValue }) + if ELUxGameControllerManager.shared.connectedControllers.contains(where: { $0 === oldValue }) { oldValue?.playerIndex = nil } @@ -67,7 +67,7 @@ class ControllersSettingsViewController: UITableViewController } } - private var connectedControllers = ExternalGameControllerManager.shared.connectedControllers.sorted(by: { $0.playerIndex ?? NSIntegerMax < $1.playerIndex ?? NSIntegerMax }) + private var connectedControllers = ELUxGameControllerManager.shared.connectedControllers.sorted(by: { $0.playerIndex ?? NSIntegerMax < $1.playerIndex ?? NSIntegerMax }) private lazy var localDeviceController: LocalDeviceController = { let device = LocalDeviceController() diff --git a/CGame/Settings/SettingsViewController.swift b/CGame/Settings/SettingsViewController.swift index a192653e..18c9290f 100644 --- a/CGame/Settings/SettingsViewController.swift +++ b/CGame/Settings/SettingsViewController.swift @@ -431,9 +431,9 @@ extension SettingsViewController // { // cell.detailTextLabel?.text = UIDevice.current.name // } -// else if let index = ExternalGameControllerManager.shared.connectedControllers.firstIndex(where: { $0.playerIndex == indexPath.row }) +// else if let index = ELUxGameControllerManager.shared.connectedControllers.firstIndex(where: { $0.playerIndex == indexPath.row }) // { -// let controller = ExternalGameControllerManager.shared.connectedControllers[index] +// let controller = ELUxGameControllerManager.shared.connectedControllers[index] // cell.detailTextLabel?.text = controller.name // } // else diff --git a/Cores/DeltaCore/DeltaCore/Game Controllers/ExternalGameControllerManager.swift b/Cores/DeltaCore/DeltaCore/Game Controllers/ExternalGameControllerManager.swift index 98cef4ba..01b66138 100644 --- a/Cores/DeltaCore/DeltaCore/Game Controllers/ExternalGameControllerManager.swift +++ b/Cores/DeltaCore/DeltaCore/Game Controllers/ExternalGameControllerManager.swift @@ -1,5 +1,5 @@ // -// ExternalGameControllerManager.swift +// ELUxGameControllerManager.swift // HthikCore // // Created by Hthik on 8/20/15. @@ -12,7 +12,7 @@ import GameController private let ExternalKeyboardStatusDidChange: @convention(c) (CFNotificationCenter?, UnsafeMutableRawPointer?, CFNotificationName?, UnsafeRawPointer?, CFDictionary?) -> Void = { (notificationCenter, observer, name, object, userInfo) in - if ExternalGameControllerManager.shared.isKeyboardConnected + if ELUxGameControllerManager.shared.isKeyboardConnected { NotificationCenter.default.post(name: .externalKeyboardDidConnect, object: nil) } @@ -33,9 +33,9 @@ public extension Notification.Name static let externalKeyboardDidDisconnect = Notification.Name("ExternalKeyboardDidDisconnect") } -public class ExternalGameControllerManager: UIResponder +public class ELUxGameControllerManager: UIResponder { - public static let shared = ExternalGameControllerManager() + public static let shared = ELUxGameControllerManager() //MARK: - Properties - /** Properties **/ @@ -86,7 +86,7 @@ public class ExternalGameControllerManager: UIResponder //MARK: - Discovery - /** Discovery **/ -public extension ExternalGameControllerManager +public extension ELUxGameControllerManager { //启动监视 func startMonitoring() @@ -105,20 +105,20 @@ public extension ExternalGameControllerManager } //控制器已连接 - NotificationCenter.default.addObserver(self, selector: #selector(ExternalGameControllerManager.mfiGameControllerDidConnect(_:)), name: .GCControllerDidConnect, object: nil) + NotificationCenter.default.addObserver(self, selector: #selector(ELUxGameControllerManager.mfiGameControllerDidConnect(_:)), name: .GCControllerDidConnect, object: nil) //控制器已断开连接 - NotificationCenter.default.addObserver(self, selector: #selector(ExternalGameControllerManager.mfiGameControllerDidDisconnect(_:)), name: .GCControllerDidDisconnect, object: nil) + NotificationCenter.default.addObserver(self, selector: #selector(ELUxGameControllerManager.mfiGameControllerDidDisconnect(_:)), name: .GCControllerDidDisconnect, object: nil) //外部键盘已连接 - NotificationCenter.default.addObserver(self, selector: #selector(ExternalGameControllerManager.keyboardDidConnect(_:)), name: .externalKeyboardDidConnect, object: nil) + NotificationCenter.default.addObserver(self, selector: #selector(ELUxGameControllerManager.keyboardDidConnect(_:)), name: .externalKeyboardDidConnect, object: nil) //外接键盘已断开连接 - NotificationCenter.default.addObserver(self, selector: #selector(ExternalGameControllerManager.keyboardDidDisconnect(_:)), name: .externalKeyboardDidDisconnect, object: nil) + NotificationCenter.default.addObserver(self, selector: #selector(ELUxGameControllerManager.keyboardDidDisconnect(_:)), name: .externalKeyboardDidDisconnect, object: nil) if #available(iOS 14, *) { - NotificationCenter.default.addObserver(self, selector: #selector(ExternalGameControllerManager.gcKeyboardDidConnect(_:)), name: .GCKeyboardDidConnect, object: nil) - NotificationCenter.default.addObserver(self, selector: #selector(ExternalGameControllerManager.gcKeyboardDidDisconnect(_:)), name: .GCKeyboardDidDisconnect, object: nil) + NotificationCenter.default.addObserver(self, selector: #selector(ELUxGameControllerManager.gcKeyboardDidConnect(_:)), name: .GCKeyboardDidConnect, object: nil) + NotificationCenter.default.addObserver(self, selector: #selector(ELUxGameControllerManager.gcKeyboardDidDisconnect(_:)), name: .GCKeyboardDidDisconnect, object: nil) } else { @@ -153,7 +153,7 @@ public extension ExternalGameControllerManager } //MARK: - External Keyboard - -public extension ExternalGameControllerManager +public extension ELUxGameControllerManager { // Implementation based on Ian McDowell's tweet: https://twitter.com/ian_mcdowell/status/844572113759547392 // 基于 Ian McDowell 的推文实现: @@ -200,7 +200,7 @@ public extension ExternalGameControllerManager } //MARK: - Managing Controllers - -private extension ExternalGameControllerManager +private extension ELUxGameControllerManager { func add(_ controller: GameController) { @@ -226,7 +226,7 @@ private extension ExternalGameControllerManager } //MARK: - MFi Game Controllers - -private extension ExternalGameControllerManager +private extension ELUxGameControllerManager { @objc func mfiGameControllerDidConnect(_ notification: Notification) { @@ -265,7 +265,7 @@ private extension ExternalGameControllerManager } //MARK: - Keyboard Game Controllers - -private extension ExternalGameControllerManager +private extension ELUxGameControllerManager { @objc func keyboardDidConnect(_ notification: Notification) { diff --git a/Cores/DeltaCore/DeltaCore/Game Controllers/Keyboard/KeyboardResponder.swift b/Cores/DeltaCore/DeltaCore/Game Controllers/Keyboard/KeyboardResponder.swift index 5048b748..661e9398 100644 --- a/Cores/DeltaCore/DeltaCore/Game Controllers/Keyboard/KeyboardResponder.swift +++ b/Cores/DeltaCore/DeltaCore/Game Controllers/Keyboard/KeyboardResponder.swift @@ -149,12 +149,12 @@ extension KeyboardResponder KeyboardResponder.activeKeyPresses[keyCode] = keyPress UIResponder.firstResponder?.keyPressesBegan([keyPress], with: event) - ExternalGameControllerManager.shared.keyPressesBegan([keyPress], with: event) + ELUxGameControllerManager.shared.keyPressesBegan([keyPress], with: event) } else { UIResponder.firstResponder?.keyPressesEnded([keyPress], with: event) - ExternalGameControllerManager.shared.keyPressesEnded([keyPress], with: event) + ELUxGameControllerManager.shared.keyPressesEnded([keyPress], with: event) KeyboardResponder.activeKeyPresses[keyCode] = nil } diff --git a/Cores/DeltaCore/DeltaCore/UI/Controller/ControllerView.swift b/Cores/DeltaCore/DeltaCore/UI/Controller/ControllerView.swift index d38702c7..147bf3de 100644 --- a/Cores/DeltaCore/DeltaCore/UI/Controller/ControllerView.swift +++ b/Cores/DeltaCore/DeltaCore/UI/Controller/ControllerView.swift @@ -335,7 +335,7 @@ extension ControllerView // 在后一种情况下,我们返回一个 nil inputView 以防止软件键盘出现。 guard let controllerSkin = self.controllerSkin, let traits = self.controllerSkinTraits else { return false } - if let keyboardController = ExternalGameControllerManager.shared.keyboardController, keyboardController.playerIndex != nil + if let keyboardController = ELUxGameControllerManager.shared.keyboardController, keyboardController.playerIndex != nil { // Keyboard is connected and has non-nil player index, so return true to receive keyboard presses. // 键盘已连接并且具有非零玩家索引,因此返回 true 以接收键盘按下。 @@ -374,7 +374,7 @@ extension ControllerView } public override var inputView: UIView? { - if let keyboardController = ExternalGameControllerManager.shared.keyboardController, keyboardController.playerIndex != nil + if let keyboardController = ELUxGameControllerManager.shared.keyboardController, keyboardController.playerIndex != nil { // Don't display any inputView if keyboard is connected and has non-nil player index. // 如果键盘已连接且玩家索引非零,则不显示任何 inputView。