Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Proof of concept: Control game speed with right thumbstick #1401

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 24 additions & 5 deletions Provenance/Emulator/PVEmulatorViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -689,6 +689,20 @@ extension PVEmulatorViewController {
}
})
}

func controllerInputDetected(gamepad: GCExtendedGamepad, element: GCControllerElement) {
if (gamepad.rightThumbstick == element) {
ELOG("RightThumbstickXAxis: \(gamepad.rightThumbstick.xAxis.value)")
if(gamepad.rightThumbstick.xAxis.value > 0.1) {
self.core.gameSpeed = GameSpeed.fast;
} else if(gamepad.rightThumbstick.xAxis.value < -0.1) {
self.core.gameSpeed = GameSpeed.slow;
}
else {
self.core.gameSpeed = GameSpeed.normal;
}
}
}

@objc func controllerDidConnect(_ note: Notification?) {
let controller = note?.object as? GCController
Expand All @@ -697,11 +711,16 @@ extension PVEmulatorViewController {
menuButton?.isHidden = true
// In instances where the controller is connected *after* the VC has been shown, we need to set the pause handler
// Except for the Apple Remote, where it's handled in the menuGestureRecognizer
// if controller?.vendorName != "Remote" {
// controller?.controllerPausedHandler = { [unowned self] controller in
// self.controllerPauseButtonPressed(controller)
// }
// }
if controller?.vendorName != "Remote" {
//controller?.controllerPausedHandler = { [unowned self] controller in
// self.controllerPauseButtonPressed(controller)
//}

controller?.extendedGamepad?.valueChangedHandler = {
(gamepad: GCExtendedGamepad, element: GCControllerElement) in self.controllerInputDetected(gamepad: gamepad, element: element)
}
}

#if os(iOS)
if #available(iOS 11.0, *) {
setNeedsUpdateOfHomeIndicatorAutoHidden()
Expand Down