From 609b09af544e8adf4f1a841f77cfe3c1203173f4 Mon Sep 17 00:00:00 2001 From: "SND\\MaddTheSane_cp" Date: Sat, 5 Oct 2013 03:15:55 +0000 Subject: Don’t load old pad preferences on OS X if we already have new ones. Do a quick static analyze when building for release. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit git-svn-id: https://pcsxr.svn.codeplex.com/svn/pcsxr@87356 e17a0e51-4ae3-4d35-97c3-1a29b211df97 --- macosx/plugins/DFInput/macsrc/PadController.m | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) (limited to 'macosx/plugins/DFInput/macsrc/PadController.m') diff --git a/macosx/plugins/DFInput/macsrc/PadController.m b/macosx/plugins/DFInput/macsrc/PadController.m index b35e7439..c08ae578 100755 --- a/macosx/plugins/DFInput/macsrc/PadController.m +++ b/macosx/plugins/DFInput/macsrc/PadController.m @@ -131,20 +131,27 @@ static void SetDefaultConfig() { g.cfg.PadDef[1].KeyDef[DKEY_SQUARE].J.Button = 3; } - - void LoadPADConfig() { SetDefaultConfig(); - [[NSUserDefaults standardUserDefaults] registerDefaults: + BOOL tryToLoadOld = YES; + //Do we have the new settings? + //This is placed here so we don't have the prefskey defined. + NSUserDefaults *usrDefaults = [NSUserDefaults standardUserDefaults]; + if ([usrDefaults objectForKey:PrefsKey]) { + //Yes we do, don't load the old. + tryToLoadOld = NO; + } + + [usrDefaults registerDefaults: @{PrefsKey: @{kDFPad1: DefaultPadArray(0), kDFPad2: DefaultPadArray(1), kDFThreading: @YES}}]; - //Load the old preferences if present. + //Load the old preferences if present and we don't have new ones. NSFileManager *fm = [NSFileManager defaultManager]; NSString *oldPrefPath = [NSString pathWithComponents:@[NSHomeDirectory(), @"Library", @"Preferences", @"net.pcsxr.DFInput.plist"]]; - if ([fm fileExistsAtPath:oldPrefPath]) { + if ([fm fileExistsAtPath:oldPrefPath] && tryToLoadOld) { char buf[256] = {0}; int current = 0, a = 0, b = 0, c = 0; @@ -301,7 +308,7 @@ void LoadPADConfig() //Delete the old preferences [fm removeItemAtPath:oldPrefPath error:NULL]; } else { - NSDictionary *dfPrefs = [[NSUserDefaults standardUserDefaults] dictionaryForKey:PrefsKey]; + NSDictionary *dfPrefs = [usrDefaults dictionaryForKey:PrefsKey]; g.cfg.Threaded = [dfPrefs[kDFThreading] boolValue]; LoadPadArray(0, dfPrefs[kDFPad1]); LoadPadArray(1, dfPrefs[kDFPad2]); -- cgit v1.2.3