Updates input + video logic to support revised DeltaCore API
- Continuous inputs - OpenGLES-based rendering - Thumbsticks in controller skins
This commit is contained in:
parent
da0ec57856
commit
9b28d42814
@ -1 +1 @@
|
|||||||
Subproject commit 97e51f6ea5935d3ce2d15be796b189bcc70dbbb3
|
Subproject commit 3373709956dc2be70563582ba7e308677bb964fa
|
||||||
@ -1 +1 @@
|
|||||||
Subproject commit acbcf2baf8f01302f2a7c6e60783b887160aa163
|
Subproject commit 6c763da1513fbe762edbca2cf33cec556ce9536e
|
||||||
@ -1 +1 @@
|
|||||||
Subproject commit c8084cee111501c0daffd113f5892050d7738519
|
Subproject commit 4dcb34a47e71b81a099bff4dc0ebd28c217ef85b
|
||||||
@ -1 +1 @@
|
|||||||
Subproject commit 7ed452b7dff25a68cd503610bee1f3e36216a871
|
Subproject commit 4dc0f283116aadf6397c88c1f7fdabcac32367a6
|
||||||
@ -1 +1 @@
|
|||||||
Subproject commit d794f67cdba072f8a9977fb76e8ccaaac09946c0
|
Subproject commit dc0ec5b74c0e47e0e35912dfd63dd70f2a3d932e
|
||||||
@ -372,7 +372,7 @@
|
|||||||
<gestureRecognizers/>
|
<gestureRecognizers/>
|
||||||
<constraints>
|
<constraints>
|
||||||
<constraint firstItem="KkE-ji-6Y8" firstAttribute="centerY" secondItem="cPg-qa-ERT" secondAttribute="centerY" placeholder="YES" id="4wi-cL-aCQ"/>
|
<constraint firstItem="KkE-ji-6Y8" firstAttribute="centerY" secondItem="cPg-qa-ERT" secondAttribute="centerY" placeholder="YES" id="4wi-cL-aCQ"/>
|
||||||
<constraint firstItem="Z6c-bc-h6l" firstAttribute="top" secondItem="6Wl-el-X30" secondAttribute="bottom" id="Bmp-yB-Yf1"/>
|
<constraint firstAttribute="bottom" secondItem="6Wl-el-X30" secondAttribute="bottom" id="Bmp-yB-Yf1"/>
|
||||||
<constraint firstAttribute="trailing" secondItem="KkE-ji-6Y8" secondAttribute="trailing" id="Jeb-8K-VYw"/>
|
<constraint firstAttribute="trailing" secondItem="KkE-ji-6Y8" secondAttribute="trailing" id="Jeb-8K-VYw"/>
|
||||||
<constraint firstItem="6Wl-el-X30" firstAttribute="top" secondItem="cH1-gu-g2u" secondAttribute="bottom" id="TD2-bx-DJC"/>
|
<constraint firstItem="6Wl-el-X30" firstAttribute="top" secondItem="cH1-gu-g2u" secondAttribute="bottom" id="TD2-bx-DJC"/>
|
||||||
<constraint firstAttribute="trailing" secondItem="6Wl-el-X30" secondAttribute="trailing" id="Xph-DL-tBk"/>
|
<constraint firstAttribute="trailing" secondItem="6Wl-el-X30" secondAttribute="trailing" id="Xph-DL-tBk"/>
|
||||||
|
|||||||
@ -66,6 +66,11 @@ extension ControllerSkin: ControllerSkinProtocol
|
|||||||
return self.controllerSkin?.image(for: traits, preferredSize: preferredSize)
|
return self.controllerSkin?.image(for: traits, preferredSize: preferredSize)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public func thumbstick(for item: DeltaCore.ControllerSkin.Item, traits: DeltaCore.ControllerSkin.Traits, preferredSize: DeltaCore.ControllerSkin.Size) -> (UIImage, CGSize)?
|
||||||
|
{
|
||||||
|
return self.controllerSkin?.thumbstick(for: item, traits: traits, preferredSize: preferredSize)
|
||||||
|
}
|
||||||
|
|
||||||
public func inputs(for traits: DeltaCore.ControllerSkin.Traits, at point: CGPoint) -> [Input]?
|
public func inputs(for traits: DeltaCore.ControllerSkin.Traits, at point: CGPoint) -> [Input]?
|
||||||
{
|
{
|
||||||
return self.controllerSkin?.inputs(for: traits, at: point)
|
return self.controllerSkin?.inputs(for: traits, at: point)
|
||||||
|
|||||||
@ -115,8 +115,6 @@ class GameViewController: DeltaCore.GameViewController
|
|||||||
|
|
||||||
private var _isLoadingSaveState = false
|
private var _isLoadingSaveState = false
|
||||||
|
|
||||||
private var context = CIContext(options: [.workingColorSpace: NSNull()])
|
|
||||||
|
|
||||||
// Sustain Buttons
|
// Sustain Buttons
|
||||||
private var isSelectingSustainedButtons = false
|
private var isSelectingSustainedButtons = false
|
||||||
private var sustainInputsMapping: SustainInputsMapping?
|
private var sustainInputsMapping: SustainInputsMapping?
|
||||||
@ -124,6 +122,7 @@ class GameViewController: DeltaCore.GameViewController
|
|||||||
private var sustainButtonsContentView: UIView!
|
private var sustainButtonsContentView: UIView!
|
||||||
private var sustainButtonsBlurView: UIVisualEffectView!
|
private var sustainButtonsBlurView: UIVisualEffectView!
|
||||||
private var sustainButtonsBackgroundView: RSTPlaceholderView!
|
private var sustainButtonsBackgroundView: RSTPlaceholderView!
|
||||||
|
private var inputsToSustain = [AnyInput: Double]()
|
||||||
|
|
||||||
private var isGyroActive = false
|
private var isGyroActive = false
|
||||||
private var presentedGyroAlert = false
|
private var presentedGyroAlert = false
|
||||||
@ -168,9 +167,9 @@ class GameViewController: DeltaCore.GameViewController
|
|||||||
}
|
}
|
||||||
|
|
||||||
// MARK: - GameControllerReceiver -
|
// MARK: - GameControllerReceiver -
|
||||||
override func gameController(_ gameController: GameController, didActivate input: Input)
|
override func gameController(_ gameController: GameController, didActivate input: Input, value: Double)
|
||||||
{
|
{
|
||||||
super.gameController(gameController, didActivate: input)
|
super.gameController(gameController, didActivate: input, value: value)
|
||||||
|
|
||||||
if self.isSelectingSustainedButtons
|
if self.isSelectingSustainedButtons
|
||||||
{
|
{
|
||||||
@ -178,7 +177,7 @@ class GameViewController: DeltaCore.GameViewController
|
|||||||
|
|
||||||
if input != StandardGameControllerInput.menu
|
if input != StandardGameControllerInput.menu
|
||||||
{
|
{
|
||||||
gameController.sustain(input)
|
self.inputsToSustain[AnyInput(input)] = value
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if self.emulatorCore?.state == .running
|
else if self.emulatorCore?.state == .running
|
||||||
@ -198,15 +197,23 @@ class GameViewController: DeltaCore.GameViewController
|
|||||||
{
|
{
|
||||||
super.gameController(gameController, didDeactivate: input)
|
super.gameController(gameController, didDeactivate: input)
|
||||||
|
|
||||||
guard !self.isSelectingSustainedButtons else { return }
|
if self.isSelectingSustainedButtons
|
||||||
|
|
||||||
guard let actionInput = ActionInput(input: input) else { return }
|
|
||||||
|
|
||||||
switch actionInput
|
|
||||||
{
|
{
|
||||||
case .quickSave: break
|
if input.isContinuous
|
||||||
case .quickLoad: break
|
{
|
||||||
case .fastForward: self.performFastForwardAction(activate: false)
|
self.inputsToSustain[AnyInput(input)] = nil
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
guard let actionInput = ActionInput(input: input) else { return }
|
||||||
|
|
||||||
|
switch actionInput
|
||||||
|
{
|
||||||
|
case .quickSave: break
|
||||||
|
case .quickLoad: break
|
||||||
|
case .fastForward: self.performFastForwardAction(activate: false)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -320,7 +327,7 @@ extension GameViewController
|
|||||||
pauseViewController.sustainButtonsItem?.isSelected = gameController.sustainedInputs.count > 0
|
pauseViewController.sustainButtonsItem?.isSelected = gameController.sustainedInputs.count > 0
|
||||||
pauseViewController.sustainButtonsItem?.action = { [unowned self, unowned pauseViewController] item in
|
pauseViewController.sustainButtonsItem?.action = { [unowned self, unowned pauseViewController] item in
|
||||||
|
|
||||||
for input in gameController.sustainedInputs
|
for input in gameController.sustainedInputs.keys
|
||||||
{
|
{
|
||||||
gameController.unsustain(input)
|
gameController.unsustain(input)
|
||||||
}
|
}
|
||||||
@ -650,10 +657,7 @@ extension GameViewController: SaveStatesViewControllerDelegate
|
|||||||
self.emulatorCore?.saveSaveState(to: saveState.fileURL)
|
self.emulatorCore?.saveSaveState(to: saveState.fileURL)
|
||||||
}
|
}
|
||||||
|
|
||||||
if
|
if let snapshot = self.gameView.snapshot(), let data = snapshot.pngData()
|
||||||
let outputImage = self.gameView.outputImage,
|
|
||||||
let quartzImage = self.context.createCGImage(outputImage, from: outputImage.extent),
|
|
||||||
let data = UIImage(cgImage: quartzImage).pngData()
|
|
||||||
{
|
{
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
@ -803,10 +807,10 @@ private extension GameViewController
|
|||||||
self.updateControllers()
|
self.updateControllers()
|
||||||
self.sustainInputsMapping = nil
|
self.sustainInputsMapping = nil
|
||||||
|
|
||||||
// Reactivate all sustained inputs, since they will now be mapped to game inputs.
|
// Activate all sustained inputs, since they will now be mapped to game inputs.
|
||||||
for input in gameController.sustainedInputs
|
for (input, value) in self.inputsToSustain
|
||||||
{
|
{
|
||||||
gameController.activate(input)
|
gameController.sustain(input, value: value)
|
||||||
}
|
}
|
||||||
|
|
||||||
let blurEffect = self.sustainButtonsBlurView.effect
|
let blurEffect = self.sustainButtonsBlurView.effect
|
||||||
@ -818,6 +822,8 @@ private extension GameViewController
|
|||||||
self.sustainButtonsContentView.isHidden = true
|
self.sustainButtonsContentView.isHidden = true
|
||||||
self.sustainButtonsBlurView.effect = blurEffect
|
self.sustainButtonsBlurView.effect = blurEffect
|
||||||
}
|
}
|
||||||
|
|
||||||
|
self.inputsToSustain = [:]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -123,6 +123,7 @@ private extension ControllerInputsViewController
|
|||||||
|
|
||||||
// Update controller view's controller skin.
|
// Update controller view's controller skin.
|
||||||
self.gameViewController.controllerView.controllerSkin = DeltaCore.ControllerSkin.standardControllerSkin(for: self.system.gameType)
|
self.gameViewController.controllerView.controllerSkin = DeltaCore.ControllerSkin.standardControllerSkin(for: self.system.gameType)
|
||||||
|
self.gameViewController.view.setNeedsUpdateConstraints()
|
||||||
|
|
||||||
// Fetch input mapping if it hasn't already been fetched.
|
// Fetch input mapping if it hasn't already been fetched.
|
||||||
if let gameController = self.gameController, let playerIndex = gameController.playerIndex, self.inputMappings[self.system] == nil
|
if let gameController = self.gameController, let playerIndex = gameController.playerIndex, self.inputMappings[self.system] == nil
|
||||||
@ -417,31 +418,32 @@ private extension ControllerInputsViewController
|
|||||||
{
|
{
|
||||||
case .standard: itemFrame = item.frame
|
case .standard: itemFrame = item.frame
|
||||||
case let .directional(up, down, left, right):
|
case let .directional(up, down, left, right):
|
||||||
|
let frame = (item.kind == .thumbstick) ? item.extendedFrame : item.frame
|
||||||
|
|
||||||
switch input.stringValue
|
switch input.stringValue
|
||||||
{
|
{
|
||||||
case up.stringValue:
|
case up.stringValue:
|
||||||
itemFrame = CGRect(x: item.frame.minX + item.frame.width / 3,
|
itemFrame = CGRect(x: frame.minX + frame.width / 3,
|
||||||
y: item.frame.minY,
|
y: frame.minY,
|
||||||
width: item.frame.width / 3,
|
width: frame.width / 3,
|
||||||
height: item.frame.height / 3)
|
height: frame.height / 3)
|
||||||
case down.stringValue:
|
case down.stringValue:
|
||||||
itemFrame = CGRect(x: item.frame.minX + item.frame.width / 3,
|
itemFrame = CGRect(x: frame.minX + frame.width / 3,
|
||||||
y: item.frame.minY + (item.frame.height / 3) * 2,
|
y: frame.minY + (frame.height / 3) * 2,
|
||||||
width: item.frame.width / 3,
|
width: frame.width / 3,
|
||||||
height: item.frame.height / 3)
|
height: frame.height / 3)
|
||||||
|
|
||||||
case left.stringValue:
|
case left.stringValue:
|
||||||
itemFrame = CGRect(x: item.frame.minX,
|
itemFrame = CGRect(x: frame.minX,
|
||||||
y: item.frame.minY + (item.frame.height / 3),
|
y: frame.minY + (frame.height / 3),
|
||||||
width: item.frame.width / 3,
|
width: frame.width / 3,
|
||||||
height: item.frame.height / 3)
|
height: frame.height / 3)
|
||||||
|
|
||||||
case right.stringValue:
|
case right.stringValue:
|
||||||
itemFrame = CGRect(x: item.frame.minX + (item.frame.width / 3) * 2,
|
itemFrame = CGRect(x: frame.minX + (frame.width / 3) * 2,
|
||||||
y: item.frame.minY + (item.frame.height / 3),
|
y: frame.minY + (frame.height / 3),
|
||||||
width: item.frame.width / 3,
|
width: frame.width / 3,
|
||||||
height: item.frame.height / 3)
|
height: frame.height / 3)
|
||||||
|
|
||||||
default: itemFrame = nil
|
default: itemFrame = nil
|
||||||
}
|
}
|
||||||
@ -478,7 +480,7 @@ private extension ControllerInputsViewController
|
|||||||
|
|
||||||
extension ControllerInputsViewController: GameControllerReceiver
|
extension ControllerInputsViewController: GameControllerReceiver
|
||||||
{
|
{
|
||||||
func gameController(_ gameController: GameController, didActivate controllerInput: DeltaCore.Input)
|
func gameController(_ gameController: GameController, didActivate controllerInput: DeltaCore.Input, value: Double)
|
||||||
{
|
{
|
||||||
guard self.isViewLoaded else { return }
|
guard self.isViewLoaded else { return }
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user