From 4b66a6a955b16737eb0e9b03b6c437ccdc44e368 Mon Sep 17 00:00:00 2001 From: Michael Buckley Date: Sun, 25 Apr 2021 17:44:40 -0700 Subject: [PATCH] Mac: refactor preferences code, fix a couple connections, and add new icons --- macosx/Snes9x/AppDelegate.h | 6 +- macosx/Snes9x/AppDelegate.m | 5 +- macosx/Snes9x/Assets.xcassets/Contents.json | 6 +- .../display.imageset/Contents.json | 18 + .../display.imageset/display.png | Bin 0 -> 300 bytes .../display.imageset/display@2x.png | Bin 0 -> 415 bytes .../emulation.imageset/Contents.json | 18 + .../emulation.imageset/emulation.png | Bin 0 -> 625 bytes .../emulation.imageset/emulation@2x.png | Bin 0 -> 774 bytes .../files.imageset/Contents.json | 18 + .../Assets.xcassets/files.imageset/files.png | Bin 0 -> 459 bytes .../files.imageset/files@2x.png | Bin 0 -> 610 bytes .../gamepad.imageset/Contents.json | 18 + .../gamepad.imageset/gamepad.png | Bin 0 -> 423 bytes .../gamepad.imageset/gamepad@2x.png | Bin 0 -> 496 bytes .../sound.imageset/Contents.json | 18 + .../Assets.xcassets/sound.imageset/sound.png | Bin 0 -> 329 bytes .../sound.imageset/sound@2x.png | Bin 0 -> 520 bytes .../S9xControlsPreferencesViewController.h | 29 + .../S9xControlsPreferencesViewController.m | 294 +++ .../S9xControlsPreferencesViewController.xib | 775 ++++++++ .../S9xDisplayPreferencesViewController.h | 29 + .../S9xDisplayPreferencesViewController.m | 140 ++ .../S9xDisplayPreferencesViewController.xib | 164 ++ .../S9xEmulationPreferencesViewController.h | 29 + .../S9xEmulationPreferencesViewController.m | 40 + .../S9xEmulationPreferencesViewController.xib | 41 + .../S9xFilesPreferencesViewController.h | 29 + .../S9xFilesPreferencesViewController.m | 40 + .../S9xFilesPreferencesViewController.xib | 41 + .../S9xGamepadPreferencesViewController.m | 281 +++ .../S9xPreferences/S9xPreferencesConstants.h | 32 + .../S9xPreferences/S9xPreferencesConstants.m | 28 + .../S9xPreferencesTabViewController.h | 29 + .../S9xPreferencesTabViewController.m | 79 + .../S9xPreferencesViewController.h | 33 + .../S9xPreferencesViewController.m | 40 + .../S9xPreferencesWindowController.h | 26 +- .../S9xPreferencesWindowController.m | 379 +--- .../S9xPreferencesWindowController.xib | 1569 +---------------- .../S9xSoundPreferencesViewController.h | 29 + .../S9xSoundPreferencesViewController.m | 40 + .../S9xSoundPreferencesViewController.xib | 41 + macosx/snes9x.xcodeproj/project.pbxproj | 68 + 44 files changed, 2509 insertions(+), 1923 deletions(-) create mode 100644 macosx/Snes9x/Assets.xcassets/display.imageset/Contents.json create mode 100644 macosx/Snes9x/Assets.xcassets/display.imageset/display.png create mode 100644 macosx/Snes9x/Assets.xcassets/display.imageset/display@2x.png create mode 100644 macosx/Snes9x/Assets.xcassets/emulation.imageset/Contents.json create mode 100644 macosx/Snes9x/Assets.xcassets/emulation.imageset/emulation.png create mode 100644 macosx/Snes9x/Assets.xcassets/emulation.imageset/emulation@2x.png create mode 100644 macosx/Snes9x/Assets.xcassets/files.imageset/Contents.json create mode 100644 macosx/Snes9x/Assets.xcassets/files.imageset/files.png create mode 100644 macosx/Snes9x/Assets.xcassets/files.imageset/files@2x.png create mode 100644 macosx/Snes9x/Assets.xcassets/gamepad.imageset/Contents.json create mode 100644 macosx/Snes9x/Assets.xcassets/gamepad.imageset/gamepad.png create mode 100644 macosx/Snes9x/Assets.xcassets/gamepad.imageset/gamepad@2x.png create mode 100644 macosx/Snes9x/Assets.xcassets/sound.imageset/Contents.json create mode 100644 macosx/Snes9x/Assets.xcassets/sound.imageset/sound.png create mode 100644 macosx/Snes9x/Assets.xcassets/sound.imageset/sound@2x.png create mode 100644 macosx/Snes9x/S9xPreferences/S9xControlsPreferencesViewController.h create mode 100644 macosx/Snes9x/S9xPreferences/S9xControlsPreferencesViewController.m create mode 100644 macosx/Snes9x/S9xPreferences/S9xControlsPreferencesViewController.xib create mode 100644 macosx/Snes9x/S9xPreferences/S9xDisplayPreferencesViewController.h create mode 100644 macosx/Snes9x/S9xPreferences/S9xDisplayPreferencesViewController.m create mode 100644 macosx/Snes9x/S9xPreferences/S9xDisplayPreferencesViewController.xib create mode 100644 macosx/Snes9x/S9xPreferences/S9xEmulationPreferencesViewController.h create mode 100644 macosx/Snes9x/S9xPreferences/S9xEmulationPreferencesViewController.m create mode 100644 macosx/Snes9x/S9xPreferences/S9xEmulationPreferencesViewController.xib create mode 100644 macosx/Snes9x/S9xPreferences/S9xFilesPreferencesViewController.h create mode 100644 macosx/Snes9x/S9xPreferences/S9xFilesPreferencesViewController.m create mode 100644 macosx/Snes9x/S9xPreferences/S9xFilesPreferencesViewController.xib create mode 100644 macosx/Snes9x/S9xPreferences/S9xGamepadPreferencesViewController.m create mode 100644 macosx/Snes9x/S9xPreferences/S9xPreferencesConstants.h create mode 100644 macosx/Snes9x/S9xPreferences/S9xPreferencesConstants.m create mode 100644 macosx/Snes9x/S9xPreferences/S9xPreferencesTabViewController.h create mode 100644 macosx/Snes9x/S9xPreferences/S9xPreferencesTabViewController.m create mode 100644 macosx/Snes9x/S9xPreferences/S9xPreferencesViewController.h create mode 100644 macosx/Snes9x/S9xPreferences/S9xPreferencesViewController.m create mode 100644 macosx/Snes9x/S9xPreferences/S9xSoundPreferencesViewController.h create mode 100644 macosx/Snes9x/S9xPreferences/S9xSoundPreferencesViewController.m create mode 100644 macosx/Snes9x/S9xPreferences/S9xSoundPreferencesViewController.xib diff --git a/macosx/Snes9x/AppDelegate.h b/macosx/Snes9x/AppDelegate.h index 02784c2a..11c52e4d 100644 --- a/macosx/Snes9x/AppDelegate.h +++ b/macosx/Snes9x/AppDelegate.h @@ -1,6 +1,6 @@ /*****************************************************************************\ - Snes9x - Portable Super Nintendo Entertainment System (TM) emulator. - This file is licensed under the Snes9x License. + Snes9x - Portable Super Nintendo Entertainment System (TM) emulator. + This file is licensed under the Snes9x License. For further information, consult the LICENSE file in the root directory. \*****************************************************************************/ @@ -15,7 +15,7 @@ (c) Copyright 2004 Alexander and Sander (c) Copyright 2004 - 2005 Steven Seeger (c) Copyright 2005 Ryan Vogt - (c) Copyright 2019 Michael Donald Buckley + (c) Copyright 2019 - 2021 Michael Donald Buckley ***********************************************************************************/ #import diff --git a/macosx/Snes9x/AppDelegate.m b/macosx/Snes9x/AppDelegate.m index 869784a9..44c9d427 100644 --- a/macosx/Snes9x/AppDelegate.m +++ b/macosx/Snes9x/AppDelegate.m @@ -20,6 +20,7 @@ #import #import "AppDelegate.h" +#import "S9xPreferencesConstants.h" NSWindowFrameAutosaveName const kMainWindowIdentifier = @"s9xMainWindow"; @@ -212,7 +213,7 @@ NSWindowFrameAutosaveName const kMainWindowIdentifier = @"s9xMainWindow"; { [self.s9xEngine clearButton:button forPlayer:player]; NSMutableDictionary *keyDict = [[NSUserDefaults.standardUserDefaults objectForKey:kKeyboardPrefs] mutableCopy]; - [keyDict removeObjectForKey:@(button).stringValue]; + [keyDict removeObjectForKey:@(button + (kNumButtons * player)).stringValue]; [NSUserDefaults.standardUserDefaults setObject:[keyDict copy] forKey:kKeyboardPrefs]; [NSUserDefaults.standardUserDefaults synchronize]; } @@ -549,7 +550,7 @@ NSWindowFrameAutosaveName const kMainWindowIdentifier = @"s9xMainWindow"; { if (NSApp.keyWindow != nil && NSApp.keyWindow == self.preferencesWindowController.window) { - return [((S9xPreferencesWindowController *) self.preferencesWindowController.contentViewController) handleInput:input fromJoypad:joypad]; + return [((S9xPreferencesWindowController *) self.preferencesWindowController) handleInput:input fromJoypad:joypad]; } return NO; diff --git a/macosx/Snes9x/Assets.xcassets/Contents.json b/macosx/Snes9x/Assets.xcassets/Contents.json index da4a164c..73c00596 100644 --- a/macosx/Snes9x/Assets.xcassets/Contents.json +++ b/macosx/Snes9x/Assets.xcassets/Contents.json @@ -1,6 +1,6 @@ { "info" : { - "version" : 1, - "author" : "xcode" + "author" : "xcode", + "version" : 1 } -} \ No newline at end of file +} diff --git a/macosx/Snes9x/Assets.xcassets/display.imageset/Contents.json b/macosx/Snes9x/Assets.xcassets/display.imageset/Contents.json new file mode 100644 index 00000000..2bb5913e --- /dev/null +++ b/macosx/Snes9x/Assets.xcassets/display.imageset/Contents.json @@ -0,0 +1,18 @@ +{ + "images" : [ + { + "filename" : "display.png", + "idiom" : "mac", + "scale" : "1x" + }, + { + "filename" : "display@2x.png", + "idiom" : "mac", + "scale" : "2x" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/macosx/Snes9x/Assets.xcassets/display.imageset/display.png b/macosx/Snes9x/Assets.xcassets/display.imageset/display.png new file mode 100644 index 0000000000000000000000000000000000000000..393227363a6cddb54e2172fdabdb8eb9add47f62 GIT binary patch literal 300 zcmV+{0n`48P)Px#=1D|BR9J=WmO&DOAPhxA#{;ZW&r-0Lxmti-~hCIhM@8 zUglJ+%?wO3##9-5@5y&afEsf=hk{`F2y<4>3Qz(ez70=+6X5s&C40JNZq`x!4+N!T z2DbiSrOJ&J$9{GO(5f+=Bz_LyJjM`06H~4A y?7b*~zuuYvU>&Oj65gr3#09hR6EA@{fVf^l$xDwo3wK8V0000J4lQSQm7DV^rL= zZt|6hKKH-RewWO2?cRjw)75*{ZS_oGTEdleJ8ad8{RQVbryOQkBDUb_r-fBPlLKm* zx(p9ks(;%*Kd6VXTG5OvLve1?D`5xb3rrU-Fl=EkF=5bU;N^ATc5sFZo!snbZ~b^y z!orTV>~A(kEoKzn@QrQ%=SjEu1i!PHZ`#R!<5fkT0pl&vzQ>=EJFeY2`uP%wm$kis zM@^yZ;Kg|of0zAY0h?YN`zfQx@UVe~_s!|cGXJ>m(>GAH;M(yzHkiE!>IxS3M&`qT y38!YQjLbawPx%D@jB_R9J=WS5HXWP#pdulL|5>vmszFkugC~q)^z=4P_t*yDf|%_ONsC?vC?3 z$=S;o2swEf2t#K*4hlt73Xai-2O+$oJ9G%6&>iBdN!~9>o2Ko>@09m@?|r{7FTX!8 zz>uMY*jt10_lR=5v|YA?3mIeBc{6FmdH8hl*k+7D*L7*`aHAkztS!VVphY>Rghb)v zf^K|ZAbAA;oe%{8M&cay8^KQyi(;{e>8B<+SG%@QDwX;xKwxd+)HnY6XFd^6VgX4V z1|h}3fq4}g>3f%B*xIj!l5OqRuy;8YI!|#+C$MZy#b&~bcMF()Hi@HZ6MxlTSk2DH zZ3*R0lm+bH6W{n-y^5o169902GaCB>UXU^1INznCYBV^2w*Y`wv-jJ^`Ez%iz2Dnt za5&C|#H(qqC2?H^q4jx}wErxNrys7PLg%y{uXM`p5w|LqG^gavwq41aaLP@nD>4UF zMY~QzB~KS2VQ*C|at-Gk`sla;0KaUC-ovf#~he z?QTeAK^hQQaJW%0gm2#`5JBRmT>7}ZjR`_=iJ)>g4QQIn9~p!P=9MwO>9=v7>_k*m zmAHfDIHVVxwPS#D?js70gF>U$rq&D6#DjpL3m{8zFzVyRovzii4h783y|)*2w;Fya z&DiTNFA`No@7`l3-vxj!?}WXA;wF1Rzv1l#J^_Pp?m^g(@nG>E7wFj5yvOu`00000 LNkvXXu0mjf62l%@ literal 0 HcmV?d00001 diff --git a/macosx/Snes9x/Assets.xcassets/emulation.imageset/emulation@2x.png b/macosx/Snes9x/Assets.xcassets/emulation.imageset/emulation@2x.png new file mode 100644 index 0000000000000000000000000000000000000000..7bdd38d25c0481b33202111a1d1906d4dd4a0049 GIT binary patch literal 774 zcmV+h1Nr=kP)Px%z)3_wRCt{2nn7q2K@^7niiJWE#dcZH%LY*>v=kxWQN7lT0Q4f`X6yl+oCOgbz-)whx68C+l?9Q8+KQlkO zZ)O%?ip`ioY$r1n*+BYl$Ff#2>>M9Z7MbyD&sq&igTC(r0G{8Tsw9`yHyaRXuYzwf>ptnFO zRI610KSv5HvDe!Z0DzBgw-O0^(yjL+oJdrks+%1U7hpQ`IxgLv2LP1LO#uK_*Y*Jb zf1C{fz|HBIG`cy2s+%2uj^jtX8?uFo&oizuZ-e9wd6bRBUf%Y z8>#Gov>Oas`;qI;=Q^q0*u|PMUfdV$IyY!KsC$v@fUG+ZGnh19ID*aFrdgLa!UK@wUA$X{Ym*Wts0>qhl+Ca8gYE-?3SaGc1& z^FqAub?~_W5rcDqZ^}GC%)D+!;>vX#wOu|JAi@J+TYznN0Bj4e4G(~A0k+`*ur0tg zq%$X}9aTwD#En)WF%<#RdRe_M&@(FPaw`0C4}xdaiqhx_&?SwC@50g?B*g z04&#bDq?LtN>Ftd-T~xufl-Ig1vF?K@E^ktV3;2N0HLkm>=k=(R{#J207*qoM6N<$ Ef`*M^?*IS* literal 0 HcmV?d00001 diff --git a/macosx/Snes9x/Assets.xcassets/files.imageset/Contents.json b/macosx/Snes9x/Assets.xcassets/files.imageset/Contents.json new file mode 100644 index 00000000..1064f03e --- /dev/null +++ b/macosx/Snes9x/Assets.xcassets/files.imageset/Contents.json @@ -0,0 +1,18 @@ +{ + "images" : [ + { + "filename" : "files.png", + "idiom" : "mac", + "scale" : "1x" + }, + { + "filename" : "files@2x.png", + "idiom" : "mac", + "scale" : "2x" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/macosx/Snes9x/Assets.xcassets/files.imageset/files.png b/macosx/Snes9x/Assets.xcassets/files.imageset/files.png new file mode 100644 index 0000000000000000000000000000000000000000..034bc2cdb4cfcaaf135183edc909e64c20125d14 GIT binary patch literal 459 zcmV;+0W|)JP)Px$g-Jv~R9J<@mpg95FbsyNq6py3$sS}8e2)z2qC;d0kVEJYoqGsREzpa233>p} zG0;UFQn?iMmgV#Zj7SPiexPKDVqi<5Hgo(>ZLm`84IBD`y1j3v&iXhwy`8F8h$>l&lwWNKyd|CiGS|0~*+EX;G5ECIuKhxB?|d8 z04QZGn9zbY0C2#XUjg+E@aNkAXtm z;Pd;<=pR<6B0oj@01fUNTMR%;2*HF9z9V>ffEt>$2)nNH6(-5b%D`^Ffrd-xf;+5E z&~TZ(duC@~?ByMzHz67>i}sPCDbNsftVBrw&U4{Px%97#k$RCt{2n>|hgF%X4k5v&9?^bt*zh8v_y0d0;zhr}T`1T{xU4H8{$kSVpa4%< zW8_2m*wiyWx*mp~KZ@G>%}1|*Q>}uF0H9K8ZC0oDVs z#w-W)g>=`FfC97%L%ZKgv>hiDAQ`l4X=uubz4jeYfMk#&+;*mOAuH2AZYV%9oR6Qp z<&$y!cf0o6t(e?BD>WXyrBHxm7+Qoi+Kv|ruPU+`ua`>+P=I0Id{ruH^*9wruK-Md^#H7~%mF6XJO>Ks%dz`1(^b07*qoM6N<$f@_o%EC2ui literal 0 HcmV?d00001 diff --git a/macosx/Snes9x/Assets.xcassets/gamepad.imageset/Contents.json b/macosx/Snes9x/Assets.xcassets/gamepad.imageset/Contents.json new file mode 100644 index 00000000..27fb69c7 --- /dev/null +++ b/macosx/Snes9x/Assets.xcassets/gamepad.imageset/Contents.json @@ -0,0 +1,18 @@ +{ + "images" : [ + { + "filename" : "gamepad.png", + "idiom" : "mac", + "scale" : "1x" + }, + { + "filename" : "gamepad@2x.png", + "idiom" : "mac", + "scale" : "2x" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/macosx/Snes9x/Assets.xcassets/gamepad.imageset/gamepad.png b/macosx/Snes9x/Assets.xcassets/gamepad.imageset/gamepad.png new file mode 100644 index 0000000000000000000000000000000000000000..3367d006cc57237f9ec3cdfa4c70545acd3ae6ce GIT binary patch literal 423 zcmV;Y0a*TtP)Px$VM#P0LP;mfG8kh@0I=3ZzjO#hBrau)0RW7Ad7Jp@@foxE zwCdN9cd>a=pNL8cAuG@+kBPeE*~1$Ez}%b%f!u1S5i_GGieR$V8UT>zIcD=|5Ta=X z>H)jP_#v1X3JqWH2k470h&?BwFo1~b^bKYd-O3uD_sL{RP!1|hz421EcH59Q=+4FGs~KYWohvx@$PLlKc5py@YM zK>Q*SPx$s!2paRCt{2nLSR#FcgF*C>0W-;}l44as@X?RGfikJ1BF2l+bO%8K{tGe1$ZT z_7rpoiFRq$5I^EL&fg+DU$yo+_KRos`DXz_2qAeIIT7lM#XZ zD~8Nc?9Bf)df$-_kQG{M0Dv*ZQNC%Kl|q^arIb_FT4w-YjB)CdcR+4GNabS{e|dfd z09@Z(b=HTF&rKaq#;=sx1HYY+yaU=fV3P8ZSVd#Uv;FI*cjtR^d*0d3(#j1PKnEZ% ziUI&o*L82hvMil)RaF3fX4vP1p*cV@HkbIum;KrIPTm0-2LASa4pYbuTtElF z;{d66h@~BI_jd1;A1@x9vQ++bpK04&>n`^J1MP9pkGH5t}0<$va@RRbZ_0 zp*{cD)qy$SK-Ss`_B!EM`v8mF30fsD&o)l|?ql2eoK(Ij3Z4ak8BT+1BNg>IfTzKM zd^=$3jgUm%$xTJZ6T3Rtcz7cunC(_rDsHoE=$;{jT&2dw!&_kw!GDH)3UsuaMe()c mN!|g35JCtcgb+dqNslk0=-CP(<6cw%0000Px$14%?dR9J=WmN5>(FbqY%5fTSr>QHs)%$0h$T#30u)u9tB5|bHdQAuKlG>9M( zPigA!ygF_if^2L(lj6HsztbWZV_=MlTsKay0(`@=1MEF>_TJg^p<0O2+rb!sxNlw8 zNxIE?2Y^}nfLTDK0`yg_>f332(PyuL0#E>)b6^;Tq=4t!B@Liynk0bJ;TZ6^>HsAJ zf0u#mzo894bF=Xp5rLUShrX(5ZZ=-C8<7tH%KBGS7XO~H=;E~#G0;!?gl`h2#E+<%0t#pBea?TN(M>>ejo$t{XW9~)B2Y{DQO7m bvp1tVi%fo>n)r^Y00000NkvXXu0mjf-9(KY literal 0 HcmV?d00001 diff --git a/macosx/Snes9x/Assets.xcassets/sound.imageset/sound@2x.png b/macosx/Snes9x/Assets.xcassets/sound.imageset/sound@2x.png new file mode 100644 index 0000000000000000000000000000000000000000..50b6a167b6a633ba0f3e86e0f7546e91c79b1c08 GIT binary patch literal 520 zcmeAS@N?(olHy`uVBq!ia0vp^4j|0I1|(Ny7TyC=jKx9jP7LeL$-D%z4|%#chE&XX zJKHe7*+8Im{%Wl)#mo6bou8ePocWtM;%DKSKMm)4=319KNE(&q&ekjGTrF@^;`V`) zANJ`c+_#n0f6ige^=`|w-=~z9Mf{u1pxFK3T6t3Bw7KV916jH!p4eZ-zJcKq(~?BS zC9EFCDWV(J?%wus;eKwlvp|_Iq056$o-Vz9Y-;JvtDKvkEN8BIx0T_-wsr9byIEe@ zw@zoalbhf4DWCuMy+5nV8Mqa69i+q@q8dze8n!TGMlfVDUIH7waUXxitTaAZw|o8b zCm&nRoWp#{WUh1j#OF^G4Gx9BkF`2r)?l0Pa05GwTff}52G7Or4Al+^UtWM6mHdXW za-KFrfLG;PftRw1vddR#E&r)s{+)|qTl?PYd=u{pUMh^M-?zRmdN1>u-=&e$7#Uve zl6%7P_sM3R;N_K$Oy#p#7(RTfmH`Qs&vu#n>}%h0W|?DUG6maSb07Y?(Z2`Abo?3q zp5guEMGK#^IdR&WFIdQ2qdu$ZK+KG)2JMoD_b%TWS`Ww>w9S~2$S + +#import "AppDelegate.h" +#import "S9xButtonConfigTextField.h" +#import "S9xPreferencesConstants.h" +#import "S9xControlsPreferencesViewController.h" + +@interface S9xControlsPreferencesViewController () +@property (nonatomic, weak) IBOutlet NSPopUpButton *devicePopUp; +@property (nonatomic, weak) IBOutlet NSPopUpButton *playerPopUp; +@property (nonatomic, strong) NSArray *configTextFields; +@end + +@implementation S9xControlsPreferencesViewController + +- (instancetype)init +{ + if (self = [super initWithNibName:@"S9xControlsPreferencesViewController" bundle:nil]) + { + self.title = NSLocalizedString(@"Controls", nil); + self.image = [NSImage imageNamed:@"gamepad"]; + } + + return self; +} + +- (void)viewDidLoad { + [super viewDidLoad]; + + AppDelegate *appDelegate = (AppDelegate *)NSApp.delegate; + NSUInteger joypadIndex = 0; + for (S9xJoypad *joypad in [appDelegate listJoypads]) + { + NSMenuItem *item = [NSMenuItem new]; + item.title = joypad.name; + item.tag = joypadIndex++; + item.representedObject = joypad; + [self.devicePopUp.menu addItem:item]; + } + + // collect all S9xButtonConfigTextFields within subviews + NSMutableArray *configTextFields = [[NSMutableArray alloc] init]; + + for ( NSView *view in self.view.subviews ) + { + if ([view isKindOfClass:[S9xButtonConfigTextField class]]) + { + [configTextFields addObject:view]; + } + } + + self.configTextFields = configTextFields; + + for (S9xButtonConfigTextField *configTextField in self.configTextFields) + { + [configTextField addObserver:self forKeyPath:@"keyCode" options:NSKeyValueObservingOptionNew context:NULL]; + [configTextField addObserver:self forKeyPath:@"joypadInput" options:NSKeyValueObservingOptionNew context:NULL]; + } + + // select Keyboard as default + [self selectDeviceForPlayer:0]; + +} + +- (void)refresh +{ + if (self.devicePopUp.selectedItem.tag < 0) + { + NSMutableDictionary *controlsDict = [NSMutableDictionary new]; + + NSDictionary *keyboardDict = [NSUserDefaults.standardUserDefaults objectForKey:kKeyboardPrefs]; + NSInteger playerNum = self.playerPopUp.selectedItem.tag; + + for (NSUInteger i = 0; i < kNumButtons; ++i) + { + controlsDict[@(i)] = keyboardDict[@(i + (playerNum * kNumButtons)).stringValue]; + } + + for (S9xButtonConfigTextField *configTextField in self.configTextFields) + { + [configTextField removeObserver:self forKeyPath:@"keyCode"]; + [configTextField removeObserver:self forKeyPath:@"joypadInput"]; + + NSNumber *keyCode = controlsDict[@(configTextField.tag)]; + + configTextField.joypadInput = nil; + + if ( keyCode != nil ) + { + configTextField.keyCode = keyCode.intValue; + } + else + { + configTextField.keyCode = -1; + } + + [configTextField addObserver:self forKeyPath:@"keyCode" options:NSKeyValueObservingOptionNew context:NULL]; + [configTextField addObserver:self forKeyPath:@"joypadInput" options:NSKeyValueObservingOptionNew context:NULL]; + + configTextField.disableKeyboardInput = NO; + } + } + else + { + AppDelegate *appDelegate = (AppDelegate *)NSApp.delegate; + S9xJoypad *joypad = self.devicePopUp.selectedItem.representedObject; + NSString *joypadKey = [appDelegate prefsKeyForVendorID:joypad.vendorID productID:joypad.productID index:joypad.index]; + NSDictionary *joypadDIct = [[NSUserDefaults.standardUserDefaults objectForKey:kJoypadInputPrefs] objectForKey:joypadKey]; + + for (S9xButtonConfigTextField *configTextField in self.configTextFields) + { + [configTextField removeObserver:self forKeyPath:@"keyCode"]; + [configTextField removeObserver:self forKeyPath:@"joypadInput"]; + + uint32 cookie = 0; + int32 value = 0; + S9xButtonCode buttonCode = (S9xButtonCode)configTextField.tag; + NSString *inputString = joypadDIct[@(buttonCode).stringValue]; + + configTextField.keyCode = -1; + + if ([appDelegate getValuesFromString:inputString cookie:&cookie value:&value]) + { + S9xJoypadInput *input = [S9xJoypadInput new]; + input.cookie = cookie; + input.value = value; + input.buttonCode = buttonCode; + configTextField.joypadInput = input; + configTextField.stringValue = [appDelegate labelForVendorID:joypad.vendorID productID:joypad.productID cookie:cookie value:value]; + } + else + { + configTextField.joypadInput = nil; + configTextField.stringValue = @""; + } + + [configTextField addObserver:self forKeyPath:@"keyCode" options:NSKeyValueObservingOptionNew context:NULL]; + [configTextField addObserver:self forKeyPath:@"joypadInput" options:NSKeyValueObservingOptionNew context:NULL]; + + configTextField.disableKeyboardInput = YES; + } + } +} + +- (void)selectDeviceForPlayer:(int8_t)player +{ + AppDelegate *appDelegate = (AppDelegate *)NSApp.delegate; + NSString* joypadKey = [[NSUserDefaults.standardUserDefaults objectForKey:kJoypadPlayerPrefs] objectForKey:@(player).stringValue]; + + [self.devicePopUp selectItemAtIndex:0]; + + if (joypadKey != nil) + { + uint32 vendorID = 0; + uint32 productID = 0; + uint32 index = 0; + + if ( [appDelegate getValuesFromString:joypadKey vendorID:&vendorID productID:&productID index:&index]) + { + S9xJoypad *joypad = [S9xJoypad new]; + joypad.vendorID = vendorID; + joypad.productID = productID; + joypad.index = index; + + for (NSMenuItem *item in self.devicePopUp.menu.itemArray) + { + if ([joypad isEqual:item.representedObject]) + { + [self.devicePopUp selectItem:item]; + break; + } + } + } + } +} + +- (BOOL)handleInput:(S9xJoypadInput *)input fromJoypad:(S9xJoypad *)joypad +{ + id firstResponder = self.view.window.firstResponder; + + if ([firstResponder respondsToSelector:@selector(isFieldEditor)] && [firstResponder isFieldEditor]) + { + firstResponder = [firstResponder delegate]; + } + + if ([firstResponder respondsToSelector:@selector(setJoypadInput:)]) + { + S9xJoypad *currentJoypad = self.devicePopUp.selectedItem.representedObject; + + if ([joypad isEqual:currentJoypad]) + { + [firstResponder setJoypadInput:input]; + return YES; + } + } + + return NO; +} + +- (void)deviceSettingChanged:(S9xDeviceSetting)deviceSetting {} + +- (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context +{ + if ([keyPath isEqualToString:@"keyCode"]) + { + S9xButtonConfigTextField *field = (S9xButtonConfigTextField *)object; + S9xButtonCode buttonCode = (S9xButtonCode)field.tag; + uint16_t keyCode = field.keyCode; + int8_t player = self.playerPopUp.selectedItem.tag; + + if (keyCode != (CGKeyCode)-1) + { + [((AppDelegate *) NSApp.delegate) setButtonCode:buttonCode forKeyCode:keyCode player:player]; + } + else + { + [((AppDelegate *) NSApp.delegate) clearButton:buttonCode forPlayer:player]; + } + + [NSUserDefaults.standardUserDefaults synchronize]; + + [self refresh]; + } + else if ( [keyPath isEqualToString:@"joypadInput"]) + { + S9xButtonConfigTextField *field = (S9xButtonConfigTextField *)object; + S9xButtonCode buttonCode = (S9xButtonCode)field.tag; + S9xJoypad *joypad = self.devicePopUp.selectedItem.representedObject; + + if ([joypad isKindOfClass:[S9xJoypad class]]) + { + S9xJoypadInput *input = field.joypadInput; + + if (input != nil) + { + [((AppDelegate *)NSApp.delegate) setButton:buttonCode forVendorID:joypad.vendorID productID:joypad.productID index:joypad.index cookie:input.cookie value:input.value]; + } + else + { + [((AppDelegate *)NSApp.delegate) clearJoypadForVendorID:joypad.vendorID productID:joypad.productID index:joypad.index buttonCode:buttonCode]; + } + } + + [NSUserDefaults.standardUserDefaults synchronize]; + [self refresh]; + } +} + +- (IBAction)playerDropdownChanged:(NSPopUpButton *)sender +{ + [self selectDeviceForPlayer:sender.selectedTag]; + [self refresh]; +} + +- (IBAction)deviceDropdownChanged:(NSPopUpButton *)sender +{ + AppDelegate *appDelegate = (AppDelegate *)NSApp.delegate; + + if (sender.selectedTag >= 0) + { + S9xJoypad *joypad = sender.selectedItem.representedObject; + [appDelegate setPlayer:self.playerPopUp.selectedTag forVendorID:joypad.vendorID productID:joypad.productID index:joypad.index]; + } + else + { + [appDelegate setPlayer:self.playerPopUp.selectedTag forVendorID:0 productID:0 index:0]; + } + + [NSUserDefaults.standardUserDefaults synchronize]; + [self refresh]; +} + + +@end diff --git a/macosx/Snes9x/S9xPreferences/S9xControlsPreferencesViewController.xib b/macosx/Snes9x/S9xPreferences/S9xControlsPreferencesViewController.xib new file mode 100644 index 00000000..d57574b9 --- /dev/null +++ b/macosx/Snes9x/S9xPreferences/S9xControlsPreferencesViewController.xib @@ -0,0 +1,775 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/macosx/Snes9x/S9xPreferences/S9xDisplayPreferencesViewController.h b/macosx/Snes9x/S9xPreferences/S9xDisplayPreferencesViewController.h new file mode 100644 index 00000000..7a100fb5 --- /dev/null +++ b/macosx/Snes9x/S9xPreferences/S9xDisplayPreferencesViewController.h @@ -0,0 +1,29 @@ +/*****************************************************************************\ + Snes9x - Portable Super Nintendo Entertainment System (TM) emulator. + This file is licensed under the Snes9x License. + For further information, consult the LICENSE file in the root directory. +\*****************************************************************************/ + +/*********************************************************************************** + SNES9X for Mac OS (c) Copyright John Stiles + + Snes9x for Mac OS X + + (c) Copyright 2001 - 2011 zones + (c) Copyright 2002 - 2005 107 + (c) Copyright 2002 PB1400c + (c) Copyright 2004 Alexander and Sander + (c) Copyright 2004 - 2005 Steven Seeger + (c) Copyright 2005 Ryan Vogt + (c) Copyright 2019 - 2021 Michael Donald Buckley + ***********************************************************************************/ + +#import "S9xPreferencesViewController.h" + +NS_ASSUME_NONNULL_BEGIN + +@interface S9xDisplayPreferencesViewController : S9xPreferencesViewController + +@end + +NS_ASSUME_NONNULL_END diff --git a/macosx/Snes9x/S9xPreferences/S9xDisplayPreferencesViewController.m b/macosx/Snes9x/S9xPreferences/S9xDisplayPreferencesViewController.m new file mode 100644 index 00000000..6031253e --- /dev/null +++ b/macosx/Snes9x/S9xPreferences/S9xDisplayPreferencesViewController.m @@ -0,0 +1,140 @@ +/*****************************************************************************\ + Snes9x - Portable Super Nintendo Entertainment System (TM) emulator. + This file is licensed under the Snes9x License. + For further information, consult the LICENSE file in the root directory. +\*****************************************************************************/ + +/*********************************************************************************** + SNES9X for Mac OS (c) Copyright John Stiles + + Snes9x for Mac OS X + + (c) Copyright 2001 - 2011 zones + (c) Copyright 2002 - 2005 107 + (c) Copyright 2002 PB1400c + (c) Copyright 2004 Alexander and Sander + (c) Copyright 2004 - 2005 Steven Seeger + (c) Copyright 2005 Ryan Vogt + (c) Copyright 2019 - 2021 Michael Donald Buckley + ***********************************************************************************/ + +#import "S9xDisplayPreferencesViewController.h" + +#import "AppDelegate.h" +#import "S9xPreferencesConstants.h" + +@interface S9xDisplayPreferencesViewController () + +@property (nonatomic, weak) IBOutlet NSPopUpButton *videoModePopup; +@property (nonatomic, weak) IBOutlet NSButton *showFPSCheckbox; +@property (nonatomic, weak) IBOutlet NSTextField *macFrameSkipTextField; +@property (nonatomic, weak) IBOutlet NSStepper *macFrameSkipStepper; +@property (nonatomic, weak) IBOutlet NSButton *macFrameSkipAutomaticButton; + +@end + +@implementation S9xDisplayPreferencesViewController + +- (instancetype)init +{ + if (self = [super initWithNibName:@"S9xDisplayPreferencesViewController" bundle:nil]) + { + self.title = NSLocalizedString(@"Display", nil); + self.image = [NSImage imageNamed:@"display"]; + } + + return self; +} + +- (void)refresh +{ + NSUInteger index = MIN([NSUserDefaults.standardUserDefaults integerForKey:kVideoModePref], 1); + [self.videoModePopup selectItemAtIndex:index]; + + NSInteger macFrameSkipDefault = [NSUserDefaults.standardUserDefaults integerForKey:kMacFrameSkipPref]; + // if macFrameSkip is equal to -1, set automatic checkbox + // to be checked, disable the ability to change frame skip values + // from stepper/text field, else leave automatic checkbox + // unchecked and set textfield to value + if (macFrameSkipDefault == -1) { + [self.macFrameSkipTextField setEnabled: false]; + [self.macFrameSkipStepper setEnabled: false]; + [self.macFrameSkipTextField setIntValue: 0]; // show something at least + [self.macFrameSkipAutomaticButton setIntValue: 1]; + } else { + [self.macFrameSkipTextField setIntValue: (int)macFrameSkipDefault]; + [self.macFrameSkipAutomaticButton setIntValue: 0]; + } + + self.showFPSCheckbox.state = [NSUserDefaults.standardUserDefaults boolForKey:kShowFPSPref]; +} + +- (void)setShowFPS:(BOOL)value +{ + AppDelegate *appDelegate = (AppDelegate *)NSApp.delegate; + [appDelegate setShowFPS:value]; +} + +- (void)setVideoMode:(int)value +{ + AppDelegate *appDelegate = (AppDelegate *)NSApp.delegate; + [appDelegate setVideoMode:value]; +} + +- (void)setMacFrameSkip:(int)value +{ + AppDelegate *appDelegate = (AppDelegate *)NSApp.delegate; + [appDelegate setMacFrameSkip:value]; +} + +- (IBAction)onCheckShowFPS:(NSButton *)sender +{ + [self setShowFPS:sender.state == NSOnState]; +} + +- (IBAction)onSelectVideoMode:(NSPopUpButton *)sender +{ + [self setVideoMode:(int)sender.selectedTag]; +} + +- (IBAction)bumpMacFrameSkip:(NSStepper *)sender +{ + int bumpValue = sender.intValue; // 1 or -1 + int nextValue = self.macFrameSkipTextField.intValue + bumpValue; + + // constrain value + if (nextValue < 0) { + nextValue = 0; + } + if (nextValue > 200) { + nextValue = 200; + } + + [self.macFrameSkipTextField setIntValue: nextValue]; + [sender setIntValue:0]; // reset stepper value + [self setMacFrameSkip:self.macFrameSkipTextField.intValue]; // execute setter +} + +- (IBAction)onChangeMacFrameSkipTextField:(NSTextField *)sender +{ + [self setMacFrameSkip:sender.intValue]; +} + +- (IBAction)onCheckMacFrameSkipAutomaticButton:(NSButton *)sender +{ + if (sender.intValue == 1) { + // when automatic is checked, disable macFrameSkipTextField and + // macFrameSkipStepper, then set macFrameSkip to -1 (automatic) + [self.macFrameSkipTextField setEnabled:false]; + [self.macFrameSkipStepper setEnabled:false]; + [self setMacFrameSkip:-1]; + } else { + // when automatic is unchecked, enable macFrameSkipTextField and + // macFrameSkipStepper, then set macFrameSkip to value of text field + [self.macFrameSkipTextField setEnabled:true]; + [self.macFrameSkipStepper setEnabled:true]; + [self setMacFrameSkip:self.macFrameSkipTextField.intValue]; + } +} + +@end diff --git a/macosx/Snes9x/S9xPreferences/S9xDisplayPreferencesViewController.xib b/macosx/Snes9x/S9xPreferences/S9xDisplayPreferencesViewController.xib new file mode 100644 index 00000000..1cf1c054 --- /dev/null +++ b/macosx/Snes9x/S9xPreferences/S9xDisplayPreferencesViewController.xib @@ -0,0 +1,164 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/macosx/Snes9x/S9xPreferences/S9xEmulationPreferencesViewController.h b/macosx/Snes9x/S9xPreferences/S9xEmulationPreferencesViewController.h new file mode 100644 index 00000000..cb1d30bc --- /dev/null +++ b/macosx/Snes9x/S9xPreferences/S9xEmulationPreferencesViewController.h @@ -0,0 +1,29 @@ +/*****************************************************************************\ + Snes9x - Portable Super Nintendo Entertainment System (TM) emulator. + This file is licensed under the Snes9x License. + For further information, consult the LICENSE file in the root directory. +\*****************************************************************************/ + +/*********************************************************************************** + SNES9X for Mac OS (c) Copyright John Stiles + + Snes9x for Mac OS X + + (c) Copyright 2001 - 2011 zones + (c) Copyright 2002 - 2005 107 + (c) Copyright 2002 PB1400c + (c) Copyright 2004 Alexander and Sander + (c) Copyright 2004 - 2005 Steven Seeger + (c) Copyright 2005 Ryan Vogt + (c) Copyright 2019 - 2021 Michael Donald Buckley + ***********************************************************************************/ + +#import "S9xPreferencesViewController.h" + +NS_ASSUME_NONNULL_BEGIN + +@interface S9xEmulationPreferencesViewController : S9xPreferencesViewController + +@end + +NS_ASSUME_NONNULL_END diff --git a/macosx/Snes9x/S9xPreferences/S9xEmulationPreferencesViewController.m b/macosx/Snes9x/S9xPreferences/S9xEmulationPreferencesViewController.m new file mode 100644 index 00000000..c77530f7 --- /dev/null +++ b/macosx/Snes9x/S9xPreferences/S9xEmulationPreferencesViewController.m @@ -0,0 +1,40 @@ +/*****************************************************************************\ + Snes9x - Portable Super Nintendo Entertainment System (TM) emulator. + This file is licensed under the Snes9x License. + For further information, consult the LICENSE file in the root directory. +\*****************************************************************************/ + +/*********************************************************************************** + SNES9X for Mac OS (c) Copyright John Stiles + + Snes9x for Mac OS X + + (c) Copyright 2001 - 2011 zones + (c) Copyright 2002 - 2005 107 + (c) Copyright 2002 PB1400c + (c) Copyright 2004 Alexander and Sander + (c) Copyright 2004 - 2005 Steven Seeger + (c) Copyright 2005 Ryan Vogt + (c) Copyright 2019 - 2021 Michael Donald Buckley + ***********************************************************************************/ + +#import "S9xEmulationPreferencesViewController.h" + +@interface S9xEmulationPreferencesViewController () + +@end + +@implementation S9xEmulationPreferencesViewController + +- (instancetype)init +{ + if (self = [super initWithNibName:@"S9xEmulationPreferencesViewController" bundle:nil]) + { + self.title = NSLocalizedString(@"Emulation", nil); + self.image = [NSImage imageNamed:@"emulation"]; + } + + return self; +} + +@end diff --git a/macosx/Snes9x/S9xPreferences/S9xEmulationPreferencesViewController.xib b/macosx/Snes9x/S9xPreferences/S9xEmulationPreferencesViewController.xib new file mode 100644 index 00000000..46522f9b --- /dev/null +++ b/macosx/Snes9x/S9xPreferences/S9xEmulationPreferencesViewController.xib @@ -0,0 +1,41 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/macosx/Snes9x/S9xPreferences/S9xFilesPreferencesViewController.h b/macosx/Snes9x/S9xPreferences/S9xFilesPreferencesViewController.h new file mode 100644 index 00000000..893163cb --- /dev/null +++ b/macosx/Snes9x/S9xPreferences/S9xFilesPreferencesViewController.h @@ -0,0 +1,29 @@ +/*****************************************************************************\ + Snes9x - Portable Super Nintendo Entertainment System (TM) emulator. + This file is licensed under the Snes9x License. + For further information, consult the LICENSE file in the root directory. +\*****************************************************************************/ + +/*********************************************************************************** + SNES9X for Mac OS (c) Copyright John Stiles + + Snes9x for Mac OS X + + (c) Copyright 2001 - 2011 zones + (c) Copyright 2002 - 2005 107 + (c) Copyright 2002 PB1400c + (c) Copyright 2004 Alexander and Sander + (c) Copyright 2004 - 2005 Steven Seeger + (c) Copyright 2005 Ryan Vogt + (c) Copyright 2019 - 2021 Michael Donald Buckley + ***********************************************************************************/ + +#import "S9xPreferencesViewController.h" + +NS_ASSUME_NONNULL_BEGIN + +@interface S9xFilesPreferencesViewController : S9xPreferencesViewController + +@end + +NS_ASSUME_NONNULL_END diff --git a/macosx/Snes9x/S9xPreferences/S9xFilesPreferencesViewController.m b/macosx/Snes9x/S9xPreferences/S9xFilesPreferencesViewController.m new file mode 100644 index 00000000..674e5677 --- /dev/null +++ b/macosx/Snes9x/S9xPreferences/S9xFilesPreferencesViewController.m @@ -0,0 +1,40 @@ +/*****************************************************************************\ + Snes9x - Portable Super Nintendo Entertainment System (TM) emulator. + This file is licensed under the Snes9x License. + For further information, consult the LICENSE file in the root directory. +\*****************************************************************************/ + +/*********************************************************************************** + SNES9X for Mac OS (c) Copyright John Stiles + + Snes9x for Mac OS X + + (c) Copyright 2001 - 2011 zones + (c) Copyright 2002 - 2005 107 + (c) Copyright 2002 PB1400c + (c) Copyright 2004 Alexander and Sander + (c) Copyright 2004 - 2005 Steven Seeger + (c) Copyright 2005 Ryan Vogt + (c) Copyright 2019 - 2021 Michael Donald Buckley + ***********************************************************************************/ + +#import "S9xFilesPreferencesViewController.h" + +@interface S9xFilesPreferencesViewController () + +@end + +@implementation S9xFilesPreferencesViewController + +- (instancetype)init +{ + if (self = [super initWithNibName:@"S9xFilesPreferencesViewController" bundle:nil]) + { + self.title = NSLocalizedString(@"Files", nil); + self.image = [NSImage imageNamed:@"files"]; + } + + return self; +} + +@end diff --git a/macosx/Snes9x/S9xPreferences/S9xFilesPreferencesViewController.xib b/macosx/Snes9x/S9xPreferences/S9xFilesPreferencesViewController.xib new file mode 100644 index 00000000..c9a8399d --- /dev/null +++ b/macosx/Snes9x/S9xPreferences/S9xFilesPreferencesViewController.xib @@ -0,0 +1,41 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/macosx/Snes9x/S9xPreferences/S9xGamepadPreferencesViewController.m b/macosx/Snes9x/S9xPreferences/S9xGamepadPreferencesViewController.m new file mode 100644 index 00000000..352b10f7 --- /dev/null +++ b/macosx/Snes9x/S9xPreferences/S9xGamepadPreferencesViewController.m @@ -0,0 +1,281 @@ +// +// S9xGamepadPreferencesViewController.m +// Snes9x +// +// Created by Buckley on 4/14/21. +// + +#import + +#import "AppDelegate.h" +#import "S9xButtonConfigTextField.h" +#import "S9xPreferencesConstants.h" +#import "S9xControlsPreferencesViewController.h" + +@interface S9xControlsPreferencesViewController () +@property (nonatomic, weak) IBOutlet NSPopUpButton *devicePopUp; +@property (nonatomic, weak) IBOutlet NSPopUpButton *playerPopUp; +@property (nonatomic, strong) NSArray *configTextFields; +@end + +@implementation S9xControlsPreferencesViewController + +- (instancetype)init +{ + if (self = [super initWithNibName:@"S9xGamepadPreferencesViewController" bundle:nil]) + { + self.title = @"Controls"; + } + + return self; +} + +@dynamic image; +- (NSImage *)image +{ + return [NSImage imageNamed:@"gamepad"]; +} + +- (void)viewDidLoad { + [super viewDidLoad]; + + AppDelegate *appDelegate = (AppDelegate *)NSApp.delegate; + NSUInteger joypadIndex = 0; + for (S9xJoypad *joypad in [appDelegate listJoypads]) + { + NSMenuItem *item = [NSMenuItem new]; + item.title = joypad.name; + item.tag = joypadIndex++; + item.representedObject = joypad; + [self.devicePopUp.menu addItem:item]; + } + + // collect all S9xButtonConfigTextFields within subviews + NSMutableArray *configTextFields = [[NSMutableArray alloc] init]; + + for ( NSView *view in self.view.subviews ) + { + if ([view isKindOfClass:[S9xButtonConfigTextField class]]) + { + [configTextFields addObject:view]; + } + } + + self.configTextFields = configTextFields; + + for (S9xButtonConfigTextField *configTextField in self.configTextFields) + { + [configTextField addObserver:self forKeyPath:@"keyCode" options:NSKeyValueObservingOptionNew context:NULL]; + [configTextField addObserver:self forKeyPath:@"joypadInput" options:NSKeyValueObservingOptionNew context:NULL]; + } + + // select Keyboard as default + [self selectDeviceForPlayer:0]; + +} + +- (void)refresh +{ + if (self.devicePopUp.selectedItem.tag < 0) + { + NSMutableDictionary *controlsDict = [NSMutableDictionary new]; + + NSDictionary *keyboardDict = [NSUserDefaults.standardUserDefaults objectForKey:kKeyboardPrefs]; + NSInteger playerNum = self.playerPopUp.selectedItem.tag; + + for (NSUInteger i = 0; i < kNumButtons; ++i) + { + controlsDict[@(i)] = keyboardDict[@(i + (playerNum * kNumButtons)).stringValue]; + } + + for (S9xButtonConfigTextField *configTextField in self.configTextFields) + { + [configTextField removeObserver:self forKeyPath:@"keyCode"]; + [configTextField removeObserver:self forKeyPath:@"joypadInput"]; + + NSNumber *keyCode = controlsDict[@(configTextField.tag)]; + + configTextField.joypadInput = nil; + + if ( keyCode != nil ) + { + configTextField.keyCode = keyCode.intValue; + } + else + { + configTextField.keyCode = -1; + } + + [configTextField addObserver:self forKeyPath:@"keyCode" options:NSKeyValueObservingOptionNew context:NULL]; + [configTextField addObserver:self forKeyPath:@"joypadInput" options:NSKeyValueObservingOptionNew context:NULL]; + + configTextField.disableKeyboardInput = NO; + } + } + else + { + AppDelegate *appDelegate = (AppDelegate *)NSApp.delegate; + S9xJoypad *joypad = self.devicePopUp.selectedItem.representedObject; + NSString *joypadKey = [appDelegate prefsKeyForVendorID:joypad.vendorID productID:joypad.productID index:joypad.index]; + NSDictionary *joypadDIct = [[NSUserDefaults.standardUserDefaults objectForKey:kJoypadInputPrefs] objectForKey:joypadKey]; + + for (S9xButtonConfigTextField *configTextField in self.configTextFields) + { + [configTextField removeObserver:self forKeyPath:@"keyCode"]; + [configTextField removeObserver:self forKeyPath:@"joypadInput"]; + + uint32 cookie = 0; + int32 value = 0; + S9xButtonCode buttonCode = (S9xButtonCode)configTextField.tag; + NSString *inputString = joypadDIct[@(buttonCode).stringValue]; + + configTextField.keyCode = -1; + + if ([appDelegate getValuesFromString:inputString cookie:&cookie value:&value]) + { + S9xJoypadInput *input = [S9xJoypadInput new]; + input.cookie = cookie; + input.value = value; + input.buttonCode = buttonCode; + configTextField.joypadInput = input; + configTextField.stringValue = [appDelegate labelForVendorID:joypad.vendorID productID:joypad.productID cookie:cookie value:value]; + } + else + { + configTextField.joypadInput = nil; + configTextField.stringValue = @""; + } + + [configTextField addObserver:self forKeyPath:@"keyCode" options:NSKeyValueObservingOptionNew context:NULL]; + [configTextField addObserver:self forKeyPath:@"joypadInput" options:NSKeyValueObservingOptionNew context:NULL]; + + configTextField.disableKeyboardInput = YES; + } + } +} + +- (void)selectDeviceForPlayer:(int8_t)player +{ + AppDelegate *appDelegate = (AppDelegate *)NSApp.delegate; + NSString* joypadKey = [[NSUserDefaults.standardUserDefaults objectForKey:kJoypadPlayerPrefs] objectForKey:@(player).stringValue]; + + [self.devicePopUp selectItemAtIndex:0]; + + if (joypadKey != nil) + { + uint32 vendorID = 0; + uint32 productID = 0; + uint32 index = 0; + + if ( [appDelegate getValuesFromString:joypadKey vendorID:&vendorID productID:&productID index:&index]) + { + S9xJoypad *joypad = [S9xJoypad new]; + joypad.vendorID = vendorID; + joypad.productID = productID; + joypad.index = index; + + for (NSMenuItem *item in self.devicePopUp.menu.itemArray) + { + if ([joypad isEqual:item.representedObject]) + { + [self.devicePopUp selectItem:item]; + break; + } + } + } + } +} + +- (BOOL)handleInput:(S9xJoypadInput *)input fromJoypad:(S9xJoypad *)joypad +{ + id firstResponder = self.view.window.firstResponder; + + if ([firstResponder respondsToSelector:@selector(isFieldEditor)] && [firstResponder isFieldEditor]) + { + firstResponder = [firstResponder delegate]; + } + + if ([firstResponder respondsToSelector:@selector(setJoypadInput:)]) + { + S9xJoypad *currentJoypad = self.devicePopUp.selectedItem.representedObject; + + if ([joypad isEqual:currentJoypad]) + { + [firstResponder setJoypadInput:input]; + return YES; + } + } + + return NO; +} + +- (void)deviceSettingChanged:(S9xDeviceSetting)deviceSetting {} + +- (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context +{ + if ([keyPath isEqualToString:@"keyCode"]) + { + S9xButtonConfigTextField *field = (S9xButtonConfigTextField *)object; + S9xButtonCode buttonCode = (S9xButtonCode)field.tag; + uint16_t keyCode = field.keyCode; + int8_t player = self.playerPopUp.selectedItem.tag; + + if (keyCode != (CGKeyCode)-1) + { + [((AppDelegate *) NSApp.delegate) setButtonCode:buttonCode forKeyCode:keyCode player:player]; + } + else + { + [((AppDelegate *) NSApp.delegate) clearButton:buttonCode forPlayer:player]; + } + + [NSUserDefaults.standardUserDefaults synchronize]; + + [self refresh]; + } + else if ( [keyPath isEqualToString:@"joypadInput"]) + { + S9xButtonConfigTextField *field = (S9xButtonConfigTextField *)object; + S9xButtonCode buttonCode = (S9xButtonCode)field.tag; + S9xJoypad *joypad = self.devicePopUp.selectedItem.representedObject; + + if ([joypad isKindOfClass:[S9xJoypad class]]) + { + S9xJoypadInput *input = field.joypadInput; + + if (input != nil) + { + [((AppDelegate *)NSApp.delegate) setButton:buttonCode forVendorID:joypad.vendorID productID:joypad.productID index:joypad.index cookie:input.cookie value:input.value]; + } + else + { + [((AppDelegate *)NSApp.delegate) clearJoypadForVendorID:joypad.vendorID productID:joypad.productID index:joypad.index buttonCode:buttonCode]; + } + } + + [NSUserDefaults.standardUserDefaults synchronize]; + [self refresh]; + } +} + +- (IBAction)playerDropdownChanged:(NSPopUpButton *)sender +{ + [self selectDeviceForPlayer:sender.selectedTag]; + [self refresh]; +} + +- (IBAction)deviceDropdownChanged:(NSPopUpButton *)sender +{ + if (sender.selectedTag >= 0) + { + AppDelegate *appDelegate = (AppDelegate *)NSApp.delegate; + S9xJoypad *joypad = sender.selectedItem.representedObject; + [appDelegate setPlayer:self.playerPopUp.selectedTag forVendorID:joypad.vendorID productID:joypad.productID index:joypad.index]; + [NSUserDefaults.standardUserDefaults synchronize]; + } + + [self refresh]; +} + + +@end diff --git a/macosx/Snes9x/S9xPreferences/S9xPreferencesConstants.h b/macosx/Snes9x/S9xPreferences/S9xPreferencesConstants.h new file mode 100644 index 00000000..5ff272c5 --- /dev/null +++ b/macosx/Snes9x/S9xPreferences/S9xPreferencesConstants.h @@ -0,0 +1,32 @@ +/*****************************************************************************\ + Snes9x - Portable Super Nintendo Entertainment System (TM) emulator. + This file is licensed under the Snes9x License. + For further information, consult the LICENSE file in the root directory. +\*****************************************************************************/ + +/*********************************************************************************** + SNES9X for Mac OS (c) Copyright John Stiles + + Snes9x for Mac OS X + + (c) Copyright 2001 - 2011 zones + (c) Copyright 2002 - 2005 107 + (c) Copyright 2002 PB1400c + (c) Copyright 2004 Alexander and Sander + (c) Copyright 2004 - 2005 Steven Seeger + (c) Copyright 2005 Ryan Vogt + (c) Copyright 2019 - 2021 Michael Donald Buckley + ***********************************************************************************/ + +#import + +NS_ASSUME_NONNULL_BEGIN + +extern NSString * const kKeyboardPrefs; +extern NSString * const kJoypadInputPrefs; +extern NSString * const kJoypadPlayerPrefs; +extern NSString * const kShowFPSPref; +extern NSString * const kVideoModePref; +extern NSString * const kMacFrameSkipPref; + +NS_ASSUME_NONNULL_END diff --git a/macosx/Snes9x/S9xPreferences/S9xPreferencesConstants.m b/macosx/Snes9x/S9xPreferences/S9xPreferencesConstants.m new file mode 100644 index 00000000..6f304e41 --- /dev/null +++ b/macosx/Snes9x/S9xPreferences/S9xPreferencesConstants.m @@ -0,0 +1,28 @@ +/*****************************************************************************\ + Snes9x - Portable Super Nintendo Entertainment System (TM) emulator. + This file is licensed under the Snes9x License. + For further information, consult the LICENSE file in the root directory. +\*****************************************************************************/ + +/*********************************************************************************** + SNES9X for Mac OS (c) Copyright John Stiles + + Snes9x for Mac OS X + + (c) Copyright 2001 - 2011 zones + (c) Copyright 2002 - 2005 107 + (c) Copyright 2002 PB1400c + (c) Copyright 2004 Alexander and Sander + (c) Copyright 2004 - 2005 Steven Seeger + (c) Copyright 2005 Ryan Vogt + (c) Copyright 2019 - 2021 Michael Donald Buckley + ***********************************************************************************/ + +#import "S9xPreferencesConstants.h" + +NSString * const kKeyboardPrefs = @"KeyboardConfig"; +NSString * const kJoypadInputPrefs = @"JoypadInputs"; +NSString * const kJoypadPlayerPrefs = @"JoypadPlayers"; +NSString * const kShowFPSPref = @"ShowFPS"; +NSString * const kVideoModePref = @"VideoMode"; +NSString * const kMacFrameSkipPref = @"FrameSkip"; diff --git a/macosx/Snes9x/S9xPreferences/S9xPreferencesTabViewController.h b/macosx/Snes9x/S9xPreferences/S9xPreferencesTabViewController.h new file mode 100644 index 00000000..4ddd3c14 --- /dev/null +++ b/macosx/Snes9x/S9xPreferences/S9xPreferencesTabViewController.h @@ -0,0 +1,29 @@ +/*****************************************************************************\ + Snes9x - Portable Super Nintendo Entertainment System (TM) emulator. + This file is licensed under the Snes9x License. + For further information, consult the LICENSE file in the root directory. +\*****************************************************************************/ + +/*********************************************************************************** + SNES9X for Mac OS (c) Copyright John Stiles + + Snes9x for Mac OS X + + (c) Copyright 2001 - 2011 zones + (c) Copyright 2002 - 2005 107 + (c) Copyright 2002 PB1400c + (c) Copyright 2004 Alexander and Sander + (c) Copyright 2004 - 2005 Steven Seeger + (c) Copyright 2005 Ryan Vogt + (c) Copyright 2019 - 2021 Michael Donald Buckley + ***********************************************************************************/ + +#import + +NS_ASSUME_NONNULL_BEGIN + +@interface S9xPreferencesTabViewController : NSTabViewController + +@end + +NS_ASSUME_NONNULL_END diff --git a/macosx/Snes9x/S9xPreferences/S9xPreferencesTabViewController.m b/macosx/Snes9x/S9xPreferences/S9xPreferencesTabViewController.m new file mode 100644 index 00000000..9298b499 --- /dev/null +++ b/macosx/Snes9x/S9xPreferences/S9xPreferencesTabViewController.m @@ -0,0 +1,79 @@ +/*****************************************************************************\ + Snes9x - Portable Super Nintendo Entertainment System (TM) emulator. + This file is licensed under the Snes9x License. + For further information, consult the LICENSE file in the root directory. +\*****************************************************************************/ + +/*********************************************************************************** + SNES9X for Mac OS (c) Copyright John Stiles + + Snes9x for Mac OS X + + (c) Copyright 2001 - 2011 zones + (c) Copyright 2002 - 2005 107 + (c) Copyright 2002 PB1400c + (c) Copyright 2004 Alexander and Sander + (c) Copyright 2004 - 2005 Steven Seeger + (c) Copyright 2005 Ryan Vogt + (c) Copyright 2019 - 2021 Michael Donald Buckley + ***********************************************************************************/ + +#import "S9xPreferencesTabViewController.h" + +@interface S9xPreferencesTabViewController () + +@end + +@implementation S9xPreferencesTabViewController +{ + BOOL _didHide; +} + +- (void)tabView:(NSTabView *)tabView willSelectTabViewItem:(NSTabViewItem *)tabViewItem +{ + [super tabView:tabView willSelectTabViewItem:tabViewItem]; + + NSTabViewItem *currentTabViewItem = tabView.selectedTabViewItem; + + if ( currentTabViewItem == nil || currentTabViewItem == tabViewItem ) + { + return; + } + + currentTabViewItem.view.hidden = YES; + tabViewItem.view.hidden = YES; + _didHide = YES; + + NSWindow *window = self.view.window; + NSSize tabViewSize = tabViewItem.view.fittingSize; + NSSize newWindowSize = [window frameRectForContentRect:(CGRect){CGPointZero, tabViewSize}].size; + + NSRect windowFrame = window.frame; + windowFrame.origin.y += windowFrame.size.height; + windowFrame.origin.y -= newWindowSize.height; + windowFrame.size = newWindowSize; + + if ( self.isViewLoaded ) + { + [NSAnimationContext runAnimationGroup:^(NSAnimationContext *context) + { + [self.view.window.animator setFrame:windowFrame display:YES]; + } completionHandler:^ + { + tabViewItem.view.hidden = NO; + }]; + } +} + +- (void)tabView:(NSTabView *)tabView didSelectTabViewItem:(NSTabViewItem *)tabViewItem +{ + [super tabView:tabView didSelectTabViewItem:tabViewItem]; + + if ( _didHide ) + { + tabViewItem.view.hidden = YES; + _didHide = NO; + } +} + +@end diff --git a/macosx/Snes9x/S9xPreferences/S9xPreferencesViewController.h b/macosx/Snes9x/S9xPreferences/S9xPreferencesViewController.h new file mode 100644 index 00000000..292fa2e9 --- /dev/null +++ b/macosx/Snes9x/S9xPreferences/S9xPreferencesViewController.h @@ -0,0 +1,33 @@ +/*****************************************************************************\ + Snes9x - Portable Super Nintendo Entertainment System (TM) emulator. + This file is licensed under the Snes9x License. + For further information, consult the LICENSE file in the root directory. +\*****************************************************************************/ + +/*********************************************************************************** + SNES9X for Mac OS (c) Copyright John Stiles + + Snes9x for Mac OS X + + (c) Copyright 2001 - 2011 zones + (c) Copyright 2002 - 2005 107 + (c) Copyright 2002 PB1400c + (c) Copyright 2004 Alexander and Sander + (c) Copyright 2004 - 2005 Steven Seeger + (c) Copyright 2005 Ryan Vogt + (c) Copyright 2019 - 2021 Michael Donald Buckley + ***********************************************************************************/ + +#import + +NS_ASSUME_NONNULL_BEGIN + +@interface S9xPreferencesViewController : NSViewController + +- (void)refresh; + +@property (nonatomic, strong) NSImage *image; + +@end + +NS_ASSUME_NONNULL_END diff --git a/macosx/Snes9x/S9xPreferences/S9xPreferencesViewController.m b/macosx/Snes9x/S9xPreferences/S9xPreferencesViewController.m new file mode 100644 index 00000000..0b70f47e --- /dev/null +++ b/macosx/Snes9x/S9xPreferences/S9xPreferencesViewController.m @@ -0,0 +1,40 @@ +/*****************************************************************************\ + Snes9x - Portable Super Nintendo Entertainment System (TM) emulator. + This file is licensed under the Snes9x License. + For further information, consult the LICENSE file in the root directory. +\*****************************************************************************/ + +/*********************************************************************************** + SNES9X for Mac OS (c) Copyright John Stiles + + Snes9x for Mac OS X + + (c) Copyright 2001 - 2011 zones + (c) Copyright 2002 - 2005 107 + (c) Copyright 2002 PB1400c + (c) Copyright 2004 Alexander and Sander + (c) Copyright 2004 - 2005 Steven Seeger + (c) Copyright 2005 Ryan Vogt + (c) Copyright 2019 - 2021 Michael Donald Buckley + ***********************************************************************************/ + +#import "S9xPreferencesViewController.h" + +@interface S9xPreferencesViewController () + +@end + +@implementation S9xPreferencesViewController + +- (void)viewWillAppear +{ + [super viewWillAppear]; + [self refresh]; +} + +- (void)refresh +{ + // Implemented by subclasses. +} + +@end diff --git a/macosx/Snes9x/S9xPreferences/S9xPreferencesWindowController.h b/macosx/Snes9x/S9xPreferences/S9xPreferencesWindowController.h index feb31366..fb40908f 100644 --- a/macosx/Snes9x/S9xPreferences/S9xPreferencesWindowController.h +++ b/macosx/Snes9x/S9xPreferences/S9xPreferencesWindowController.h @@ -1,6 +1,6 @@ /*****************************************************************************\ - Snes9x - Portable Super Nintendo Entertainment System (TM) emulator. - This file is licensed under the Snes9x License. + Snes9x - Portable Super Nintendo Entertainment System (TM) emulator. + This file is licensed under the Snes9x License. For further information, consult the LICENSE file in the root directory. \*****************************************************************************/ @@ -15,30 +15,16 @@ (c) Copyright 2004 Alexander and Sander (c) Copyright 2004 - 2005 Steven Seeger (c) Copyright 2005 Ryan Vogt - (c) Copyright 2019 Michael Donald Buckley + (c) Copyright 2019 - 2021 Michael Donald Buckley ***********************************************************************************/ + #import #import "S9xButtonConfigTextField.h" NS_ASSUME_NONNULL_BEGIN -extern NSString * const kKeyboardPrefs; -extern NSString * const kJoypadInputPrefs; -extern NSString * const kJoypadPlayerPrefs; -extern NSString * const kShowFPSPref; -extern NSString * const kVideoModePref; -extern NSString * const kMacFrameSkipPref; - -@interface S9xPreferencesWindowController : NSWindowController -@property (nonatomic, weak) IBOutlet NSTabView *tabView; -@property (nonatomic, weak) IBOutlet NSPopUpButton *videoModePopup; -@property (nonatomic, weak) IBOutlet NSButton *showFPSCheckbox; -@property (nonatomic, weak) IBOutlet NSPopUpButton *devicePopUp; -@property (nonatomic, weak) IBOutlet NSPopUpButton *playerPopUp; -@property (nonatomic, weak) IBOutlet NSTextField *macFrameSkipTextField; -@property (nonatomic, weak) IBOutlet NSStepper *macFrameSkipStepper; -@property (nonatomic, weak) IBOutlet NSButton *macFrameSkipAutomaticButton; -@property (nonatomic, strong) NSArray *configTextFields; +@interface S9xPreferencesWindowController : NSWindowController +- (BOOL)handleInput:(S9xJoypadInput *)input fromJoypad:(S9xJoypad *)joypad; @end NS_ASSUME_NONNULL_END diff --git a/macosx/Snes9x/S9xPreferences/S9xPreferencesWindowController.m b/macosx/Snes9x/S9xPreferences/S9xPreferencesWindowController.m index cc4724af..41ac005b 100644 --- a/macosx/Snes9x/S9xPreferences/S9xPreferencesWindowController.m +++ b/macosx/Snes9x/S9xPreferences/S9xPreferencesWindowController.m @@ -1,6 +1,6 @@ /*****************************************************************************\ - Snes9x - Portable Super Nintendo Entertainment System (TM) emulator. - This file is licensed under the Snes9x License. + Snes9x - Portable Super Nintendo Entertainment System (TM) emulator. + This file is licensed under the Snes9x License. For further information, consult the LICENSE file in the root directory. \*****************************************************************************/ @@ -15,23 +15,39 @@ (c) Copyright 2004 Alexander and Sander (c) Copyright 2004 - 2005 Steven Seeger (c) Copyright 2005 Ryan Vogt - (c) Copyright 2019 Michael Donald Buckley + (c) Copyright 2019 - 2021 Michael Donald Buckley ***********************************************************************************/ #import #import "AppDelegate.h" -#import "S9xPreferencesWindowController.h" #import "S9xButtonConfigTextField.h" +#import "S9xPreferencesConstants.h" +#import "S9xPreferencesWindowController.h" -NSString * const kKeyboardPrefs = @"KeyboardConfig"; -NSString * const kJoypadInputPrefs = @"JoypadInputs"; -NSString * const kJoypadPlayerPrefs = @"JoypadPlayers"; -NSString * const kShowFPSPref = @"ShowFPS"; -NSString * const kVideoModePref = @"VideoMode"; -NSString * const kMacFrameSkipPref = @"FrameSkip"; +#import "S9xPreferencesTabViewController.h" +#import "S9xControlsPreferencesViewController.h" +#import "S9xDisplayPreferencesViewController.h" +#import "S9xSoundPreferencesViewController.h" +#import "S9xEmulationPreferencesViewController.h" +#import "S9xFilesPreferencesViewController.h" + +@interface S9xPreferencesWindowController () +@property (nonatomic, readonly, strong) NSArray *tabs; +@property (nonatomic, readonly, strong) NSTabViewController *tabViewController; +@end @implementation S9xPreferencesWindowController -@synthesize tabView, videoModePopup, showFPSCheckbox, devicePopUp, playerPopUp, macFrameSkipTextField, macFrameSkipStepper, macFrameSkipAutomaticButton, configTextFields; + +- (NSArray *)tabs +{ + return self.contentViewController.childViewControllers; +} + +@dynamic tabViewController; +- (S9xPreferencesTabViewController *)tabViewController +{ + return (S9xPreferencesTabViewController *)self.contentViewController; +} - (void)windowDidLoad { @@ -40,340 +56,45 @@ NSString * const kMacFrameSkipPref = @"FrameSkip"; - (void)awakeFromNib { - AppDelegate *appDelegate = (AppDelegate *)NSApp.delegate; - NSUInteger joypadIndex = 0; - for (S9xJoypad *joypad in [appDelegate listJoypads]) - { - NSMenuItem *item = [NSMenuItem new]; - item.title = joypad.name; - item.tag = joypadIndex++; - item.representedObject = joypad; - [self.devicePopUp.menu addItem:item]; - } + S9xPreferencesTabViewController *tabViewController = [S9xPreferencesTabViewController new]; + tabViewController.tabStyle = NSTabViewControllerTabStyleToolbar; + self.contentViewController = tabViewController; - // collect all S9xButtonConfigTextFields within subviews - NSMutableArray *configTextFields = [[NSMutableArray alloc] init]; - for (NSTabViewItem *tabViewItem in self.tabView.tabViewItems) { - [configTextFields addObjectsFromArray:[self getS9xButtonConfigTextFields:tabViewItem.view]]; - } - self.configTextFields = configTextFields; + [self addPane:[S9xControlsPreferencesViewController new] to:tabViewController]; + [self addPane:[S9xDisplayPreferencesViewController new] to:tabViewController]; + [self addPane:[S9xSoundPreferencesViewController new] to:tabViewController]; + [self addPane:[S9xEmulationPreferencesViewController new] to:tabViewController]; + [self addPane:[S9xFilesPreferencesViewController new] to:tabViewController]; +} - for (S9xButtonConfigTextField *configTextField in self.configTextFields) - { - [configTextField addObserver:self forKeyPath:@"keyCode" options:NSKeyValueObservingOptionNew context:NULL]; - [configTextField addObserver:self forKeyPath:@"joypadInput" options:NSKeyValueObservingOptionNew context:NULL]; - } - - // select Keyboard as default - [self selectDeviceForPlayer:0]; +- (void)addPane:(S9xPreferencesViewController *)pane to:(NSTabViewController *)tabController +{ + [tabController addChildViewController:pane]; + tabController.tabView.tabViewItems.lastObject.image = pane.image; } - (void)refresh { - NSUInteger index = MIN([NSUserDefaults.standardUserDefaults integerForKey:kVideoModePref], 1); - [self.videoModePopup selectItemAtIndex:index]; - - NSInteger macFrameSkipDefault = [NSUserDefaults.standardUserDefaults integerForKey:kMacFrameSkipPref]; - // if macFrameSkip is equal to -1, set automatic checkbox - // to be checked, disable the ability to change frame skip values - // from stepper/text field, else leave automatic checkbox - // unchecked and set textfield to value - if (macFrameSkipDefault == -1) { - [self.macFrameSkipTextField setEnabled: false]; - [self.macFrameSkipStepper setEnabled: false]; - [self.macFrameSkipTextField setIntValue: 0]; // show something at least - [self.macFrameSkipAutomaticButton setIntValue: 1]; - } else { - [self.macFrameSkipTextField setIntValue: (int)macFrameSkipDefault]; - [self.macFrameSkipAutomaticButton setIntValue: 0]; + for ( S9xPreferencesViewController *tab in self.tabs ) + { + [tab refresh]; } - - self.showFPSCheckbox.state = [NSUserDefaults.standardUserDefaults boolForKey:kShowFPSPref]; - - if (self.devicePopUp.selectedItem.tag < 0) - { - NSMutableDictionary *controlsDict = [NSMutableDictionary new]; - - NSDictionary *keyboardDict = [NSUserDefaults.standardUserDefaults objectForKey:kKeyboardPrefs]; - NSInteger playerNum = self.playerPopUp.selectedItem.tag; - - for (NSUInteger i = 0; i < kNumButtons; ++i) - { - controlsDict[@(i)] = keyboardDict[@(i + (playerNum * kNumButtons)).stringValue]; - } - - for (S9xButtonConfigTextField *configTextField in self.configTextFields) - { - [configTextField removeObserver:self forKeyPath:@"keyCode"]; - [configTextField removeObserver:self forKeyPath:@"joypadInput"]; - - NSNumber *keyCode = controlsDict[@(configTextField.tag)]; - - configTextField.joypadInput = nil; - - if ( keyCode != nil ) - { - configTextField.keyCode = keyCode.intValue; - } - else - { - configTextField.keyCode = -1; - } - - [configTextField addObserver:self forKeyPath:@"keyCode" options:NSKeyValueObservingOptionNew context:NULL]; - [configTextField addObserver:self forKeyPath:@"joypadInput" options:NSKeyValueObservingOptionNew context:NULL]; - - configTextField.disableKeyboardInput = NO; - } - } - else - { - AppDelegate *appDelegate = (AppDelegate *)NSApp.delegate; - S9xJoypad *joypad = self.devicePopUp.selectedItem.representedObject; - NSString *joypadKey = [appDelegate prefsKeyForVendorID:joypad.vendorID productID:joypad.productID index:joypad.index]; - NSDictionary *joypadDIct = [[NSUserDefaults.standardUserDefaults objectForKey:kJoypadInputPrefs] objectForKey:joypadKey]; - - for (S9xButtonConfigTextField *configTextField in self.configTextFields) - { - [configTextField removeObserver:self forKeyPath:@"keyCode"]; - [configTextField removeObserver:self forKeyPath:@"joypadInput"]; - - uint32 cookie = 0; - int32 value = 0; - S9xButtonCode buttonCode = (S9xButtonCode)configTextField.tag; - NSString *inputString = joypadDIct[@(buttonCode).stringValue]; - - configTextField.keyCode = -1; - - if ([appDelegate getValuesFromString:inputString cookie:&cookie value:&value]) - { - S9xJoypadInput *input = [S9xJoypadInput new]; - input.cookie = cookie; - input.value = value; - input.buttonCode = buttonCode; - configTextField.joypadInput = input; - configTextField.stringValue = [appDelegate labelForVendorID:joypad.vendorID productID:joypad.productID cookie:cookie value:value]; - } - else - { - configTextField.joypadInput = nil; - configTextField.stringValue = @""; - } - - [configTextField addObserver:self forKeyPath:@"keyCode" options:NSKeyValueObservingOptionNew context:NULL]; - [configTextField addObserver:self forKeyPath:@"joypadInput" options:NSKeyValueObservingOptionNew context:NULL]; - - configTextField.disableKeyboardInput = YES; - } - } -} - -- (NSArray *)getS9xButtonConfigTextFields:(NSView*)view { - NSMutableArray *S9xButtonConfigTextFields = [[NSMutableArray alloc] init]; - - if ([view isKindOfClass:[S9xButtonConfigTextField class]]) { - [S9xButtonConfigTextFields addObject:view]; - } else if (view.subviews) { - for (NSView *subview in view.subviews) { - [S9xButtonConfigTextFields addObjectsFromArray:[self getS9xButtonConfigTextFields:subview]]; - } - } - return [NSArray arrayWithArray:S9xButtonConfigTextFields]; -} - -- (void)selectDeviceForPlayer:(int8_t)player -{ - AppDelegate *appDelegate = (AppDelegate *)NSApp.delegate; - NSString* joypadKey = [[NSUserDefaults.standardUserDefaults objectForKey:kJoypadPlayerPrefs] objectForKey:@(player).stringValue]; - - [self.devicePopUp selectItemAtIndex:0]; - - if (joypadKey != nil) - { - uint32 vendorID = 0; - uint32 productID = 0; - uint32 index = 0; - - if ( [appDelegate getValuesFromString:joypadKey vendorID:&vendorID productID:&productID index:&index]) - { - S9xJoypad *joypad = [S9xJoypad new]; - joypad.vendorID = vendorID; - joypad.productID = productID; - joypad.index = index; - - for (NSMenuItem *item in self.devicePopUp.menu.itemArray) - { - if ([joypad isEqual:item.representedObject]) - { - [self.devicePopUp selectItem:item]; - break; - } - } - } - } } - (BOOL)handleInput:(S9xJoypadInput *)input fromJoypad:(S9xJoypad *)joypad { - id firstResponder = self.window.firstResponder; - - if ([firstResponder respondsToSelector:@selector(isFieldEditor)] && [firstResponder isFieldEditor]) - { - firstResponder = [firstResponder delegate]; - } - - if ([firstResponder respondsToSelector:@selector(setJoypadInput:)]) - { - S9xJoypad *currentJoypad = self.devicePopUp.selectedItem.representedObject; - - if ([joypad isEqual:currentJoypad]) - { - [firstResponder setJoypadInput:input]; - return YES; - } - } - - return NO; -} - -- (void)deviceSettingChanged:(S9xDeviceSetting)deviceSetting {} - -- (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context -{ - if ([keyPath isEqualToString:@"keyCode"]) + NSTabViewController *tabViewController = self.tabViewController; + NSUInteger index = self.tabViewController.selectedTabViewItemIndex; + if ( index >= 0 && index < tabViewController.childViewControllers.count ) { - S9xButtonConfigTextField *field = (S9xButtonConfigTextField *)object; - S9xButtonCode buttonCode = (S9xButtonCode)field.tag; - uint16_t keyCode = field.keyCode; - int8_t player = self.playerPopUp.selectedItem.tag; - - if (keyCode != (CGKeyCode)-1) + S9xPreferencesViewController *viewController = tabViewController.childViewControllers[index]; + if ( [viewController isKindOfClass:[S9xControlsPreferencesViewController class]] ) { - [((AppDelegate *) NSApp.delegate) setButtonCode:buttonCode forKeyCode:keyCode player:player]; + return [((S9xControlsPreferencesViewController *)viewController) handleInput:input fromJoypad:joypad]; } - else - { - [((AppDelegate *) NSApp.delegate) clearButton:buttonCode forPlayer:player]; - } - - [NSUserDefaults.standardUserDefaults synchronize]; - - [self refresh]; - } - else if ( [keyPath isEqualToString:@"joypadInput"]) - { - S9xButtonConfigTextField *field = (S9xButtonConfigTextField *)object; - S9xButtonCode buttonCode = (S9xButtonCode)field.tag; - S9xJoypad *joypad = self.devicePopUp.selectedItem.representedObject; - - if ([joypad isKindOfClass:[S9xJoypad class]]) - { - S9xJoypadInput *input = field.joypadInput; - - if (input != nil) - { - [((AppDelegate *)NSApp.delegate) setButton:buttonCode forVendorID:joypad.vendorID productID:joypad.productID index:joypad.index cookie:input.cookie value:input.value]; - } - else - { - [((AppDelegate *)NSApp.delegate) clearJoypadForVendorID:joypad.vendorID productID:joypad.productID index:joypad.index buttonCode:buttonCode]; - } - } - - [NSUserDefaults.standardUserDefaults synchronize]; - [self refresh]; - } -} - -- (void)setShowFPS:(BOOL)value -{ - AppDelegate *appDelegate = (AppDelegate *)NSApp.delegate; - [appDelegate setShowFPS:value]; -} - -- (void)setVideoMode:(int)value -{ - AppDelegate *appDelegate = (AppDelegate *)NSApp.delegate; - [appDelegate setVideoMode:value]; -} - -- (void)setMacFrameSkip:(int)value -{ - AppDelegate *appDelegate = (AppDelegate *)NSApp.delegate; - [appDelegate setMacFrameSkip:value]; -} - -- (IBAction)onToolbarItemPress:(NSToolbarItem *)sender -{ - [self.tabView selectTabViewItemAtIndex:sender.tag]; -} - -- (IBAction)onCheckShowFPS:(NSButton *)sender -{ - [self setShowFPS:sender.state == NSOnState]; -} - -- (IBAction)onSelectVideoMode:(NSPopUpButton *)sender -{ - [self setVideoMode:(int)sender.selectedTag]; -} - -- (IBAction)bumpMacFrameSkip:(NSStepper *)sender -{ - int bumpValue = sender.intValue; // 1 or -1 - int nextValue = self.macFrameSkipTextField.intValue + bumpValue; - - // constrain value - if (nextValue < 0) { - nextValue = 0; - } - if (nextValue > 200) { - nextValue = 200; } - [self.macFrameSkipTextField setIntValue: nextValue]; - [sender setIntValue:0]; // reset stepper value - [self setMacFrameSkip:self.macFrameSkipTextField.intValue]; // execute setter -} - -- (IBAction)onChangeMacFrameSkipTextField:(NSTextField *)sender -{ - [self setMacFrameSkip:sender.intValue]; -} - -- (IBAction)onCheckMacFrameSkipAutomaticButton:(NSButton *)sender -{ - if (sender.intValue == 1) { - // when automatic is checked, disable macFrameSkipTextField and - // macFrameSkipStepper, then set macFrameSkip to -1 (automatic) - [self.macFrameSkipTextField setEnabled:false]; - [self.macFrameSkipStepper setEnabled:false]; - [self setMacFrameSkip:-1]; - } else { - // when automatic is unchecked, enable macFrameSkipTextField and - // macFrameSkipStepper, then set macFrameSkip to value of text field - [self.macFrameSkipTextField setEnabled:true]; - [self.macFrameSkipStepper setEnabled:true]; - [self setMacFrameSkip:self.macFrameSkipTextField.intValue]; - } -} - -- (IBAction)onChangePlayerDropdown:(NSPopUpButton *)sender -{ - [self selectDeviceForPlayer:sender.selectedTag]; - [self refresh]; -} - -- (IBAction)onChangeDeviceDropdown:(NSPopUpButton *)sender -{ - if (sender.selectedTag >= 0) - { - AppDelegate *appDelegate = (AppDelegate *)NSApp.delegate; - S9xJoypad *joypad = sender.selectedItem.representedObject; - [appDelegate setPlayer:self.playerPopUp.selectedTag forVendorID:joypad.vendorID productID:joypad.productID index:joypad.index]; - [NSUserDefaults.standardUserDefaults synchronize]; - } - [self refresh]; + return NO; } @end diff --git a/macosx/Snes9x/S9xPreferences/S9xPreferencesWindowController.xib b/macosx/Snes9x/S9xPreferences/S9xPreferencesWindowController.xib index eef93933..3055fee1 100644 --- a/macosx/Snes9x/S9xPreferences/S9xPreferencesWindowController.xib +++ b/macosx/Snes9x/S9xPreferences/S9xPreferencesWindowController.xib @@ -1,22 +1,13 @@ - + - + - - - - - - - - - @@ -25,1569 +16,15 @@ - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/macosx/Snes9x/S9xPreferences/S9xSoundPreferencesViewController.h b/macosx/Snes9x/S9xPreferences/S9xSoundPreferencesViewController.h new file mode 100644 index 00000000..8e265273 --- /dev/null +++ b/macosx/Snes9x/S9xPreferences/S9xSoundPreferencesViewController.h @@ -0,0 +1,29 @@ +/*****************************************************************************\ + Snes9x - Portable Super Nintendo Entertainment System (TM) emulator. + This file is licensed under the Snes9x License. + For further information, consult the LICENSE file in the root directory. +\*****************************************************************************/ + +/*********************************************************************************** + SNES9X for Mac OS (c) Copyright John Stiles + + Snes9x for Mac OS X + + (c) Copyright 2001 - 2011 zones + (c) Copyright 2002 - 2005 107 + (c) Copyright 2002 PB1400c + (c) Copyright 2004 Alexander and Sander + (c) Copyright 2004 - 2005 Steven Seeger + (c) Copyright 2005 Ryan Vogt + (c) Copyright 2019 - 2021 Michael Donald Buckley + ***********************************************************************************/ + +#import "S9xPreferencesViewController.h" + +NS_ASSUME_NONNULL_BEGIN + +@interface S9xSoundPreferencesViewController : S9xPreferencesViewController + +@end + +NS_ASSUME_NONNULL_END diff --git a/macosx/Snes9x/S9xPreferences/S9xSoundPreferencesViewController.m b/macosx/Snes9x/S9xPreferences/S9xSoundPreferencesViewController.m new file mode 100644 index 00000000..bc6a88a2 --- /dev/null +++ b/macosx/Snes9x/S9xPreferences/S9xSoundPreferencesViewController.m @@ -0,0 +1,40 @@ +/*****************************************************************************\ + Snes9x - Portable Super Nintendo Entertainment System (TM) emulator. + This file is licensed under the Snes9x License. + For further information, consult the LICENSE file in the root directory. +\*****************************************************************************/ + +/*********************************************************************************** + SNES9X for Mac OS (c) Copyright John Stiles + + Snes9x for Mac OS X + + (c) Copyright 2001 - 2011 zones + (c) Copyright 2002 - 2005 107 + (c) Copyright 2002 PB1400c + (c) Copyright 2004 Alexander and Sander + (c) Copyright 2004 - 2005 Steven Seeger + (c) Copyright 2005 Ryan Vogt + (c) Copyright 2019 - 2021 Michael Donald Buckley + ***********************************************************************************/ + +#import "S9xSoundPreferencesViewController.h" + +@interface S9xSoundPreferencesViewController () + +@end + +@implementation S9xSoundPreferencesViewController + +- (instancetype)init +{ + if (self = [super initWithNibName:@"S9xSoundPreferencesViewController" bundle:nil]) + { + self.title = NSLocalizedString(@"Sound", nil); + self.image = [NSImage imageNamed:@"sound"]; + } + + return self; +} + +@end diff --git a/macosx/Snes9x/S9xPreferences/S9xSoundPreferencesViewController.xib b/macosx/Snes9x/S9xPreferences/S9xSoundPreferencesViewController.xib new file mode 100644 index 00000000..e90a1efd --- /dev/null +++ b/macosx/Snes9x/S9xPreferences/S9xSoundPreferencesViewController.xib @@ -0,0 +1,41 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/macosx/snes9x.xcodeproj/project.pbxproj b/macosx/snes9x.xcodeproj/project.pbxproj index f2127ce9..63077a6d 100755 --- a/macosx/snes9x.xcodeproj/project.pbxproj +++ b/macosx/snes9x.xcodeproj/project.pbxproj @@ -17,8 +17,20 @@ 302EECA522DAD1B9006D1502 /* CoreAudio.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 302EECA422DAD1B9006D1502 /* CoreAudio.framework */; }; 3042F7E3232E9BDD00C03F5E /* Carbon.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 3042F7E2232E9BDD00C03F5E /* Carbon.framework */; }; 3045A1EF22D03C4B0092B97D /* Cocoa.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 3045A1EE22D03C4B0092B97D /* Cocoa.framework */; }; + 304B364A262E328400F8DC8E /* S9xControlsPreferencesViewController.xib in Resources */ = {isa = PBXBuildFile; fileRef = 304B3649262E328400F8DC8E /* S9xControlsPreferencesViewController.xib */; }; + 304B366C262E82B800F8DC8E /* S9xPreferencesConstants.m in Sources */ = {isa = PBXBuildFile; fileRef = 304B366B262E82B800F8DC8E /* S9xPreferencesConstants.m */; }; 3059DA94250690DB003EF183 /* compat.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 3059DA93250690DB003EF183 /* compat.cpp */; }; 30656200236A8BA700A1B3B2 /* gamecontrollerdb.txt in Resources */ = {isa = PBXBuildFile; fileRef = 306561FF236A8BA700A1B3B2 /* gamecontrollerdb.txt */; }; + 306937CA2635EE5800007ABB /* S9xDisplayPreferencesViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 306937C82635EE5800007ABB /* S9xDisplayPreferencesViewController.m */; }; + 306937CB2635EE5800007ABB /* S9xDisplayPreferencesViewController.xib in Resources */ = {isa = PBXBuildFile; fileRef = 306937C92635EE5800007ABB /* S9xDisplayPreferencesViewController.xib */; }; + 306937D02636253900007ABB /* S9xPreferencesTabViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 306937CF2636253900007ABB /* S9xPreferencesTabViewController.m */; }; + 306937D526362A1100007ABB /* S9xPreferencesViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 306937D426362A1100007ABB /* S9xPreferencesViewController.m */; }; + 306937DC26362B2400007ABB /* S9xSoundPreferencesViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 306937DA26362B2400007ABB /* S9xSoundPreferencesViewController.m */; }; + 306937DD26362B2400007ABB /* S9xSoundPreferencesViewController.xib in Resources */ = {isa = PBXBuildFile; fileRef = 306937DB26362B2400007ABB /* S9xSoundPreferencesViewController.xib */; }; + 306937E22636352100007ABB /* S9xEmulationPreferencesViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 306937E02636352100007ABB /* S9xEmulationPreferencesViewController.m */; }; + 306937E32636352100007ABB /* S9xEmulationPreferencesViewController.xib in Resources */ = {isa = PBXBuildFile; fileRef = 306937E12636352100007ABB /* S9xEmulationPreferencesViewController.xib */; }; + 306937E82636365100007ABB /* S9xFilesPreferencesViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 306937E62636365100007ABB /* S9xFilesPreferencesViewController.m */; }; + 306937E92636365100007ABB /* S9xFilesPreferencesViewController.xib in Resources */ = {isa = PBXBuildFile; fileRef = 306937E72636365100007ABB /* S9xFilesPreferencesViewController.xib */; }; 30714719230E379500917F82 /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 30714718230E379500917F82 /* AppDelegate.m */; }; 3071471B230E379600917F82 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 3071471A230E379600917F82 /* Assets.xcassets */; }; 3071471E230E379600917F82 /* MainMenu.xib in Resources */ = {isa = PBXBuildFile; fileRef = 3071471C230E379600917F82 /* MainMenu.xib */; }; @@ -58,6 +70,7 @@ 3082C4262378BCE80081CA7C /* FakeResources.c in Sources */ = {isa = PBXBuildFile; fileRef = 3082C4212378BCE80081CA7C /* FakeResources.c */; }; 3082C4272378BCE80081CA7C /* FakeResources.h in Headers */ = {isa = PBXBuildFile; fileRef = 3082C4222378BCE80081CA7C /* FakeResources.h */; }; 3082C42A2379199F0081CA7C /* S9xApplication.m in Sources */ = {isa = PBXBuildFile; fileRef = 3082C4292379199F0081CA7C /* S9xApplication.m */; }; + 309C54802627F3060055DD95 /* S9xControlsPreferencesViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 309C547F2627F3060055DD95 /* S9xControlsPreferencesViewController.m */; }; 30A6F62423B2771A00630584 /* MetalKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 30A6F62323B2771A00630584 /* MetalKit.framework */; }; 30A6F62623B29EF500630584 /* shaders.metal in Sources */ = {isa = PBXBuildFile; fileRef = 30A6F62523B29EF500630584 /* shaders.metal */; }; 30A6F62823B29F8200630584 /* Metal.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 30A6F62723B29F8200630584 /* Metal.framework */; }; @@ -259,8 +272,27 @@ 3042F7E2232E9BDD00C03F5E /* Carbon.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Carbon.framework; path = System/Library/Frameworks/Carbon.framework; sourceTree = SDKROOT; }; 3045A1EC22D03C430092B97D /* AppKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AppKit.framework; path = System/Library/Frameworks/AppKit.framework; sourceTree = SDKROOT; }; 3045A1EE22D03C4B0092B97D /* Cocoa.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Cocoa.framework; path = System/Library/Frameworks/Cocoa.framework; sourceTree = SDKROOT; }; + 304B3649262E328400F8DC8E /* S9xControlsPreferencesViewController.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = S9xControlsPreferencesViewController.xib; sourceTree = ""; }; + 304B366A262E82B800F8DC8E /* S9xPreferencesConstants.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = S9xPreferencesConstants.h; sourceTree = ""; }; + 304B366B262E82B800F8DC8E /* S9xPreferencesConstants.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = S9xPreferencesConstants.m; sourceTree = ""; }; 3059DA93250690DB003EF183 /* compat.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = compat.cpp; sourceTree = ""; }; 306561FF236A8BA700A1B3B2 /* gamecontrollerdb.txt */ = {isa = PBXFileReference; lastKnownFileType = text; path = gamecontrollerdb.txt; sourceTree = ""; }; + 306937C72635EE5800007ABB /* S9xDisplayPreferencesViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = S9xDisplayPreferencesViewController.h; sourceTree = ""; }; + 306937C82635EE5800007ABB /* S9xDisplayPreferencesViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = S9xDisplayPreferencesViewController.m; sourceTree = ""; }; + 306937C92635EE5800007ABB /* S9xDisplayPreferencesViewController.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = S9xDisplayPreferencesViewController.xib; sourceTree = ""; }; + 306937CE2636253900007ABB /* S9xPreferencesTabViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = S9xPreferencesTabViewController.h; sourceTree = ""; }; + 306937CF2636253900007ABB /* S9xPreferencesTabViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = S9xPreferencesTabViewController.m; sourceTree = ""; }; + 306937D326362A1100007ABB /* S9xPreferencesViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = S9xPreferencesViewController.h; sourceTree = ""; }; + 306937D426362A1100007ABB /* S9xPreferencesViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = S9xPreferencesViewController.m; sourceTree = ""; }; + 306937D926362B2400007ABB /* S9xSoundPreferencesViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = S9xSoundPreferencesViewController.h; sourceTree = ""; }; + 306937DA26362B2400007ABB /* S9xSoundPreferencesViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = S9xSoundPreferencesViewController.m; sourceTree = ""; }; + 306937DB26362B2400007ABB /* S9xSoundPreferencesViewController.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = S9xSoundPreferencesViewController.xib; sourceTree = ""; }; + 306937DF2636352100007ABB /* S9xEmulationPreferencesViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = S9xEmulationPreferencesViewController.h; sourceTree = ""; }; + 306937E02636352100007ABB /* S9xEmulationPreferencesViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = S9xEmulationPreferencesViewController.m; sourceTree = ""; }; + 306937E12636352100007ABB /* S9xEmulationPreferencesViewController.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = S9xEmulationPreferencesViewController.xib; sourceTree = ""; }; + 306937E52636365100007ABB /* S9xFilesPreferencesViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = S9xFilesPreferencesViewController.h; sourceTree = ""; }; + 306937E62636365100007ABB /* S9xFilesPreferencesViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = S9xFilesPreferencesViewController.m; sourceTree = ""; }; + 306937E72636365100007ABB /* S9xFilesPreferencesViewController.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = S9xFilesPreferencesViewController.xib; sourceTree = ""; }; 30714715230E379500917F82 /* Snes9x.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Snes9x.app; sourceTree = BUILT_PRODUCTS_DIR; }; 30714717230E379500917F82 /* AppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = ""; }; 30714718230E379500917F82 /* AppDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = ""; usesTabs = 0; }; @@ -285,6 +317,8 @@ 3082C4222378BCE80081CA7C /* FakeResources.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FakeResources.h; sourceTree = ""; }; 3082C4282379199F0081CA7C /* S9xApplication.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = S9xApplication.h; sourceTree = ""; }; 3082C4292379199F0081CA7C /* S9xApplication.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = S9xApplication.m; sourceTree = ""; }; + 309C547E2627F3060055DD95 /* S9xControlsPreferencesViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = S9xControlsPreferencesViewController.h; sourceTree = ""; }; + 309C547F2627F3060055DD95 /* S9xControlsPreferencesViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = S9xControlsPreferencesViewController.m; sourceTree = ""; }; 30A6F62323B2771A00630584 /* MetalKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = MetalKit.framework; path = System/Library/Frameworks/MetalKit.framework; sourceTree = SDKROOT; }; 30A6F62523B29EF500630584 /* shaders.metal */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.metal; path = shaders.metal; sourceTree = ""; }; 30A6F62723B29F8200630584 /* Metal.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Metal.framework; path = System/Library/Frameworks/Metal.framework; sourceTree = SDKROOT; }; @@ -677,9 +711,30 @@ children = ( 30D709C3236F90DF00AAB7C3 /* S9xButtonConfigTextField.h */, 30D709C4236F90DF00AAB7C3 /* S9xButtonConfigTextField.m */, + 309C547E2627F3060055DD95 /* S9xControlsPreferencesViewController.h */, + 309C547F2627F3060055DD95 /* S9xControlsPreferencesViewController.m */, + 304B3649262E328400F8DC8E /* S9xControlsPreferencesViewController.xib */, + 306937C72635EE5800007ABB /* S9xDisplayPreferencesViewController.h */, + 306937C82635EE5800007ABB /* S9xDisplayPreferencesViewController.m */, + 306937C92635EE5800007ABB /* S9xDisplayPreferencesViewController.xib */, + 306937DF2636352100007ABB /* S9xEmulationPreferencesViewController.h */, + 306937E02636352100007ABB /* S9xEmulationPreferencesViewController.m */, + 306937E12636352100007ABB /* S9xEmulationPreferencesViewController.xib */, + 306937E52636365100007ABB /* S9xFilesPreferencesViewController.h */, + 306937E62636365100007ABB /* S9xFilesPreferencesViewController.m */, + 306937E72636365100007ABB /* S9xFilesPreferencesViewController.xib */, + 304B366A262E82B800F8DC8E /* S9xPreferencesConstants.h */, + 304B366B262E82B800F8DC8E /* S9xPreferencesConstants.m */, + 306937CE2636253900007ABB /* S9xPreferencesTabViewController.h */, + 306937CF2636253900007ABB /* S9xPreferencesTabViewController.m */, + 306937D326362A1100007ABB /* S9xPreferencesViewController.h */, + 306937D426362A1100007ABB /* S9xPreferencesViewController.m */, 30D709BE236F7E3200AAB7C3 /* S9xPreferencesWindowController.h */, 30D709BF236F7E3200AAB7C3 /* S9xPreferencesWindowController.m */, 30D709C0236F7E3200AAB7C3 /* S9xPreferencesWindowController.xib */, + 306937D926362B2400007ABB /* S9xSoundPreferencesViewController.h */, + 306937DA26362B2400007ABB /* S9xSoundPreferencesViewController.m */, + 306937DB26362B2400007ABB /* S9xSoundPreferencesViewController.xib */, ); path = S9xPreferences; sourceTree = ""; @@ -1175,7 +1230,10 @@ 3071471B230E379600917F82 /* Assets.xcassets in Resources */, 30D709B4236F731B00AAB7C3 /* SAVE.icns in Resources */, 30D709B8236F731B00AAB7C3 /* musicbox_ledoff.icns in Resources */, + 306937CB2635EE5800007ABB /* S9xDisplayPreferencesViewController.xib in Resources */, + 306937E92636365100007ABB /* S9xFilesPreferencesViewController.xib in Resources */, 30D709B0236F583600AAB7C3 /* Localizable.strings in Resources */, + 304B364A262E328400F8DC8E /* S9xControlsPreferencesViewController.xib in Resources */, 30D709B1236F585100AAB7C3 /* Snes9x Help in Resources */, 30D709B3236F731B00AAB7C3 /* SRAM.icns in Resources */, 30D709B5236F731B00AAB7C3 /* folder_SRAMs.icns in Resources */, @@ -1183,7 +1241,9 @@ 30D709B7236F731B00AAB7C3 /* musicbox_ledon.icns in Resources */, 30D709B6236F731B00AAB7C3 /* folder_Freezes.icns in Resources */, 30D709C2236F7E3200AAB7C3 /* S9xPreferencesWindowController.xib in Resources */, + 306937E32636352100007ABB /* S9xEmulationPreferencesViewController.xib in Resources */, 3071471E230E379600917F82 /* MainMenu.xib in Resources */, + 306937DD26362B2400007ABB /* S9xSoundPreferencesViewController.xib in Resources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -1205,11 +1265,19 @@ isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( + 306937D526362A1100007ABB /* S9xPreferencesViewController.m in Sources */, + 306937E22636352100007ABB /* S9xEmulationPreferencesViewController.m in Sources */, + 309C54802627F3060055DD95 /* S9xControlsPreferencesViewController.m in Sources */, 30D709C5236F90DF00AAB7C3 /* S9xButtonConfigTextField.m in Sources */, + 306937E82636365100007ABB /* S9xFilesPreferencesViewController.m in Sources */, + 306937D02636253900007ABB /* S9xPreferencesTabViewController.m in Sources */, 30714721230E379600917F82 /* main.m in Sources */, + 306937CA2635EE5800007ABB /* S9xDisplayPreferencesViewController.m in Sources */, 30714719230E379500917F82 /* AppDelegate.m in Sources */, + 306937DC26362B2400007ABB /* S9xSoundPreferencesViewController.m in Sources */, 3082C42A2379199F0081CA7C /* S9xApplication.m in Sources */, 30D709C1236F7E3200AAB7C3 /* S9xPreferencesWindowController.m in Sources */, + 304B366C262E82B800F8DC8E /* S9xPreferencesConstants.m in Sources */, ); runOnlyForDeploymentPostprocessing = 0; };