From ed5e1a9d5cf26aa0a018c61a142de1205711b305 Mon Sep 17 00:00:00 2001 From: Will Cobb Date: Tue, 12 Apr 2016 21:41:33 -0500 Subject: [PATCH] Bug fixes --- iNDS/AppDelegate.m | 30 ++++++++-------- iNDS/Base.lproj/MainStoryboard.storyboard | 44 +++++++++++------------ iNDS/RBVolumeButtons.m | 2 +- iNDS/core/Sound/iNDSMicrophone.m | 5 +++ iNDS/iNDSEmulatorViewController.mm | 31 +++++++++------- 5 files changed, 61 insertions(+), 51 deletions(-) diff --git a/iNDS/AppDelegate.m b/iNDS/AppDelegate.m index 53dda82..95773b9 100755 --- a/iNDS/AppDelegate.m +++ b/iNDS/AppDelegate.m @@ -13,8 +13,6 @@ #import "LZMAExtractor.h" #import "ZAActivityBar.h" - - #include #include @@ -27,7 +25,6 @@ #import #endif - @interface AppDelegate () { BOOL backgroundProcessesStarted; } @@ -122,8 +119,8 @@ - (BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceAppl } return YES; } - } else if (url.isFileURL && [[NSFileManager defaultManager] fileExistsAtPath:url.path] && ([url.path.stringByDeletingLastPathComponent.lastPathComponent isEqualToString:@"Inbox"] || [url.path.stringByDeletingLastPathComponent.lastPathComponent isEqualToString:@"tmp"])) { - NSLog(@"Zip File"); + } else if (url.isFileURL && [[NSFileManager defaultManager] fileExistsAtPath:url.path]) { + NSLog(@"Zip File (maybe)"); NSFileManager *fm = [NSFileManager defaultManager]; NSError *err = nil; if ([url.pathExtension.lowercaseString isEqualToString:@"zip"] || [url.pathExtension.lowercaseString isEqualToString:@"7z"] || [url.pathExtension.lowercaseString isEqualToString:@"rar"]) { @@ -135,7 +132,7 @@ - (BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceAppl NSLog(@"Could not create directory to expand zip: %@ %@", dstDir, err); [fm removeItemAtURL:url error:NULL]; [self showError:@"Unable to extract archive file."]; - [fm removeItemAtPath:[self.rootDocumentsPath stringByAppendingPathComponent:@"Inbox"] error:NULL]; + [fm removeItemAtPath:url.path error:NULL]; return NO; } @@ -148,7 +145,7 @@ - (BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceAppl if (![LZMAExtractor extract7zArchive:url.path tmpDirName:@"extract"]) { NSLog(@"Unable to extract 7z"); [self showError:@"Unable to extract .7z file."]; - [fm removeItemAtPath:[self.rootDocumentsPath stringByAppendingPathComponent:@"Inbox"] error:NULL]; + [fm removeItemAtPath:url.path error:NULL]; return NO; } } else { //Rar @@ -166,12 +163,12 @@ - (BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceAppl if (error) { NSLog(@"Unable to extract rar: %@", archiveError); [self showError:@"Unable to extract .rar file."]; - [fm removeItemAtPath:[self.rootDocumentsPath stringByAppendingPathComponent:@"Inbox"] error:NULL]; + [fm removeItemAtPath:url.path error:NULL]; return NO; } #else - [self showError:@"Rar support has been disabled due to code singing issues."]; - [fm removeItemAtPath:[self.rootDocumentsPath stringByAppendingPathComponent:@"Inbox"] error:NULL]; + [self showError:@"Rar support has been disabled due to code singing issues. It will return in a future update."]; + [fm removeItemAtPath:url.path error:NULL]; return NO; #endif } @@ -183,12 +180,10 @@ - (BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceAppl if ([path.pathExtension.lowercaseString isEqualToString:@"nds"] && ![[path.lastPathComponent substringToIndex:1] isEqualToString:@"."]) { NSLog(@"found ROM in zip: %@", path); [fm moveItemAtPath:[dstDir stringByAppendingPathComponent:path] toPath:[self.documentsPath stringByAppendingPathComponent:path.lastPathComponent] error:&error]; - if (error) NSLog(@"%@", error); [foundItems addObject:path.lastPathComponent]; } else if ([path.pathExtension.lowercaseString isEqualToString:@"dsv"]) { NSLog(@"found save in zip: %@", path); [fm moveItemAtPath:[dstDir stringByAppendingPathComponent:path] toPath:[self.batteryDir stringByAppendingPathComponent:path.lastPathComponent] error:&error]; - if (error) NSLog(@"%@", error); [foundItems addObject:path.lastPathComponent]; } else { BOOL isDirectory; @@ -198,6 +193,9 @@ - (BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceAppl } } } + if (error) { + NSLog(@"Error searching archive: %@", error); + } } if (foundItems.count == 0) { [self showError:@"No roms or saves found in archive. Make sure the zip contains a .nds file or a .dsv file"]; @@ -216,13 +214,15 @@ - (BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceAppl } else { NSLog(@"Invalid File!"); NSLog(@"%@", url.pathExtension.lowercaseString); + [fm removeItemAtPath:url.path error:NULL]; + [self showError:@"Unable to open file: Unknown extension"]; + } - // remove inbox (shouldn't be needed) - [fm removeItemAtPath:[self.rootDocumentsPath stringByAppendingPathComponent:@"Inbox"] error:NULL]; - + [fm removeItemAtPath:url.path error:NULL]; return YES; } else { [self showError:[NSString stringWithFormat:@"Unable to open file: Unknown Error (%i, %i, %@)", url.isFileURL, [[NSFileManager defaultManager] fileExistsAtPath:url.path], url]]; + [[NSFileManager defaultManager] removeItemAtPath:url.path error:NULL]; } return NO; diff --git a/iNDS/Base.lproj/MainStoryboard.storyboard b/iNDS/Base.lproj/MainStoryboard.storyboard index e414b6e..948983e 100755 --- a/iNDS/Base.lproj/MainStoryboard.storyboard +++ b/iNDS/Base.lproj/MainStoryboard.storyboard @@ -78,8 +78,8 @@ - - + + @@ -106,7 +106,7 @@ - + @@ -133,7 +133,7 @@ - + @@ -160,7 +160,7 @@ - + @@ -187,7 +187,7 @@ - + @@ -214,7 +214,7 @@ - + @@ -245,7 +245,7 @@ - + @@ -275,7 +275,7 @@ - + @@ -301,7 +301,7 @@ - + @@ -328,7 +328,7 @@ - + @@ -355,7 +355,7 @@ - + @@ -387,7 +387,7 @@ Enabling Dropbox will add an "iNDS" folder to your Dropbox account. Your game saves will be synced back to that folder so it will carry across devices (iPhone, iPad, iPod touch, Android, PC, etc). - + @@ -414,7 +414,7 @@ - + @@ -436,7 +436,7 @@ - + @@ -467,7 +467,7 @@ - + @@ -492,7 +492,7 @@ - + @@ -517,7 +517,7 @@ - + @@ -542,7 +542,7 @@ - + @@ -567,7 +567,7 @@ - + @@ -592,7 +592,7 @@ - + @@ -621,7 +621,7 @@ - + diff --git a/iNDS/RBVolumeButtons.m b/iNDS/RBVolumeButtons.m index cd7a71d..cecfdec 100755 --- a/iNDS/RBVolumeButtons.m +++ b/iNDS/RBVolumeButtons.m @@ -83,7 +83,7 @@ - (void)startStealingVolumeButtonEvents AudioSessionInitialize(NULL, NULL, NULL, NULL); - const UInt32 sessionCategory = kAudioSessionCategory_AmbientSound; + const UInt32 sessionCategory = kAudioSessionCategory_PlayAndRecord; AudioSessionSetProperty(kAudioSessionProperty_AudioCategory, sizeof(sessionCategory), &sessionCategory); AudioSessionSetActive(YES); diff --git a/iNDS/core/Sound/iNDSMicrophone.m b/iNDS/core/Sound/iNDSMicrophone.m index 67cc9de..3e3cbc9 100755 --- a/iNDS/core/Sound/iNDSMicrophone.m +++ b/iNDS/core/Sound/iNDSMicrophone.m @@ -70,6 +70,11 @@ -(void) microphone:(EZMicrophone *)microphone [self appendDataToCircularBuffer:&buffer fromAudioBufferList:bufferList]; } +- (void)microphone:(EZMicrophone *)microphone changedPlayingState:(BOOL)isPlaying +{ + NSLog(@"Microphone changed playing state to: %d", isPlaying); +} + -(void)appendDataToCircularBuffer:(TPCircularBuffer*)circularBuffer fromAudioBufferList:(AudioBufferList*)audioBufferList { TPCircularBufferProduceBytes(circularBuffer, audioBufferList->mBuffers[0].mData, audioBufferList->mBuffers[0].mDataByteSize); diff --git a/iNDS/iNDSEmulatorViewController.mm b/iNDS/iNDSEmulatorViewController.mm index bbd724b..6fc7c0e 100755 --- a/iNDS/iNDSEmulatorViewController.mm +++ b/iNDS/iNDSEmulatorViewController.mm @@ -294,28 +294,32 @@ - (void)defaultsChanged:(NSNotification*)notification NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults]; if (emuLoopLock) { //Only update these is the core has loaded EMU_setFrameSkip((int)[defaults integerForKey:@"frameSkip"]); - EMU_enableSound(![defaults boolForKey:@"disableSound"] && ![[AVAudioSession sharedInstance] secondaryAudioShouldBeSilencedHint]); + EMU_enableSound(![defaults boolForKey:@"disableSound"]); EMU_setSynchMode([defaults boolForKey:@"synchSound"]); + // Enable sound? + // (Mute on && don't ignore it) or user has sound disabled + BOOL muteSound = ([self muteButtonOn] && ![defaults boolForKey:@"ignoreMute"]) || [defaults boolForKey:@"disableSound"]; + EMU_enableSound(!muteSound); } self.directionalControl.style = [defaults integerForKey:@"controlPadStyle"]; self.fpsLabel.hidden = ![defaults integerForKey:@"showFPS"]; // For some reason both of these disable the mic -// if ([defaults integerForKey:@"volumeBumper"] && !settingsShown) { -// [volumeStealer startStealingVolumeButtonEvents]; -// } else { -// [volumeStealer stopStealingVolumeButtonEvents]; -// } - -// if ([defaults boolForKey:@"ignoreMute"]) { -// [[AVAudioSession sharedInstance] setCategory: AVAudioSessionCategoryPlayback error:nil]; -// } else { -// [[AVAudioSession sharedInstance] setCategory:AVAudioSessionCategoryAmbient error:nil]; -// } + if ([defaults integerForKey:@"volumeBumper"] && !settingsShown) { + [volumeStealer startStealingVolumeButtonEvents]; + } else { + [volumeStealer stopStealingVolumeButtonEvents]; + } [self.view setNeedsLayout]; } +// Not sure if we can figure this out +- (BOOL)muteButtonOn +{ + return NO; +} + -(BOOL) isPortrait { return UIInterfaceOrientationIsPortrait([UIApplication sharedApplication].statusBarOrientation); @@ -615,7 +619,8 @@ - (void)updateDisplay dispatch_async(dispatch_get_main_queue(), ^{ static CFTimeInterval fpsUpdateTime = 0; if (CACurrentMediaTime() - fpsUpdateTime > 1) { - self.fpsLabel.text = [NSString stringWithFormat:@"%d FPS (%d CORE)", MIN((int)coreFps, 60), (int)(coreFps / self.speed)]; + int fps = (int)(coreFps / self.speed); + self.fpsLabel.text = [NSString stringWithFormat:@"%d FPS (%d CORE)", MIN(fps, 60), fps]; fpsUpdateTime = CACurrentMediaTime(); } });