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

Game speed controls #24

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
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
26 changes: 26 additions & 0 deletions OpenEmuBase/OEGameCore.m
Original file line number Diff line number Diff line change
Expand Up @@ -573,6 +573,32 @@ - (BOOL)isEmulationPaused
return self.rate == 0;
}

- (void)increaseGameSpeed
{
float nextSpeed = self.rate + 0.25;

if (nextSpeed >= 5) nextSpeed = 5.0;

if (self.isEmulationPaused) {
lastRate = nextSpeed;
} else {
self.rate = nextSpeed;
}
}

- (void)decreaseGameSpeed
{
float nextSpeed = self.rate - 0.25;

if (nextSpeed <= 0) nextSpeed = 0.25;

if (self.isEmulationPaused) {
lastRate = nextSpeed;
} else {
self.rate = nextSpeed;
}
}

- (void)fastForwardAtSpeed:(CGFloat)fastForwardSpeed;
{
// FIXME: Need implementation.
Expand Down
2 changes: 2 additions & 0 deletions OpenEmuBase/OESystemResponderClient.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@

- (void)fastForward:(BOOL)flag;
- (void)fastForwardAtSpeed:(CGFloat)fastForwardSpeed;
- (void)increaseGameSpeed;
- (void)decreaseGameSpeed;
- (void)rewind:(BOOL)flag;
- (void)rewindAtSpeed:(CGFloat)rewindSpeed;
- (void)slowMotionAtSpeed:(CGFloat)slowMotionSpeed;
Expand Down
2 changes: 2 additions & 0 deletions OpenEmuSystem/OEKeyBindingDescription.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ typedef NS_ENUM(NSUInteger, OEGlobalButtonIdentifier) {
OEGlobalButtonIdentifierPause,
OEGlobalButtonIdentifierRewind,
OEGlobalButtonIdentifierFastForward,
OEGlobalButtonIdentifierIncreaseGameSpeed,
OEGlobalButtonIdentifierDecreaseGameSpeed,
OEGlobalButtonIdentifierSlowMotion,
OEGlobalButtonIdentifierStepFrameBackward,
OEGlobalButtonIdentifierStepFrameForward,
Expand Down
8 changes: 8 additions & 0 deletions OpenEmuSystem/OEKeyBindingDescription.m
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,10 @@
return @"OEGlobalButtonIdentifierRewind";
case OEGlobalButtonIdentifierFastForward :
return @"OEGlobalButtonIdentifierFastForward";
case OEGlobalButtonIdentifierIncreaseGameSpeed :
return @"OEGlobalButtonIdentifierIncreaseGameSpeed";
case OEGlobalButtonIdentifierDecreaseGameSpeed :
return @"OEGlobalButtonIdentifierDecreaseGameSpeed";
case OEGlobalButtonIdentifierSlowMotion :
return @"OEGlobalButtonIdentifierSlowMotion";
case OEGlobalButtonIdentifierStepFrameBackward :
Expand Down Expand Up @@ -127,6 +131,10 @@
return OEGlobalButtonRewind;
case OEGlobalButtonIdentifierFastForward :
return OEGlobalButtonFastForward;
case OEGlobalButtonIdentifierIncreaseGameSpeed :
return OEGlobalButtonIncreaseGameSpeed;
case OEGlobalButtonIdentifierDecreaseGameSpeed :
return OEGlobalButtonDecreaseGameSpeed;
case OEGlobalButtonIdentifierSlowMotion :
return OEGlobalButtonSlowMotion;
case OEGlobalButtonIdentifierStepFrameBackward :
Expand Down
2 changes: 2 additions & 0 deletions OpenEmuSystem/OESystemBindings.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@ extern NSString *const OEGlobalButtonReset;
extern NSString *const OEGlobalButtonPause;
extern NSString *const OEGlobalButtonRewind;
extern NSString *const OEGlobalButtonFastForward;
extern NSString *const OEGlobalButtonIncreaseGameSpeed;
extern NSString *const OEGlobalButtonDecreaseGameSpeed;
extern NSString *const OEGlobalButtonSlowMotion;
extern NSString *const OEGlobalButtonStepFrameBackward;
extern NSString *const OEGlobalButtonStepFrameForward;
Expand Down
46 changes: 24 additions & 22 deletions OpenEmuSystem/OESystemBindings.m
Original file line number Diff line number Diff line change
Expand Up @@ -42,28 +42,30 @@
static NSString *const _OEKeyboardPlayerBindingRepresentationsKey = @"keyboardPlayerBindings";
static NSString *const _OEControllerBindingRepresentationsKey = @"controllerBindings";

NSString *const OEGlobalButtonSaveState = @"OEGlobalButtonSaveState";
NSString *const OEGlobalButtonLoadState = @"OEGlobalButtonLoadState";
NSString *const OEGlobalButtonQuickSave = @"OEGlobalButtonQuickSave";
NSString *const OEGlobalButtonQuickLoad = @"OEGlobalButtonQuickLoad";
NSString *const OEGlobalButtonFullScreen = @"OEGlobalButtonFullScreen";
NSString *const OEGlobalButtonMute = @"OEGlobalButtonMute";
NSString *const OEGlobalButtonVolumeDown = @"OEGlobalButtonVolumeDown";
NSString *const OEGlobalButtonVolumeUp = @"OEGlobalButtonVolumeUp";
NSString *const OEGlobalButtonStop = @"OEGlobalButtonStop";
NSString *const OEGlobalButtonReset = @"OEGlobalButtonReset";
NSString *const OEGlobalButtonPause = @"OEGlobalButtonPause";
NSString *const OEGlobalButtonRewind = @"OEGlobalButtonRewind";
NSString *const OEGlobalButtonFastForward = @"OEGlobalButtonFastForward";
NSString *const OEGlobalButtonSlowMotion = @"OEGlobalButtonSlowMotion";
NSString *const OEGlobalButtonStepFrameBackward = @"OEGlobalButtonStepFrameBackward";
NSString *const OEGlobalButtonStepFrameForward = @"OEGlobalButtonStepFrameForward";
NSString *const OEGlobalButtonNextDisplayMode = @"OEGlobalButtonNextDisplayMode";
NSString *const OEGlobalButtonLastDisplayMode = @"OEGlobalButtonLastDisplayMode";
NSString *const OEGlobalButtonScreenshot = @"OEGlobalButtonScreenshot";
NSString *const OEGlobalButtonRapidFireToggle = @"OEGlobalButtonRapidFireToggle";
NSString *const OEGlobalButtonRapidFireClear = @"OEGlobalButtonRapidFireClear";
NSString *const OEGlobalButtonRapidFireReset = @"OEGlobalButtonRapidFireReset";
NSString *const OEGlobalButtonSaveState = @"OEGlobalButtonSaveState";
NSString *const OEGlobalButtonLoadState = @"OEGlobalButtonLoadState";
NSString *const OEGlobalButtonQuickSave = @"OEGlobalButtonQuickSave";
NSString *const OEGlobalButtonQuickLoad = @"OEGlobalButtonQuickLoad";
NSString *const OEGlobalButtonFullScreen = @"OEGlobalButtonFullScreen";
NSString *const OEGlobalButtonMute = @"OEGlobalButtonMute";
NSString *const OEGlobalButtonVolumeDown = @"OEGlobalButtonVolumeDown";
NSString *const OEGlobalButtonVolumeUp = @"OEGlobalButtonVolumeUp";
NSString *const OEGlobalButtonStop = @"OEGlobalButtonStop";
NSString *const OEGlobalButtonReset = @"OEGlobalButtonReset";
NSString *const OEGlobalButtonPause = @"OEGlobalButtonPause";
NSString *const OEGlobalButtonRewind = @"OEGlobalButtonRewind";
NSString *const OEGlobalButtonFastForward = @"OEGlobalButtonFastForward";
NSString *const OEGlobalButtonIncreaseGameSpeed = @"OEGlobalButtonIncreaseGameSpeed";
NSString *const OEGlobalButtonDecreaseGameSpeed = @"OEGlobalButtonDecreaseGameSpeed";
NSString *const OEGlobalButtonSlowMotion = @"OEGlobalButtonSlowMotion";
NSString *const OEGlobalButtonStepFrameBackward = @"OEGlobalButtonStepFrameBackward";
NSString *const OEGlobalButtonStepFrameForward = @"OEGlobalButtonStepFrameForward";
NSString *const OEGlobalButtonNextDisplayMode = @"OEGlobalButtonNextDisplayMode";
NSString *const OEGlobalButtonLastDisplayMode = @"OEGlobalButtonLastDisplayMode";
NSString *const OEGlobalButtonScreenshot = @"OEGlobalButtonScreenshot";
NSString *const OEGlobalButtonRapidFireToggle = @"OEGlobalButtonRapidFireToggle";
NSString *const OEGlobalButtonRapidFireClear = @"OEGlobalButtonRapidFireClear";
NSString *const OEGlobalButtonRapidFireReset = @"OEGlobalButtonRapidFireReset";

@interface OEHIDEvent ()
- (OEHIDEvent *)OE_eventWithDeviceHandler:(OEDeviceHandler *)aDeviceHandler;
Expand Down
4 changes: 4 additions & 0 deletions OpenEmuSystem/OESystemController.m
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,8 @@ - (NSString *)serialLookupForFile:(__kindof OEFile *)file
Button(@"Pause", @"Name of the global button to pause the emulation", OEGlobalButtonPause),
Button(@"Rewind", @"Name of the global button to rewind the emulation", OEGlobalButtonRewind),
Button(@"Fast Forward", @"Name of the global button to fast foward the emulation", OEGlobalButtonFastForward),
Button(@"Increase Game Speed", @"Name of the global button to increase the emulation speed", OEGlobalButtonIncreaseGameSpeed),
Button(@"Decrease Game Speed", @"Name of the global button to decrease the emulation speed", OEGlobalButtonDecreaseGameSpeed),
//Button(@"Slow Motion", @"Name of the global button to run the emulation in slow motion", OEGlobalButtonSlowMotion),
Button(@"Step Backward", @"Name of the global button to step the emulation backward by one frame", OEGlobalButtonStepFrameBackward),
Button(@"Step Forward", @"Name of the global button to step the emulation forward by one frame", OEGlobalButtonStepFrameForward),
Expand All @@ -239,6 +241,8 @@ - (NSString *)serialLookupForFile:(__kindof OEFile *)file
Button(@"Pause", @"Name of the global button to pause the emulation", OEGlobalButtonPause),
Button(@"Rewind", @"Name of the global button to rewind the emulation", OEGlobalButtonRewind),
Button(@"Fast Forward", @"Name of the global button to fast foward the emulation", OEGlobalButtonFastForward),
Button(@"Increase Game Speed", @"Name of the global button to increase the emulation speed", OEGlobalButtonIncreaseGameSpeed),
Button(@"Decrease Game Speed", @"Name of the global button to decrease the emulation speeed", OEGlobalButtonDecreaseGameSpeed),
Button(@"Step Backward", @"Name of the global button to step the emulation backward by one frame", OEGlobalButtonStepFrameBackward),
Button(@"Step Forward", @"Name of the global button to step the emulation forward by one frame", OEGlobalButtonStepFrameForward),
Button(@"Next Display Mode", @"Name of the global button to switch to the next display mode", OEGlobalButtonNextDisplayMode),
Expand Down
2 changes: 2 additions & 0 deletions OpenEmuSystem/OESystemResponder.h
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,8 @@ NS_ASSUME_NONNULL_BEGIN
- (void)toggleEmulationPaused:(id)sender;
- (void)takeScreenshot:(id)sender;
- (void)fastForwardGameplay:(BOOL)enable;
- (void)increaseGameSpeed:(id)sender;
- (void)decreaseGameSpeed:(id)sender;
- (void)rewindGameplay:(BOOL)enable;
- (void)stepGameplayFrameForward:(id)sender;
- (void)stepGameplayFrameBackward:(id)sender;
Expand Down
12 changes: 12 additions & 0 deletions OpenEmuSystem/OESystemResponder.mm
Original file line number Diff line number Diff line change
Expand Up @@ -481,6 +481,12 @@ - (void)pressGlobalButtonWithIdentifier:(OEGlobalButtonIdentifier)identifier pla
SEND_ACTION2(fastForwardGameplay:, YES);
[[self client] fastForward:YES];
return;
case OEGlobalButtonIdentifierIncreaseGameSpeed :
[[self client] increaseGameSpeed];
return;
case OEGlobalButtonIdentifierDecreaseGameSpeed :
[[self client] decreaseGameSpeed];
return;
case OEGlobalButtonIdentifierRewind :
SEND_ACTION2(rewindGameplay:, YES);
[[self client] rewind:YES];
Expand Down Expand Up @@ -550,6 +556,10 @@ - (void)releaseGlobalButtonWithIdentifier:(OEGlobalButtonIdentifier)identifier p
SEND_ACTION2(fastForwardGameplay:, NO);
[[self client] fastForward:NO];
return;
case OEGlobalButtonIdentifierIncreaseGameSpeed :
return;
case OEGlobalButtonIdentifierDecreaseGameSpeed :
return;
case OEGlobalButtonIdentifierRewind :
SEND_ACTION2(rewindGameplay:, NO);
[[self client] rewind:NO];
Expand Down Expand Up @@ -599,6 +609,8 @@ - (void)changeAnalogGlobalButtonIdentifier:(OEGlobalButtonIdentifier)identifier
return;

case OEGlobalButtonIdentifierFastForward :
case OEGlobalButtonIdentifierIncreaseGameSpeed :
case OEGlobalButtonIdentifierDecreaseGameSpeed :
case OEGlobalButtonIdentifierRewind :
case OEGlobalButtonIdentifierSaveState :
case OEGlobalButtonIdentifierLoadState :
Expand Down