diff --git a/OpenEmuSystem/OEKeyBindingDescription.h b/OpenEmuSystem/OEKeyBindingDescription.h index 3092fc3..4bd9dbd 100644 --- a/OpenEmuSystem/OEKeyBindingDescription.h +++ b/OpenEmuSystem/OEKeyBindingDescription.h @@ -60,6 +60,7 @@ typedef NS_ENUM(NSUInteger, OEGlobalButtonIdentifier) { OEGlobalButtonIdentifierRapidFireToggle, OEGlobalButtonIdentifierRapidFireClear, OEGlobalButtonIdentifierRapidFireReset, + OEGlobalButtonIdentifierFastForwardToggle, OEGlobalButtonIdentifierCount, diff --git a/OpenEmuSystem/OEKeyBindingDescription.m b/OpenEmuSystem/OEKeyBindingDescription.m index 4cd4506..d0b0c8a 100644 --- a/OpenEmuSystem/OEKeyBindingDescription.m +++ b/OpenEmuSystem/OEKeyBindingDescription.m @@ -82,6 +82,8 @@ return @"OEGlobalButtonIdentifierLastDisplayMode"; case OEGlobalButtonIdentifierScreenshot : return @"OEGlobalButtonIdentifierScreenshot"; + case OEGlobalButtonIdentifierFastForwardToggle : + return @"OEGlobalButtonIdentifierFastForwardToggle"; case OEGlobalButtonIdentifierCount : return @"OEGlobalButtonIdentifierCount"; case OEGlobalButtonIdentifierFlag : @@ -139,6 +141,8 @@ return OEGlobalButtonLastDisplayMode; case OEGlobalButtonIdentifierScreenshot : return OEGlobalButtonScreenshot; + case OEGlobalButtonIdentifierFastForwardToggle : + return OEGlobalButtonFastForwardToggle; default : break; } diff --git a/OpenEmuSystem/OESystemBindings.h b/OpenEmuSystem/OESystemBindings.h index 6d1276e..ca9221f 100644 --- a/OpenEmuSystem/OESystemBindings.h +++ b/OpenEmuSystem/OESystemBindings.h @@ -62,6 +62,7 @@ extern NSString *const OEGlobalButtonScreenshot; extern NSString *const OEGlobalButtonRapidFireToggle; extern NSString *const OEGlobalButtonRapidFireClear; extern NSString *const OEGlobalButtonRapidFireReset; +extern NSString *const OEGlobalButtonFastForwardToggle; /// Manages the bindings for a specific system, useful for system responders /// Instances of this class are allocated by OEGameBindingsController diff --git a/OpenEmuSystem/OESystemBindings.m b/OpenEmuSystem/OESystemBindings.m index be57ce1..9f63012 100644 --- a/OpenEmuSystem/OESystemBindings.m +++ b/OpenEmuSystem/OESystemBindings.m @@ -64,6 +64,7 @@ NSString *const OEGlobalButtonRapidFireToggle = @"OEGlobalButtonRapidFireToggle"; NSString *const OEGlobalButtonRapidFireClear = @"OEGlobalButtonRapidFireClear"; NSString *const OEGlobalButtonRapidFireReset = @"OEGlobalButtonRapidFireReset"; +NSString *const OEGlobalButtonFastForwardToggle = @"OEGlobalButtonFastForwardToggle"; @interface OEHIDEvent () - (OEHIDEvent *)OE_eventWithDeviceHandler:(OEDeviceHandler *)aDeviceHandler; diff --git a/OpenEmuSystem/OESystemController.m b/OpenEmuSystem/OESystemController.m index 7819a18..b9e904d 100644 --- a/OpenEmuSystem/OESystemController.m +++ b/OpenEmuSystem/OESystemController.m @@ -233,6 +233,7 @@ - (NSString *)serialLookupForFile:(__kindof OEFile *)file Button(@"Pause/Resume", OEGlobalButtonPause), Button(@"Rewind", OEGlobalButtonRewind), Button(@"Fast Forward", OEGlobalButtonFastForward), + Button(@"Toggle Fast Forward", OEGlobalButtonFastForwardToggle), //Button(@"Slow Motion", OEGlobalButtonSlowMotion), Button(@"Step Backward", OEGlobalButtonStepFrameBackward), Button(@"Step Forward", OEGlobalButtonStepFrameForward), @@ -249,6 +250,7 @@ - (NSString *)serialLookupForFile:(__kindof OEFile *)file Button(@"Pause/Resume", OEGlobalButtonPause), Button(@"Rewind", OEGlobalButtonRewind), Button(@"Fast Forward", OEGlobalButtonFastForward), + Button(@"Toggle Fast Forward", OEGlobalButtonFastForwardToggle), Button(@"Step Backward", OEGlobalButtonStepFrameBackward), Button(@"Step Forward", OEGlobalButtonStepFrameForward), Button(@"Next Display Mode", OEGlobalButtonNextDisplayMode), diff --git a/OpenEmuSystem/OESystemResponder.mm b/OpenEmuSystem/OESystemResponder.mm index 5f39289..092e3cd 100644 --- a/OpenEmuSystem/OESystemResponder.mm +++ b/OpenEmuSystem/OESystemResponder.mm @@ -112,6 +112,9 @@ @implementation OESystemResponder std::set _rapidFireKeyBlacklist; std::vector _rapidFireState; + BOOL _fastForwardHeld; + BOOL _fastForwardToggled; + BOOL _fastForwardActive; BOOL _handlesEscapeKey; double _analogToDigitalThreshold; @@ -495,6 +498,36 @@ - (void)changeAnalogEmulatorKey:(OESystemKey *)aKey value:(CGFloat)value else dispatch_async(dispatch_get_main_queue(), blk); \ } while(NO) +- (void)OE_setFastForwardActive:(BOOL)enable +{ + if (_fastForwardActive == enable) + return; + + _fastForwardActive = enable; + SEND_ACTION2(fastForwardGameplay:, enable); + [[self client] fastForward:enable]; +} + +- (void)OE_updateFastForwardState +{ + [self OE_setFastForwardActive:_fastForwardHeld || _fastForwardToggled]; +} + +- (void)OE_setFastForwardHeld:(BOOL)held +{ + if (_fastForwardHeld == held) + return; + + _fastForwardHeld = held; + [self OE_updateFastForwardState]; +} + +- (void)OE_toggleFastForward +{ + _fastForwardToggled = !_fastForwardToggled; + [self OE_updateFastForwardState]; +} + - (void)pressGlobalButtonWithIdentifier:(OEGlobalButtonIdentifier)identifier player:(NSInteger)player { // FIXME: We currently only trigger these actions on release, but maybe some of these (like StepFrameBackward and StepFrameForward) should allow key repeat @@ -509,8 +542,10 @@ - (void)pressGlobalButtonWithIdentifier:(OEGlobalButtonIdentifier)identifier pla [[self client] stepFrameForward]; return; case OEGlobalButtonIdentifierFastForward : - SEND_ACTION2(fastForwardGameplay:, YES); - [[self client] fastForward:YES]; + [self OE_setFastForwardHeld:YES]; + return; + case OEGlobalButtonIdentifierFastForwardToggle : + [self OE_toggleFastForward]; return; case OEGlobalButtonIdentifierRewind : SEND_ACTION2(rewindGameplay:, YES); @@ -578,8 +613,9 @@ - (void)releaseGlobalButtonWithIdentifier:(OEGlobalButtonIdentifier)identifier p case OEGlobalButtonIdentifierStepFrameForward : return; case OEGlobalButtonIdentifierFastForward : - SEND_ACTION2(fastForwardGameplay:, NO); - [[self client] fastForward:NO]; + [self OE_setFastForwardHeld:NO]; + return; + case OEGlobalButtonIdentifierFastForwardToggle : return; case OEGlobalButtonIdentifierRewind : SEND_ACTION2(rewindGameplay:, NO); @@ -647,6 +683,7 @@ - (void)changeAnalogGlobalButtonIdentifier:(OEGlobalButtonIdentifier)identifier case OEGlobalButtonIdentifierNextDisplayMode : case OEGlobalButtonIdentifierLastDisplayMode : case OEGlobalButtonIdentifierScreenshot : + case OEGlobalButtonIdentifierFastForwardToggle : case OEGlobalButtonIdentifierRapidFireToggle : case OEGlobalButtonIdentifierRapidFireClear : case OEGlobalButtonIdentifierRapidFireReset :