From 41794de2d006d4096942c8a94a6ae929f095e4ad Mon Sep 17 00:00:00 2001 From: Eduo Gutierrez Date: Thu, 30 Oct 2025 23:49:53 +0100 Subject: [PATCH] Fix Cmd+F4 disc cycling shortcut Pressing Cmd+F4 now correctly cycles around all mounted drives to their next queued disc image(s) with automatic bezel notifications showing the disc changes. To mount multiple disk images place them in the root directory with the format: {LETTER} {LABEL}.{EXTENSION} Images for a drive letter will be mounted alphabetically. A command line like: imgmount a .\floppy\PROG32.IMA .\floppy\DATA1.IMA -t floppy Becomes two files in the gamebox root names: A 1PROG32.IMA A 2DATA1.IMA Shortcut cmd-F4 (or cmd-fn-F4) will cycle and provide visual input as well as update the volume inspector. --- Boxer/BXSession+BXUIControls.h | 3 ++ Boxer/BXSession+BXUIControls.m | 30 +++++++++++++++++++ .../BXInputController+BXKeyboardInput.m | 12 ++++++++ 3 files changed, 45 insertions(+) diff --git a/Boxer/BXSession+BXUIControls.h b/Boxer/BXSession+BXUIControls.h index 931e90097..2c8cc4778 100644 --- a/Boxer/BXSession+BXUIControls.h +++ b/Boxer/BXSession+BXUIControls.h @@ -159,6 +159,9 @@ typedef NS_ENUM(NSInteger, BXPlaybackMode) { - (IBAction) mountNextDrivesInQueues: (id)sender; - (IBAction) mountPreviousDrivesInQueues: (id)sender; +/// Cycle all mounted drives to their next queued images. Triggered by Cmd+F4 keyboard shortcut. +- (IBAction) cycleMountedDiscsForward: (id)sender; + /// Whether we have any drive queues that can be cycled. Used for UI bindings. - (BOOL) canCycleDrivesInQueues; diff --git a/Boxer/BXSession+BXUIControls.m b/Boxer/BXSession+BXUIControls.m index f381392b8..8ce03fac0 100644 --- a/Boxer/BXSession+BXUIControls.m +++ b/Boxer/BXSession+BXUIControls.m @@ -1087,6 +1087,36 @@ - (IBAction) mountPreviousDrivesInQueues: (id)sender [self _mountQueuedSiblingsAtOffset: -1]; } +- (IBAction) cycleMountedDiscsForward: (id)sender +{ + //Cycle through each mounted drive's queued images, showing bezel notifications for each change. + //This is triggered by Cmd+F4 in the keyboard input handler. + for (BXDrive *currentDrive in self.mountedDrives) + { + BXDrive *siblingDrive = [self siblingOfQueuedDrive: currentDrive atOffset: 1]; + if (siblingDrive && ![siblingDrive isEqual: currentDrive]) + { + NSError *mountError = nil; + BXDrive *mountedDrive = [self mountDrive: siblingDrive + ifExists: BXDriveReplace + options: BXDefaultDriveMountOptions + error: &mountError]; + + if (!mountedDrive && mountError) + { + [self presentError: mountError + modalForWindow: self.windowForDriveSheet + delegate: nil + didPresentSelector: NULL + contextInfo: NULL]; + + //Don't continue mounting if we encounter a problem + break; + } + } + } +} + + (NSSet *) keyPathsForValuesAffectingCanCycleDrivesInQueues { return [NSSet setWithObject: @"drives"]; diff --git a/Boxer/DOS window/BXInputController+BXKeyboardInput.m b/Boxer/DOS window/BXInputController+BXKeyboardInput.m index d74b306a4..2bc9c036d 100644 --- a/Boxer/DOS window/BXInputController+BXKeyboardInput.m +++ b/Boxer/DOS window/BXInputController+BXKeyboardInput.m @@ -68,6 +68,14 @@ - (void) _syncKeyboardLayout - (void) keyDown: (NSEvent *)theEvent { + //Special handling for Cmd+F4 to cycle through mounted disc images + if ((theEvent.modifierFlags & NSEventModifierFlagCommand) == NSEventModifierFlagCommand && + theEvent.keyCode == kVK_F4) + { + [self cycleMountedDiscsForward: self]; + return; + } + //If the keypress was command-modified, don't pass it on to the emulator as it indicates //a failed key equivalent. //(This is consistent with how other OS X apps with textinput handle Cmd-keypresses.) @@ -230,6 +238,10 @@ - (IBAction) sendForwardSlash: (id)sender { [self.representedObject.emulator ha - (IBAction) sendColon: (id)sender { [self.representedObject.emulator handlePastedString: @":" asCommand: NO]; } - (IBAction) sendDash: (id)sender { [self.representedObject.emulator handlePastedString: @"-" asCommand: NO]; } +- (IBAction) cycleMountedDiscsForward: (id)sender +{ + [self.representedObject cycleMountedDiscsForward: sender]; +} - (void) type: (NSString *)message {