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 1 commit
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
19 changes: 19 additions & 0 deletions Provenance/Emulator/PVEmulatorViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -705,6 +705,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 @@ -717,6 +731,11 @@ extension PVEmulatorViewController {
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, *) {
Expand Down