Cocoa Port:

- New feature: Users can now save and restore their favorite input settings as an "Input Profile". This feature may be accessed in the Input section in DeSmuME > Preferences.
This commit is contained in:
rogerman 2013-04-04 01:21:21 +00:00
parent 02f7b9f030
commit 41a4ee009f
14 changed files with 3065 additions and 631 deletions

View File

@ -52,6 +52,10 @@
AB0F29C714BE7213009ABC6F /* Icon_RotateCW_420x420.png in Resources */ = {isa = PBXBuildFile; fileRef = AB0F29A314BE7213009ABC6F /* Icon_RotateCW_420x420.png */; };
AB0F29C814BE7213009ABC6F /* Icon_ShowHUD_420x420.png in Resources */ = {isa = PBXBuildFile; fileRef = AB0F29A414BE7213009ABC6F /* Icon_ShowHUD_420x420.png */; };
AB0F29C914BE7213009ABC6F /* Icon_Speaker_420x420.png in Resources */ = {isa = PBXBuildFile; fileRef = AB0F29A514BE7213009ABC6F /* Icon_Speaker_420x420.png */; };
AB213D45170CB141006DDB0F /* InputProfileController.mm in Sources */ = {isa = PBXBuildFile; fileRef = AB213D44170CB141006DDB0F /* InputProfileController.mm */; };
AB213D46170CB141006DDB0F /* InputProfileController.mm in Sources */ = {isa = PBXBuildFile; fileRef = AB213D44170CB141006DDB0F /* InputProfileController.mm */; };
AB213D47170CB141006DDB0F /* InputProfileController.mm in Sources */ = {isa = PBXBuildFile; fileRef = AB213D44170CB141006DDB0F /* InputProfileController.mm */; };
AB213D48170CB141006DDB0F /* InputProfileController.mm in Sources */ = {isa = PBXBuildFile; fileRef = AB213D44170CB141006DDB0F /* InputProfileController.mm */; };
AB2F3B7D15CF9C6000858373 /* KeyNames.plist in Resources */ = {isa = PBXBuildFile; fileRef = AB02475B13886BF300E9F9AB /* KeyNames.plist */; };
AB2F3B7E15CF9C6000858373 /* DefaultKeyMappings.plist in Resources */ = {isa = PBXBuildFile; fileRef = ABC719E1138CB25E002827A9 /* DefaultKeyMappings.plist */; };
AB2F3B7F15CF9C6000858373 /* DefaultUserPrefs.plist in Resources */ = {isa = PBXBuildFile; fileRef = ABBC0F8C1394B1AA0028B6BD /* DefaultUserPrefs.plist */; };
@ -925,6 +929,8 @@
AB0F29A314BE7213009ABC6F /* Icon_RotateCW_420x420.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = Icon_RotateCW_420x420.png; path = images/Icon_RotateCW_420x420.png; sourceTree = "<group>"; };
AB0F29A414BE7213009ABC6F /* Icon_ShowHUD_420x420.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = Icon_ShowHUD_420x420.png; path = images/Icon_ShowHUD_420x420.png; sourceTree = "<group>"; };
AB0F29A514BE7213009ABC6F /* Icon_Speaker_420x420.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = Icon_Speaker_420x420.png; path = images/Icon_Speaker_420x420.png; sourceTree = "<group>"; };
AB213D43170CB141006DDB0F /* InputProfileController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = InputProfileController.h; sourceTree = "<group>"; };
AB213D44170CB141006DDB0F /* InputProfileController.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = InputProfileController.mm; sourceTree = "<group>"; };
AB2F3C4515CF9C6000858373 /* DeSmuME (PPC).app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "DeSmuME (PPC).app"; sourceTree = BUILT_PRODUCTS_DIR; };
AB2F56EE1704C86900E28885 /* utilities.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = utilities.h; sourceTree = "<group>"; };
AB2F56EF1704C86900E28885 /* utilities.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = utilities.c; sourceTree = "<group>"; };
@ -1494,6 +1500,7 @@
AB6A187A16C9951C00384EED /* EmuControllerDelegate.h */,
AB5A795616D5A56000ED84B7 /* InputManager.h */,
AB3ACB6E14C2361100D7D192 /* inputPrefsView.h */,
AB213D43170CB141006DDB0F /* InputProfileController.h */,
AB3ACB7014C2361100D7D192 /* preferencesWindowDelegate.h */,
ABA0356E169127BB00817C69 /* troubleshootingWindowDelegate.h */,
AB3ACB6714C2361100D7D192 /* appDelegate.mm */,
@ -1502,6 +1509,7 @@
AB6A187B16C9951C00384EED /* EmuControllerDelegate.mm */,
AB5A795716D5A56000ED84B7 /* InputManager.mm */,
AB3ACB6F14C2361100D7D192 /* inputPrefsView.mm */,
AB213D44170CB141006DDB0F /* InputProfileController.mm */,
AB3ACB7114C2361100D7D192 /* preferencesWindowDelegate.mm */,
ABA0356F169127C000817C69 /* troubleshootingWindowDelegate.mm */,
);
@ -2650,6 +2658,7 @@
AB4C4C5116F55C64002E07CD /* TDStretch.cpp in Sources */,
AB4C4C5216F55C64002E07CD /* WavFile.cpp in Sources */,
AB2F56F11704C86900E28885 /* utilities.c in Sources */,
AB213D46170CB141006DDB0F /* InputProfileController.mm in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
@ -2807,6 +2816,7 @@
AB4C4C4716F55C64002E07CD /* TDStretch.cpp in Sources */,
AB4C4C4816F55C64002E07CD /* WavFile.cpp in Sources */,
AB2F56F01704C86900E28885 /* utilities.c in Sources */,
AB213D48170CB141006DDB0F /* InputProfileController.mm in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
@ -2964,6 +2974,7 @@
AB4C4C6516F55C64002E07CD /* TDStretch.cpp in Sources */,
AB4C4C6616F55C64002E07CD /* WavFile.cpp in Sources */,
AB2F56F31704C86900E28885 /* utilities.c in Sources */,
AB213D45170CB141006DDB0F /* InputProfileController.mm in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
@ -3091,6 +3102,7 @@
AB4C4C5B16F55C64002E07CD /* TDStretch.cpp in Sources */,
AB4C4C5C16F55C64002E07CD /* WavFile.cpp in Sources */,
AB2F56F21704C86900E28885 /* utilities.c in Sources */,
AB213D47170CB141006DDB0F /* InputProfileController.mm in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};

View File

@ -10,6 +10,9 @@
8D11072F0486CEB800E47090 /* Cocoa.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1058C7A1FEA54F0111CA2CBB /* Cocoa.framework */; };
AB00E87B14205EAE00DE561F /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = AB00E87914205EAE00DE561F /* InfoPlist.strings */; };
AB00E87E14205EBC00DE561F /* MainMenu.xib in Resources */ = {isa = PBXBuildFile; fileRef = AB00E87C14205EBC00DE561F /* MainMenu.xib */; };
AB01005E170D07B000D70FBE /* InputProfileController.mm in Sources */ = {isa = PBXBuildFile; fileRef = AB01005D170D07B000D70FBE /* InputProfileController.mm */; };
AB01005F170D07B000D70FBE /* InputProfileController.mm in Sources */ = {isa = PBXBuildFile; fileRef = AB01005D170D07B000D70FBE /* InputProfileController.mm */; };
AB010060170D07B000D70FBE /* InputProfileController.mm in Sources */ = {isa = PBXBuildFile; fileRef = AB01005D170D07B000D70FBE /* InputProfileController.mm */; };
AB02475C13886BF300E9F9AB /* KeyNames.plist in Resources */ = {isa = PBXBuildFile; fileRef = AB02475B13886BF300E9F9AB /* KeyNames.plist */; };
AB0F290214BE6E68009ABC6F /* Icon_Execute_420x420.png in Resources */ = {isa = PBXBuildFile; fileRef = AB0F28FE14BE6E68009ABC6F /* Icon_Execute_420x420.png */; };
AB0F290314BE6E68009ABC6F /* Icon_Pause_420x420.png in Resources */ = {isa = PBXBuildFile; fileRef = AB0F28FF14BE6E68009ABC6F /* Icon_Pause_420x420.png */; };
@ -630,6 +633,8 @@
AB00E87A14205EAE00DE561F /* English */ = {isa = PBXFileReference; fileEncoding = 10; lastKnownFileType = text.plist.strings; name = English; path = translations/English.lproj/InfoPlist.strings; sourceTree = "<group>"; };
AB00E87D14205EBC00DE561F /* English */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = English; path = translations/English.lproj/MainMenu.xib; sourceTree = "<group>"; };
AB00E89114205ECC00DE561F /* English */ = {isa = PBXFileReference; fileEncoding = 10; lastKnownFileType = text.plist.strings; lineEnding = 0; name = English; path = translations/English.lproj/Localizable.strings; sourceTree = "<group>"; };
AB01005C170D07AF00D70FBE /* InputProfileController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = InputProfileController.h; sourceTree = "<group>"; };
AB01005D170D07B000D70FBE /* InputProfileController.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = InputProfileController.mm; sourceTree = "<group>"; };
AB02475B13886BF300E9F9AB /* KeyNames.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = KeyNames.plist; sourceTree = "<group>"; };
AB02791814415E4C0075E58C /* Info (Debug).plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = "Info (Debug).plist"; sourceTree = "<group>"; };
AB0A0D1914AACA9600E83E91 /* libz.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; name = libz.dylib; path = usr/lib/libz.dylib; sourceTree = SDKROOT; };
@ -1243,6 +1248,7 @@
AB3A655C16CC5416001F5D4A /* EmuControllerDelegate.h */,
AB29B32F16D4BEBF000EF671 /* InputManager.h */,
AB3ACB6E14C2361100D7D192 /* inputPrefsView.h */,
AB01005C170D07AF00D70FBE /* InputProfileController.h */,
AB3ACB7014C2361100D7D192 /* preferencesWindowDelegate.h */,
ABF2B9F81690412A000FF7C0 /* troubleshootingWindowDelegate.h */,
AB3ACB6714C2361100D7D192 /* appDelegate.mm */,
@ -1251,6 +1257,7 @@
AB3A655D16CC5421001F5D4A /* EmuControllerDelegate.mm */,
AB29B33016D4BEBF000EF671 /* InputManager.mm */,
AB3ACB6F14C2361100D7D192 /* inputPrefsView.mm */,
AB01005D170D07B000D70FBE /* InputProfileController.mm */,
AB3ACB7114C2361100D7D192 /* preferencesWindowDelegate.mm */,
ABF2B9FA16904133000FF7C0 /* troubleshootingWindowDelegate.mm */,
);
@ -2247,6 +2254,7 @@
AB8967DA16D2ED0700F826F1 /* DisplayWindowController.mm in Sources */,
AB29B33216D4BEBF000EF671 /* InputManager.mm in Sources */,
AB82445C1704AE9A00B8EE20 /* utilities.c in Sources */,
AB01005F170D07B000D70FBE /* InputProfileController.mm in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
@ -2405,6 +2413,7 @@
AB8967D916D2ED0700F826F1 /* DisplayWindowController.mm in Sources */,
AB29B33116D4BEBF000EF671 /* InputManager.mm in Sources */,
AB82445B1704AE9A00B8EE20 /* utilities.c in Sources */,
AB01005E170D07B000D70FBE /* InputProfileController.mm in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
@ -2551,6 +2560,7 @@
AB68A0DD16B139BC00DE0546 /* OGLRender_3_2.cpp in Sources */,
AB3A656316CC5438001F5D4A /* cocoa_GPU.mm in Sources */,
AB82445D1704AE9A00B8EE20 /* utilities.c in Sources */,
AB010060170D07B000D70FBE /* InputProfileController.mm in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};

View File

@ -32,313 +32,374 @@
<string>Enable/Disable Cheats</string>
<string>Enable/Disable GPU State</string>
</array>
<key>DefaultInputMappings</key>
<dict>
<key>Up</key>
<array>
<key>DefaultInputProfiles</key>
<array>
<dict>
<key>Name</key>
<string>Default</string>
<key>IsDefaultType</key>
<true/>
<key>Mappings</key>
<dict>
<key>deviceCode</key>
<string>NSEventKeyboard</string>
<key>deviceName</key>
<string>Keyboard</string>
<key>elementCode</key>
<string>126</string>
<key>elementName</key>
<string>Up Arrow</string>
<key>Up</key>
<array>
<dict>
<key>deviceInfoSummary</key>
<string>Keyboard: Up Arrow</string>
<key>deviceCode</key>
<string>NSEventKeyboard</string>
<key>deviceName</key>
<string>Keyboard</string>
<key>elementCode</key>
<string>126</string>
<key>elementName</key>
<string>Up Arrow</string>
</dict>
</array>
<key>Down</key>
<array>
<dict>
<key>deviceInfoSummary</key>
<string>Keyboard: Down Arrow</string>
<key>deviceCode</key>
<string>NSEventKeyboard</string>
<key>deviceName</key>
<string>Keyboard</string>
<key>elementCode</key>
<string>125</string>
<key>elementName</key>
<string>Down Arrow</string>
</dict>
</array>
<key>Left</key>
<array>
<dict>
<key>deviceInfoSummary</key>
<string>Keyboard: Left Arrow</string>
<key>deviceCode</key>
<string>NSEventKeyboard</string>
<key>deviceName</key>
<string>Keyboard</string>
<key>elementCode</key>
<string>123</string>
<key>elementName</key>
<string>Left Arrow</string>
</dict>
</array>
<key>Right</key>
<array>
<dict>
<key>deviceInfoSummary</key>
<string>Keyboard: Right Arrow</string>
<key>deviceCode</key>
<string>NSEventKeyboard</string>
<key>deviceName</key>
<string>Keyboard</string>
<key>elementCode</key>
<string>124</string>
<key>elementName</key>
<string>Right Arrow</string>
</dict>
</array>
<key>A</key>
<array>
<dict>
<key>deviceInfoSummary</key>
<string>Keyboard: X</string>
<key>deviceCode</key>
<string>NSEventKeyboard</string>
<key>deviceName</key>
<string>Keyboard</string>
<key>elementCode</key>
<string>7</string>
<key>elementName</key>
<string>X</string>
</dict>
</array>
<key>B</key>
<array>
<dict>
<key>deviceInfoSummary</key>
<string>Keyboard: Z</string>
<key>deviceCode</key>
<string>NSEventKeyboard</string>
<key>deviceName</key>
<string>Keyboard</string>
<key>elementCode</key>
<string>6</string>
<key>elementName</key>
<string>Z</string>
</dict>
</array>
<key>X</key>
<array>
<dict>
<key>deviceInfoSummary</key>
<string>Keyboard: S</string>
<key>deviceCode</key>
<string>NSEventKeyboard</string>
<key>deviceName</key>
<string>Keyboard</string>
<key>elementCode</key>
<string>1</string>
<key>elementName</key>
<string>S</string>
</dict>
</array>
<key>Y</key>
<array>
<dict>
<key>deviceInfoSummary</key>
<string>Keyboard: A</string>
<key>deviceCode</key>
<string>NSEventKeyboard</string>
<key>deviceName</key>
<string>Keyboard</string>
<key>elementCode</key>
<string>0</string>
<key>elementName</key>
<string>A</string>
</dict>
</array>
<key>L</key>
<array>
<dict>
<key>deviceInfoSummary</key>
<string>Keyboard: Q</string>
<key>deviceCode</key>
<string>NSEventKeyboard</string>
<key>deviceName</key>
<string>Keyboard</string>
<key>elementCode</key>
<string>12</string>
<key>elementName</key>
<string>Q</string>
</dict>
</array>
<key>R</key>
<array>
<dict>
<key>deviceInfoSummary</key>
<string>Keyboard: W</string>
<key>deviceCode</key>
<string>NSEventKeyboard</string>
<key>deviceName</key>
<string>Keyboard</string>
<key>elementCode</key>
<string>13</string>
<key>elementName</key>
<string>W</string>
</dict>
</array>
<key>Start</key>
<array>
<dict>
<key>deviceInfoSummary</key>
<string>Keyboard: Return</string>
<key>deviceCode</key>
<string>NSEventKeyboard</string>
<key>deviceName</key>
<string>Keyboard</string>
<key>elementCode</key>
<string>36</string>
<key>elementName</key>
<string>Return</string>
</dict>
</array>
<key>Select</key>
<array>
<dict>
<key>deviceInfoSummary</key>
<string>Keyboard: Tab</string>
<key>deviceCode</key>
<string>NSEventKeyboard</string>
<key>deviceName</key>
<string>Keyboard</string>
<key>elementCode</key>
<string>48</string>
<key>elementName</key>
<string>Tab</string>
</dict>
</array>
<key>Touch</key>
<array>
<dict>
<key>deviceInfoSummary</key>
<string>Keyboard: Primary Button</string>
<key>deviceCode</key>
<string>NSEventMouse</string>
<key>deviceName</key>
<string>Mouse</string>
<key>elementCode</key>
<string>0</string>
<key>elementName</key>
<string>Primary Button</string>
<key>inputSettingsSummary</key>
<string>Use Device Coordinates</string>
<key>useInputForIntCoord</key>
<true/>
</dict>
</array>
<key>Microphone</key>
<array>
<dict>
<key>deviceInfoSummary</key>
<string>Keyboard: ` (Accent)</string>
<key>deviceCode</key>
<string>NSEventKeyboard</string>
<key>deviceName</key>
<string>Keyboard</string>
<key>elementCode</key>
<string>50</string>
<key>elementName</key>
<string>` (Accent)</string>
<key>inputSettingsSummary</key>
<string>Internal Noise Samples</string>
<key>intValue1</key>
<string>1</string>
</dict>
</array>
<key>Lid</key>
<array>
<dict>
<key>deviceInfoSummary</key>
<string>Keyboard: Delete (Backspace)</string>
<key>deviceCode</key>
<string>NSEventKeyboard</string>
<key>deviceName</key>
<string>Keyboard</string>
<key>elementCode</key>
<string>51</string>
<key>elementName</key>
<string>Delete (Backspace)</string>
</dict>
</array>
<key>Debug</key>
<array>
<dict>
<key>deviceInfoSummary</key>
<string>Keyboard: \</string>
<key>deviceCode</key>
<string>NSEventKeyboard</string>
<key>deviceName</key>
<string>Keyboard</string>
<key>elementCode</key>
<string>42</string>
<key>elementName</key>
<string>\</string>
</dict>
</array>
<key>HUD</key>
<array>
<dict>
<key>deviceInfoSummary</key>
<string>Keyboard: H</string>
<key>deviceCode</key>
<string>NSEventKeyboard</string>
<key>deviceName</key>
<string>Keyboard</string>
<key>elementCode</key>
<string>4</string>
<key>elementName</key>
<string>H</string>
</dict>
</array>
<key>Execute/Pause</key>
<array>
<dict>
<key>deviceInfoSummary</key>
<string>Keyboard: Forward Delete</string>
<key>deviceCode</key>
<string>NSEventKeyboard</string>
<key>deviceName</key>
<string>Keyboard</string>
<key>elementCode</key>
<string>117</string>
<key>elementName</key>
<string>Forward Delete</string>
</dict>
</array>
<key>Reset</key>
<array>
<dict>
<key>deviceInfoSummary</key>
<string>Keyboard: Page Down</string>
<key>deviceCode</key>
<string>NSEventKeyboard</string>
<key>deviceName</key>
<string>Keyboard</string>
<key>elementCode</key>
<string>121</string>
<key>elementName</key>
<string>Page Down</string>
</dict>
</array>
<key>Mute/Unmute</key>
<array>
<dict>
<key>deviceInfoSummary</key>
<string>Keyboard: Numpad Clear</string>
<key>deviceCode</key>
<string>NSEventKeyboard</string>
<key>deviceName</key>
<string>Keyboard</string>
<key>elementCode</key>
<string>71</string>
<key>elementName</key>
<string>Numpad Clear</string>
</dict>
</array>
<key>Load State Slot</key>
<array/>
<key>Save State Slot</key>
<array/>
<key>Copy Screen</key>
<array/>
<key>Set Speed</key>
<array>
<dict>
<key>deviceInfoSummary</key>
<string>Keyboard: -</string>
<key>deviceCode</key>
<string>NSEventKeyboard</string>
<key>deviceName</key>
<string>Keyboard</string>
<key>elementCode</key>
<string>27</string>
<key>elementName</key>
<string>-</string>
<key>inputSettingsSummary</key>
<string>0.50x Speed</string>
<key>floatValue0</key>
<string>0.5</string>
</dict>
<dict>
<key>deviceInfoSummary</key>
<string>Keyboard: =</string>
<key>deviceCode</key>
<string>NSEventKeyboard</string>
<key>deviceName</key>
<string>Keyboard</string>
<key>elementCode</key>
<string>24</string>
<key>elementName</key>
<string>=</string>
<key>inputSettingsSummary</key>
<string>2.00x Speed</string>
<key>floatValue0</key>
<integer>2</integer>
</dict>
</array>
<key>Enable/Disable Speed Limiter</key>
<array/>
<key>Enable/Disable Auto Frame Skip</key>
<array/>
<key>Enable/Disable Cheats</key>
<array/>
<key>Enable/Disable GPU State</key>
<array/>
</dict>
</array>
<key>Down</key>
<array>
<dict>
<key>deviceCode</key>
<string>NSEventKeyboard</string>
<key>deviceName</key>
<string>Keyboard</string>
<key>elementCode</key>
<string>125</string>
<key>elementName</key>
<string>Down Arrow</string>
</dict>
</array>
<key>Left</key>
<array>
<dict>
<key>deviceCode</key>
<string>NSEventKeyboard</string>
<key>deviceName</key>
<string>Keyboard</string>
<key>elementCode</key>
<string>123</string>
<key>elementName</key>
<string>Left Arrow</string>
</dict>
</array>
<key>Right</key>
<array>
<dict>
<key>deviceCode</key>
<string>NSEventKeyboard</string>
<key>deviceName</key>
<string>Keyboard</string>
<key>elementCode</key>
<string>124</string>
<key>elementName</key>
<string>Right Arrow</string>
</dict>
</array>
<key>A</key>
<array>
<dict>
<key>deviceCode</key>
<string>NSEventKeyboard</string>
<key>deviceName</key>
<string>Keyboard</string>
<key>elementCode</key>
<string>7</string>
<key>elementName</key>
<string>X</string>
</dict>
</array>
<key>B</key>
<array>
<dict>
<key>deviceCode</key>
<string>NSEventKeyboard</string>
<key>deviceName</key>
<string>Keyboard</string>
<key>elementCode</key>
<string>6</string>
<key>elementName</key>
<string>Z</string>
</dict>
</array>
<key>X</key>
<array>
<dict>
<key>deviceCode</key>
<string>NSEventKeyboard</string>
<key>deviceName</key>
<string>Keyboard</string>
<key>elementCode</key>
<string>1</string>
<key>elementName</key>
<string>S</string>
</dict>
</array>
<key>Y</key>
<array>
<dict>
<key>deviceCode</key>
<string>NSEventKeyboard</string>
<key>deviceName</key>
<string>Keyboard</string>
<key>elementCode</key>
<string>0</string>
<key>elementName</key>
<string>A</string>
</dict>
</array>
<key>L</key>
<array>
<dict>
<key>deviceCode</key>
<string>NSEventKeyboard</string>
<key>deviceName</key>
<string>Keyboard</string>
<key>elementCode</key>
<string>12</string>
<key>elementName</key>
<string>Q</string>
</dict>
</array>
<key>R</key>
<array>
<dict>
<key>deviceCode</key>
<string>NSEventKeyboard</string>
<key>deviceName</key>
<string>Keyboard</string>
<key>elementCode</key>
<string>13</string>
<key>elementName</key>
<string>W</string>
</dict>
</array>
<key>Start</key>
<array>
<dict>
<key>deviceCode</key>
<string>NSEventKeyboard</string>
<key>deviceName</key>
<string>Keyboard</string>
<key>elementCode</key>
<string>36</string>
<key>elementName</key>
<string>Return</string>
</dict>
</array>
<key>Select</key>
<array>
<dict>
<key>deviceCode</key>
<string>NSEventKeyboard</string>
<key>deviceName</key>
<string>Keyboard</string>
<key>elementCode</key>
<string>48</string>
<key>elementName</key>
<string>Tab</string>
</dict>
</array>
<key>Touch</key>
<array>
<dict>
<key>deviceCode</key>
<string>NSEventMouse</string>
<key>deviceName</key>
<string>Mouse</string>
<key>elementCode</key>
<string>0</string>
<key>elementName</key>
<string>Primary Button</string>
<key>useInputForIntCoord</key>
<true/>
</dict>
</array>
<key>Microphone</key>
<array>
<dict>
<key>deviceCode</key>
<string>NSEventKeyboard</string>
<key>deviceName</key>
<string>Keyboard</string>
<key>elementCode</key>
<string>50</string>
<key>elementName</key>
<string>` (Accent)</string>
<key>intValue1</key>
<string>1</string>
</dict>
</array>
<key>Lid</key>
<array>
<dict>
<key>deviceCode</key>
<string>NSEventKeyboard</string>
<key>deviceName</key>
<string>Keyboard</string>
<key>elementCode</key>
<string>51</string>
<key>elementName</key>
<string>Delete (Backspace)</string>
</dict>
</array>
<key>Debug</key>
<array>
<dict>
<key>deviceCode</key>
<string>NSEventKeyboard</string>
<key>deviceName</key>
<string>Keyboard</string>
<key>elementCode</key>
<string>42</string>
<key>elementName</key>
<string>\</string>
</dict>
</array>
<key>HUD</key>
<array>
<dict>
<key>deviceCode</key>
<string>NSEventKeyboard</string>
<key>deviceName</key>
<string>Keyboard</string>
<key>elementCode</key>
<string>4</string>
<key>elementName</key>
<string>H</string>
</dict>
</array>
<key>Execute/Pause</key>
<array>
<dict>
<key>deviceCode</key>
<string>NSEventKeyboard</string>
<key>deviceName</key>
<string>Keyboard</string>
<key>elementCode</key>
<string>117</string>
<key>elementName</key>
<string>Forward Delete</string>
</dict>
</array>
<key>Reset</key>
<array>
<dict>
<key>deviceCode</key>
<string>NSEventKeyboard</string>
<key>deviceName</key>
<string>Keyboard</string>
<key>elementCode</key>
<string>121</string>
<key>elementName</key>
<string>Page Down</string>
</dict>
</array>
<key>Mute/Unmute</key>
<array>
<dict>
<key>deviceCode</key>
<string>NSEventKeyboard</string>
<key>deviceName</key>
<string>Keyboard</string>
<key>elementCode</key>
<string>71</string>
<key>elementName</key>
<string>Numpad Clear</string>
</dict>
</array>
<key>Load State Slot</key>
<array/>
<key>Save State Slot</key>
<array/>
<key>Copy Screen</key>
<array/>
<key>Set Speed</key>
<array>
<dict>
<key>deviceCode</key>
<string>NSEventKeyboard</string>
<key>deviceName</key>
<string>Keyboard</string>
<key>elementCode</key>
<string>27</string>
<key>elementName</key>
<string>-</string>
<key>floatValue0</key>
<string>0.5</string>
</dict>
<dict>
<key>deviceCode</key>
<string>NSEventKeyboard</string>
<key>deviceName</key>
<string>Keyboard</string>
<key>elementCode</key>
<string>24</string>
<key>elementName</key>
<string>=</string>
<key>floatValue0</key>
<integer>2</integer>
</dict>
</array>
<key>Enable/Disable Speed Limiter</key>
<array/>
<key>Enable/Disable Auto Frame Skip</key>
<array/>
<key>Enable/Disable Cheats</key>
<array/>
<key>Enable/Disable GPU State</key>
<array/>
</dict>
</dict>
</array>
</dict>
</plist>

View File

@ -104,6 +104,8 @@
#define NSSTRING_INPUTPREF_NUM_INPUTS_MAPPED NSLocalizedString(@"%ld Input Mapped", nil)
#define NSSTRING_INPUTPREF_NUM_INPUTS_MAPPED_PLURAL NSLocalizedString(@"%ld Inputs Mapped", nil)
#define NSSTRING_INPUTPREF_NO_SAVED_PROFILES NSLocalizedString(@"No saved profiles.", nil)
#define NSSTRING_INPUTPREF_USE_DEVICE_COORDINATES NSLocalizedString(@"Use Device Coordinates", nil)
#define NSSTRING_INPUTPREF_MIC_NONE NSLocalizedString(@"None", nil)
#define NSSTRING_INPUTPREF_MIC_INTERNAL_NOISE NSLocalizedString(@"Internal Noise Samples", nil)

File diff suppressed because it is too large Load Diff

View File

@ -147,6 +147,8 @@ void HandleDeviceRemovalCallback(void *inContext, IOReturn inResult, void *inSen
id<InputHIDManagerTarget> hidInputTarget;
InputHIDManager *hidManager;
NSMutableDictionary *inputMappings;
NSArray *commandTagList;
NSDictionary *commandIcon;
InputCommandMap commandMap;
CommandAttributesMap defaultCommandAttributes;
@ -155,9 +157,11 @@ void HandleDeviceRemovalCallback(void *inContext, IOReturn inResult, void *inSen
@property (readonly) IBOutlet EmuControllerDelegate *emuControl;
@property (retain) id<InputHIDManagerTarget> hidInputTarget;
@property (retain) NSMutableDictionary *inputMappings;
@property (readonly) NSMutableDictionary *inputMappings;
@property (readonly) NSArray *commandTagList;
@property (readonly) NSDictionary *commandIcon;
- (void) addMappingsUsingUserDefaults;
- (void) setMappingsWithMappings:(NSDictionary *)mappings;
- (void) addMappingUsingDeviceInfoDictionary:(NSDictionary *)deviceDict commandAttributes:(const CommandAttributes *)cmdAttr;
- (void) addMappingUsingInputAttributes:(const InputAttributes *)inputAttr commandAttributes:(const CommandAttributes *)cmdAttr;
- (void) addMappingUsingInputList:(const InputAttributesList *)inputList commandAttributes:(const CommandAttributes *)cmdAttr;
@ -173,6 +177,7 @@ void HandleDeviceRemovalCallback(void *inContext, IOReturn inResult, void *inSen
- (BOOL) dispatchCommandUsingIBAction:(const SEL)theSelector sender:(id)sender;
- (void) writeDefaultsInputMappings;
- (NSString *) commandTagFromInputList:(NSArray *)inputList;
- (SEL) selectorOfCommandTag:(const char *)commandTag;
- (CommandAttributes) defaultCommandAttributesForCommandTag:(const char *)commandTag;

View File

@ -788,6 +788,8 @@ void HandleDeviceRemovalCallback(void *inContext, IOReturn inResult, void *inSen
@synthesize emuControl;
@dynamic hidInputTarget;
@synthesize inputMappings;
@synthesize commandTagList;
@synthesize commandIcon;
static std::tr1::unordered_map<unsigned short, std::string> keyboardNameTable; // Key = Key code, Value = Key name
@ -812,7 +814,33 @@ static std::tr1::unordered_map<unsigned short, std::string> keyboardNameTable; /
}
hidManager = [[InputHIDManager alloc] initWithInputManager:self];
inputMappings = [[NSMutableDictionary dictionaryWithCapacity:128] retain];
inputMappings = [[NSMutableDictionary alloc] initWithCapacity:128];
commandTagList = [[[NSDictionary alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"DefaultKeyMappings" ofType:@"plist"]] valueForKey:@"CommandTagList"];
// Initialize the icons associated with each command.
commandIcon = [[NSDictionary alloc] initWithObjectsAndKeys:
[[[NSImage alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"Icon_DSButtonSelect_420x420" ofType:@"png"]] autorelease], @"UNKNOWN COMMAND",
[[[NSImage alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"Icon_ArrowUp_420x420" ofType:@"png"]] autorelease], @"Up",
[[[NSImage alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"Icon_ArrowDown_420x420" ofType:@"png"]] autorelease], @"Down",
[[[NSImage alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"Icon_ArrowLeft_420x420" ofType:@"png"]] autorelease], @"Left",
[[[NSImage alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"Icon_ArrowRight_420x420" ofType:@"png"]] autorelease], @"Right",
[[[NSImage alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"Icon_DSButtonA_420x420" ofType:@"png"]] autorelease], @"A",
[[[NSImage alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"Icon_DSButtonB_420x420" ofType:@"png"]] autorelease], @"B",
[[[NSImage alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"Icon_DSButtonX_420x420" ofType:@"png"]] autorelease], @"X",
[[[NSImage alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"Icon_DSButtonY_420x420" ofType:@"png"]] autorelease], @"Y",
[[[NSImage alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"Icon_DSButtonL_420x420" ofType:@"png"]] autorelease], @"L",
[[[NSImage alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"Icon_DSButtonR_420x420" ofType:@"png"]] autorelease], @"R",
[[[NSImage alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"Icon_DSButtonStart_420x420" ofType:@"png"]] autorelease], @"Start",
[[[NSImage alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"Icon_DSButtonSelect_420x420" ofType:@"png"]] autorelease], @"Select",
[[[NSImage alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"Icon_Microphone_420x420" ofType:@"png"]] autorelease], @"Microphone",
[[[NSImage alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"Icon_ShowHUD_420x420" ofType:@"png"]] autorelease], @"HUD",
[[[NSImage alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"Icon_Execute_420x420" ofType:@"png"]] autorelease], @"Execute",
[[[NSImage alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"Icon_Pause_420x420" ofType:@"png"]] autorelease], @"Pause",
[[[NSImage alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"Icon_Execute_420x420" ofType:@"png"]] autorelease], @"Execute/Pause",
[[[NSImage alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"Icon_Reset_420x420" ofType:@"png"]] autorelease], @"Reset",
[[[NSImage alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"Icon_DSButtonSelect_420x420" ofType:@"png"]] autorelease], @"Touch",
[[[NSImage alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"Icon_VolumeMute_16x16" ofType:@"png"]] autorelease], @"Mute/Unmute",
nil];
// Initialize the selectors used for each command tag. (Do this in code rather than in an external file.)
commandSelector["Up"] = @selector(cmdUpdateDSController:);
@ -921,7 +949,7 @@ static std::tr1::unordered_map<unsigned short, std::string> keyboardNameTable; /
[self addMappingForIBAction:@selector(reset:) commandAttributes:&cmdReset];
[self addMappingForIBAction:@selector(toggleGPUState:) commandAttributes:&cmdToggleGPUState];
[self addMappingsUsingUserDefaults];
[self setMappingsWithMappings:[[NSUserDefaults standardUserDefaults] dictionaryForKey:@"Input_ControllerMappings"]];
return self;
}
@ -929,7 +957,9 @@ static std::tr1::unordered_map<unsigned short, std::string> keyboardNameTable; /
- (void)dealloc
{
[hidManager release];
[self setInputMappings:nil];
[inputMappings release];
[commandTagList release];
[commandIcon release];
[super dealloc];
}
@ -948,54 +978,26 @@ static std::tr1::unordered_map<unsigned short, std::string> keyboardNameTable; /
#pragma mark Class Methods
- (void) addMappingsUsingUserDefaults
- (void) setMappingsWithMappings:(NSDictionary *)mappings
{
// Check to see if the DefaultKeyMappings.plist files exists.
NSDictionary *defaultKeyMappingsDict = [NSDictionary dictionaryWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"DefaultKeyMappings" ofType:@"plist"]];
if (defaultKeyMappingsDict == nil)
if (mappings == nil || commandTagList == nil)
{
return;
}
NSDictionary *defaultMappings = [defaultKeyMappingsDict valueForKey:@"DefaultInputMappings"];
if (defaultMappings == nil)
{
return;
}
NSArray *commandTagList = [defaultKeyMappingsDict valueForKey:@"CommandTagList"];
if (commandTagList == nil)
{
return;
}
// At this point, we need to check every key in the user's preference file and make sure that all the keys
// exist. The keys that must exist are all listed in the DefaultKeyMappings.plist file.
BOOL userMappingsDidChange = NO;
NSMutableDictionary *tempUserMappings = [NSMutableDictionary dictionaryWithDictionary:[[NSUserDefaults standardUserDefaults] dictionaryForKey:@"Input_ControllerMappings"]];
// Add the input mappings, filling in missing data as needed.
for (NSString *commandTag in commandTagList)
{
if ([tempUserMappings objectForKey:commandTag] == nil)
NSArray *deviceInfoList = (NSArray *)[mappings valueForKey:commandTag];
if ([[self inputMappings] valueForKey:commandTag] == nil)
{
[tempUserMappings setValue:[defaultMappings valueForKey:commandTag] forKey:commandTag];
userMappingsDidChange = YES;
[[self inputMappings] setObject:[NSMutableArray arrayWithCapacity:4] forKey:commandTag];
}
else
{
[self removeAllMappingsForCommandTag:[commandTag cStringUsingEncoding:NSUTF8StringEncoding]];
}
}
// If we had to add a missing key, then we need to copy our temporary dictionary back to the
// user's preferences file.
if (userMappingsDidChange)
{
[[NSUserDefaults standardUserDefaults] setObject:tempUserMappings forKey:@"Input_ControllerMappings"];
}
// Finally, add all the input mappings per user defaults.
NSDictionary *userMappings = [[NSUserDefaults standardUserDefaults] dictionaryForKey:@"Input_ControllerMappings"];
for (NSString *commandTag in commandTagList)
{
NSArray *deviceInfoList = (NSArray *)[userMappings valueForKey:commandTag];
[[self inputMappings] setObject:[NSMutableArray arrayWithCapacity:2] forKey:commandTag];
for(NSDictionary *deviceInfo in deviceInfoList)
{
@ -1266,6 +1268,26 @@ static std::tr1::unordered_map<unsigned short, std::string> keyboardNameTable; /
[[NSUserDefaults standardUserDefaults] setObject:[self inputMappings] forKey:@"Input_ControllerMappings"];
}
- (NSString *) commandTagFromInputList:(NSArray *)inputList
{
NSString *commandTag = nil;
if (inputList == nil)
{
return commandTag;
}
for (NSString *tag in inputMappings)
{
if (inputList == [inputMappings valueForKey:tag])
{
commandTag = tag;
break;
}
}
return commandTag;
}
- (SEL) selectorOfCommandTag:(const char *)commandTag
{
return commandSelector[commandTag];

View File

@ -0,0 +1,39 @@
/*
Copyright (C) 2013 DeSmuME team
This file is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 2 of the License, or
(at your option) any later version.
This file is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with the this software. If not, see <http://www.gnu.org/licenses/>.
*/
#import <Cocoa/Cocoa.h>
#import "InputManager.h"
#if MAC_OS_X_VERSION_MAX_ALLOWED > MAC_OS_X_VERSION_10_5
@interface InputProfileController : NSObjectController <NSOutlineViewDelegate, NSOutlineViewDataSource>
#else
@interface InputProfileController : NSObjectController
#endif
{
NSObject *dummyObject;
InputManager *inputManager;
NSOutlineView *profileOutlineView;
}
@property (readonly) IBOutlet NSObject *dummyObject;
@property (readonly) IBOutlet InputManager *inputManager;
@property (readonly) IBOutlet NSOutlineView *profileOutlineView;
- (NSString *) commandTagFromInputList:(NSArray *)inputList;
@end

View File

@ -0,0 +1,238 @@
/*
Copyright (C) 2013 DeSmuME team
This file is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 2 of the License, or
(at your option) any later version.
This file is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with the this software. If not, see <http://www.gnu.org/licenses/>.
*/
#import "InputProfileController.h"
#import "cocoa_globals.h"
@implementation InputProfileController
@synthesize dummyObject;
@synthesize inputManager;
@synthesize profileOutlineView;
- (id)init
{
self = [super init];
if (self == nil)
{
return self;
}
return self;
}
- (void)dealloc
{
[super dealloc];
}
- (NSString *) commandTagFromInputList:(NSArray *)inputList
{
NSDictionary *mappings = [(NSDictionary *)[self content] valueForKey:@"Mappings"];
NSString *commandTag = nil;
if (inputList == nil)
{
return commandTag;
}
for (NSString *tag in mappings)
{
if (inputList == [mappings valueForKey:tag])
{
commandTag = tag;
break;
}
}
return commandTag;
}
#pragma mark NSOutlineViewDelegate Protocol
- (BOOL)selectionShouldChangeInOutlineView:(NSOutlineView *)outlineView
{
return NO;
}
- (BOOL)outlineView:(NSOutlineView *)outlineView shouldTrackCell:(NSCell *)cell forTableColumn:(NSTableColumn *)tableColumn item:(id)item
{
if ([(NSString *)[tableColumn identifier] isEqualToString:@"InputCommandTagColumn"])
{
return YES;
}
return NO;
}
- (NSCell *)outlineView:(NSOutlineView *)outlineView dataCellForTableColumn:(NSTableColumn *)tableColumn item:(id)item
{
NSString *columnID = (NSString *)[tableColumn identifier];
NSCell *outCell = [tableColumn dataCellForRow:[outlineView rowForItem:item]];
if ([columnID isEqualToString:@"InputCommandIconColumn"])
{
if ([item isKindOfClass:[NSArray class]])
{
NSString *commandTag = [self commandTagFromInputList:item];
if (commandTag != nil)
{
NSImage *iconImage = (NSImage *)[[inputManager commandIcon] valueForKey:commandTag];
if (iconImage == nil)
{
iconImage = (NSImage *)[[inputManager commandIcon] valueForKey:@"UNKNOWN COMMAND"];
}
[outCell setImage:iconImage];
}
else
{
outCell = [[[NSCell alloc] init] autorelease];
}
}
else
{
outCell = [[[NSCell alloc] init] autorelease];
}
}
else if ([columnID isEqualToString:@"InputDeviceColumn"])
{
NSFont *newFont = [[NSFontManager sharedFontManager] fontWithFamily:[[outCell font] familyName]
traits:([item isKindOfClass:[NSArray class]]) ? NSBoldFontMask : 0
weight:0
size:[[outCell font] pointSize]];
[outCell setFont:newFont];
}
else if ([columnID isEqualToString:@"InputSettingsSummaryColumn"])
{
NSFont *newFont = [[NSFontManager sharedFontManager] fontWithFamily:[[outCell font] familyName]
traits:([item isKindOfClass:[NSArray class]]) ? NSBoldFontMask : 0
weight:0
size:[[outCell font] pointSize]];
[outCell setFont:newFont];
}
return outCell;
}
#pragma mark NSOutlineViewDataSource Protocol
- (id)outlineView:(NSOutlineView *)outlineView child:(NSInteger)index ofItem:(id)item
{
if (item == nil)
{
NSDictionary *mappings = [(NSDictionary *)[self content] valueForKey:@"Mappings"];
NSString *commandTag = [[inputManager commandTagList] objectAtIndex:index];
return [mappings valueForKey:commandTag];
}
else if ([item isKindOfClass:[NSArray class]])
{
return [(NSArray *)item objectAtIndex:index];
}
return nil;
}
- (BOOL)outlineView:(NSOutlineView *)outlineView isItemExpandable:(id)item
{
if ([item isKindOfClass:[NSArray class]])
{
return YES;
}
return NO;
}
- (NSInteger)outlineView:(NSOutlineView *)outlineView numberOfChildrenOfItem:(id)item
{
NSInteger numberChildren = 0;
if (item == nil)
{
numberChildren = [[inputManager commandTagList] count];
}
else if ([item isKindOfClass:[NSArray class]])
{
numberChildren = [(NSArray *)item count];
}
return numberChildren;
}
- (id)outlineView:(NSOutlineView *)outlineView objectValueForTableColumn:(NSTableColumn *)tableColumn byItem:(id)item
{
NSString *columnID = (NSString *)[tableColumn identifier];
if ([columnID isEqualToString:@"InputCommandIconColumn"])
{
NSString *commandTag = [self commandTagFromInputList:item];
if (commandTag != nil)
{
NSImage *iconImage = (NSImage *)[[inputManager commandIcon] valueForKey:commandTag];
if (iconImage == nil)
{
iconImage = (NSImage *)[[inputManager commandIcon] valueForKey:@"UNKNOWN COMMAND"];
}
return iconImage;
}
else
{
return nil;
}
}
else if ([columnID isEqualToString:@"InputCommandTagColumn"])
{
if ([item isKindOfClass:[NSArray class]])
{
NSString *tag = [self commandTagFromInputList:item];
return tag;
}
else
{
return @"";
}
}
else if ([columnID isEqualToString:@"InputDeviceColumn"])
{
if ([item isKindOfClass:[NSArray class]])
{
const unsigned long inputCount = (unsigned long)[(NSArray *)item count];
return [NSString stringWithFormat:(inputCount != 1) ? NSSTRING_INPUTPREF_NUM_INPUTS_MAPPED_PLURAL : NSSTRING_INPUTPREF_NUM_INPUTS_MAPPED, inputCount];
}
else if ([item isKindOfClass:[NSDictionary class]])
{
return [item valueForKey:@"deviceInfoSummary"];
}
return @"";
}
else if ([columnID isEqualToString:@"InputSettingsSummaryColumn"])
{
NSString *settingsSummary = @"";
if ([item isKindOfClass:[NSDictionary class]])
{
settingsSummary = [item valueForKey:@"inputSettingsSummary"];
}
return settingsSummary;
}
return item;
}
@end

View File

@ -203,6 +203,8 @@
[self setupUserDefaults];
[inputPrefsView initSettingsSheets];
[inputPrefsView populateInputProfileMenu];
[[inputPrefsView inputProfileMenu] selectItemAtIndex:0];
}
- (void)applicationDidFinishLaunching:(NSNotification *)aNotification

View File

@ -19,24 +19,8 @@
#import <Cocoa/Cocoa.h>
#import "InputManager.h"
@class CocoaDSController;
@class InputProfileController;
@interface InputPrefProperties : NSObject
{
NSString *commandTag;
NSImage *icon;
NSWindow *settingsSheet;
}
@property (retain) NSString *commandTag;
@property (retain) NSImage *icon;
@property (retain) NSWindow *settingsSheet;
- (id) initWithCommandTag:(NSString *)theCommandTag icon:(NSImage *)theIcon sheet:(NSWindow *)theSheet;
@end
#pragma mark -
#if MAC_OS_X_VERSION_MAX_ALLOWED > MAC_OS_X_VERSION_10_5
@interface InputPrefsView : NSView <InputHIDManagerTarget, NSOutlineViewDelegate, NSOutlineViewDataSource>
@ -44,10 +28,17 @@
@interface InputPrefsView : NSView <InputHIDManagerTarget>
#endif
{
NSObject *dummyObject;
NSWindow *prefWindow;
NSPopUpButton *inputProfileMenu;
NSButton *inputProfilePreviousButton;
NSButton *inputProfileNextButton;
NSOutlineView *inputPrefOutlineView;
NSObjectController *inputSettingsController;
InputProfileController *inputProfileController;
NSWindow *inputProfileSheet;
NSWindow *inputProfileRenameSheet;
NSWindow *inputSettingsMicrophone;
NSWindow *inputSettingsTouch;
NSWindow *inputSettingsLoadStateSlot;
@ -59,15 +50,23 @@
NSString *configInputTargetID;
NSMutableDictionary *configInputList;
NSDictionary *inputPrefProperties;
NSDictionary *inputSettingsMappings;
NSArray *commandTagList;
NSUInteger _defaultProfileListCount;
NSMutableArray *savedProfilesList;
}
@property (readonly) IBOutlet NSObject *dummyObject;
@property (readonly) IBOutlet NSWindow *prefWindow;
@property (readonly) IBOutlet NSPopUpButton *inputProfileMenu;
@property (readonly) IBOutlet NSButton *inputProfilePreviousButton;
@property (readonly) IBOutlet NSButton *inputProfileNextButton;
@property (readonly) IBOutlet NSOutlineView *inputPrefOutlineView;
@property (readonly) IBOutlet NSObjectController *inputSettingsController;
@property (readonly) IBOutlet InputProfileController *inputProfileController;
@property (readonly) IBOutlet NSWindow *inputProfileSheet;
@property (readonly) IBOutlet NSWindow *inputProfileRenameSheet;
@property (readonly) IBOutlet NSWindow *inputSettingsMicrophone;
@property (readonly) IBOutlet NSWindow *inputSettingsTouch;
@property (readonly) IBOutlet NSWindow *inputSettingsLoadStateSlot;
@ -79,13 +78,17 @@
@property (retain) NSString *configInputTargetID;
- (void) initSettingsSheets;
- (NSString *) commandTagFromInputList:(NSArray *)inputList;
- (void) populateInputProfileMenu;
- (BOOL) handleKeyboardEvent:(NSEvent *)theEvent keyPressed:(BOOL)keyPressed;
- (BOOL) handleMouseButtonEvent:(NSEvent *)mouseEvent buttonPressed:(BOOL)buttonPressed;
- (BOOL) addMappingUsingInputAttributes:(const InputAttributes *)inputAttr commandTag:(NSString *)commandTag;
- (void) setMappingUsingDeviceInfoDictionary:(NSMutableDictionary *)deviceInfo;
- (BOOL) doesProfileNameExist:(NSString *)profileName;
- (void) updateSelectedProfileName;
- (void) didEndSettingsSheet:(NSWindow *)sheet returnCode:(NSInteger)returnCode contextInfo:(void *)contextInfo;
- (void) didEndProfileSheet:(NSWindow *)sheet returnCode:(NSInteger)returnCode contextInfo:(void *)contextInfo;
- (void) didEndProfileRenameSheet:(NSWindow *)sheet returnCode:(NSInteger)returnCode contextInfo:(void *)contextInfo;
- (IBAction) setInputAdd:(id)sender;
- (IBAction) removeInput:(id)sender;
@ -93,4 +96,14 @@
- (IBAction) showSettingsSheet:(id)sender;
- (IBAction) closeSettingsSheet:(id)sender;
- (IBAction) profileNew:(id)sender;
- (IBAction) profileView:(id)sender;
- (IBAction) profileApply:(id)sender;
- (IBAction) profileRename:(id)sender;
- (IBAction) profileSave:(id)sender;
- (IBAction) profileDelete:(id)sender;
- (IBAction) profileSelect:(id)sender;
- (IBAction) closeProfileSheet:(id)sender;
- (IBAction) closeProfileRenameSheet:(id)sender;
@end

View File

@ -17,114 +17,67 @@
*/
#import "inputPrefsView.h"
#import "InputProfileController.h"
#import "preferencesWindowDelegate.h"
#import "cocoa_globals.h"
#import "cocoa_input.h"
#import "cocoa_util.h"
#define INPUT_HOLD_TIME 0.1 // Time in seconds to hold a button in its on state when mapping an input.
@implementation InputPrefProperties
@synthesize commandTag;
@synthesize icon;
@synthesize settingsSheet;
- (id)init
{
return [self initWithCommandTag:@"" icon:nil sheet:nil];
}
- (id) initWithCommandTag:(NSString *)theCommandTag icon:(NSImage *)theIcon sheet:(NSWindow *)theSheet
{
self = [super init];
if (self == nil)
{
return self;
}
commandTag = [theCommandTag retain];
icon = [theIcon retain];
settingsSheet = [theSheet retain];
return self;
}
- (void)dealloc
{
[self setCommandTag:nil];
[self setIcon:nil];
[self setSettingsSheet:nil];
[super dealloc];
}
@end
#pragma mark -
@implementation InputPrefsView
@synthesize dummyObject;
@synthesize prefWindow;
@synthesize inputProfileMenu;
@synthesize inputProfilePreviousButton;
@synthesize inputProfileNextButton;
@synthesize inputPrefOutlineView;
@synthesize inputSettingsController;
@synthesize inputProfileController;
@synthesize inputSettingsMicrophone;
@synthesize inputSettingsTouch;
@synthesize inputSettingsLoadStateSlot;
@synthesize inputSettingsSaveStateSlot;
@synthesize inputSettingsSetSpeedLimit;
@synthesize inputSettingsGPUState;
@synthesize inputProfileSheet;
@synthesize inputProfileRenameSheet;
@synthesize inputManager;
@dynamic configInputTargetID;
- (id)initWithFrame:(NSRect)frame
{
self = [super initWithFrame:frame];
self = [super initWithFrame:frame];
if (self == nil)
{
return self;
}
NSDictionary *defaultKeyMappingsDict = [NSDictionary dictionaryWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"DefaultKeyMappings" ofType:@"plist"]];
NSArray *defaultProfileList = [defaultKeyMappingsDict valueForKey:@"DefaultInputProfiles"];
_defaultProfileListCount = [defaultProfileList count];
NSArray *userDefaultsSavedProfilesList = (NSArray *)[[NSUserDefaults standardUserDefaults] arrayForKey:@"Input_SavedProfiles"];
savedProfilesList = [[NSMutableArray alloc] initWithCapacity:32];
for (NSDictionary *savedProfile in userDefaultsSavedProfilesList)
{
[savedProfilesList addObject:[NSMutableDictionary dictionaryWithDictionary:savedProfile]];
}
configInputTargetID = nil;
configInputList = [[NSMutableDictionary alloc] initWithCapacity:128];
inputPrefProperties = [[NSDictionary alloc] initWithObjectsAndKeys:
[[[NSImage alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"Icon_DSButtonSelect_420x420" ofType:@"png"]] autorelease], @"UNKNOWN COMMAND",
[[[NSImage alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"Icon_ArrowUp_420x420" ofType:@"png"]] autorelease], @"Up",
[[[NSImage alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"Icon_ArrowDown_420x420" ofType:@"png"]] autorelease], @"Down",
[[[NSImage alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"Icon_ArrowLeft_420x420" ofType:@"png"]] autorelease], @"Left",
[[[NSImage alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"Icon_ArrowRight_420x420" ofType:@"png"]] autorelease], @"Right",
[[[NSImage alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"Icon_DSButtonA_420x420" ofType:@"png"]] autorelease], @"A",
[[[NSImage alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"Icon_DSButtonB_420x420" ofType:@"png"]] autorelease], @"B",
[[[NSImage alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"Icon_DSButtonX_420x420" ofType:@"png"]] autorelease], @"X",
[[[NSImage alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"Icon_DSButtonY_420x420" ofType:@"png"]] autorelease], @"Y",
[[[NSImage alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"Icon_DSButtonL_420x420" ofType:@"png"]] autorelease], @"L",
[[[NSImage alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"Icon_DSButtonR_420x420" ofType:@"png"]] autorelease], @"R",
[[[NSImage alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"Icon_DSButtonStart_420x420" ofType:@"png"]] autorelease], @"Start",
[[[NSImage alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"Icon_DSButtonSelect_420x420" ofType:@"png"]] autorelease], @"Select",
[[[NSImage alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"Icon_Microphone_420x420" ofType:@"png"]] autorelease], @"Microphone",
[[[NSImage alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"Icon_ShowHUD_420x420" ofType:@"png"]] autorelease], @"HUD",
[[[NSImage alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"Icon_Execute_420x420" ofType:@"png"]] autorelease], @"Execute",
[[[NSImage alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"Icon_Pause_420x420" ofType:@"png"]] autorelease], @"Pause",
[[[NSImage alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"Icon_Execute_420x420" ofType:@"png"]] autorelease], @"Execute/Pause",
[[[NSImage alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"Icon_Reset_420x420" ofType:@"png"]] autorelease], @"Reset",
[[[NSImage alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"Icon_DSButtonSelect_420x420" ofType:@"png"]] autorelease], @"Touch",
[[[NSImage alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"Icon_VolumeMute_16x16" ofType:@"png"]] autorelease], @"Mute/Unmute",
nil];
commandTagList = [[[NSDictionary dictionaryWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"DefaultKeyMappings" ofType:@"plist"]] valueForKey:@"CommandTagList"] retain];
return self;
}
- (void)dealloc
{
[configInputList release];
[inputPrefProperties release];
[inputSettingsMappings release];
[commandTagList release];
[savedProfilesList release];
[super dealloc];
}
@ -160,25 +113,70 @@
nil];
}
- (NSString *) commandTagFromInputList:(NSArray *)inputList
- (void) populateInputProfileMenu
{
NSString *commandTag = nil;
if (inputList == nil)
NSDictionary *defaultKeyMappingsDict = [NSDictionary dictionaryWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"DefaultKeyMappings" ofType:@"plist"]];
NSArray *defaultProfileList = [defaultKeyMappingsDict valueForKey:@"DefaultInputProfiles"];
if (defaultKeyMappingsDict == nil || defaultProfileList == nil)
{
return commandTag;
return;
}
NSDictionary *inputMappings = [inputManager inputMappings];
for (NSString *tag in inputMappings)
// We're going to populate this menu from scratch, so remove all existing profile items.
NSMenu *profileMenu = [inputProfileMenu menu];
NSInteger menuItemCount = [profileMenu numberOfItems] - 2;
for (NSInteger i = 0; i < menuItemCount; i++)
{
if (inputList == [inputMappings valueForKey:tag])
[profileMenu removeItemAtIndex:i];
}
// Need this to keep track of profile indexes.
NSInteger profileIndex = 0;
// Add the menu items for the default profiles.
for (NSUInteger i = 0; i < _defaultProfileListCount; i++)
{
NSDictionary *profileDict = [defaultProfileList objectAtIndex:i];
NSString *profileName = (NSString *)[profileDict valueForKey:@"Name"];
NSMenuItem *newProfileMenuItem = [[[NSMenuItem alloc] initWithTitle:profileName
action:@selector(profileSelect:)
keyEquivalent:@""] autorelease];
[newProfileMenuItem setTag:profileIndex];
[newProfileMenuItem setTarget:self];
[profileMenu insertItem:newProfileMenuItem atIndex:profileIndex];
profileIndex++;
}
// Add a separator item in between default profiles and user saved profiles.
[[inputProfileMenu menu] insertItem:[NSMenuItem separatorItem] atIndex:profileIndex];
// Add the menu items for the user saved profiles.
if ([savedProfilesList count] < 1)
{
[inputProfileMenu insertItemWithTitle:NSSTRING_INPUTPREF_NO_SAVED_PROFILES atIndex:profileIndex+1];
NSMenuItem *noSavedConfigItem = [inputProfileMenu itemAtIndex:profileIndex+1];
[noSavedConfigItem setEnabled:NO];
}
else
{
for (NSUInteger i = 0; i < [savedProfilesList count]; i++)
{
commandTag = tag;
break;
NSDictionary *profileDict = [savedProfilesList objectAtIndex:i];
NSString *profileName = (NSString *)[profileDict valueForKey:@"Name"];
NSMenuItem *newProfileMenuItem = [[[NSMenuItem alloc] initWithTitle:profileName
action:@selector(profileSelect:)
keyEquivalent:@""] autorelease];
[newProfileMenuItem setTag:profileIndex];
[newProfileMenuItem setTarget:self];
[profileMenu insertItem:newProfileMenuItem atIndex:profileIndex+1];
profileIndex++;
}
}
return commandTag;
[inputProfileMenu selectItemAtIndex:0];
[self profileSelect:[inputProfileMenu itemAtIndex:0]];
}
- (BOOL) handleKeyboardEvent:(NSEvent *)theEvent keyPressed:(BOOL)keyPressed
@ -257,6 +255,36 @@
[inputManager writeDefaultsInputMappings];
}
- (BOOL) doesProfileNameExist:(NSString *)profileName
{
BOOL doesExist = NO;
for (NSMutableDictionary *savedProfile in savedProfilesList)
{
NSString *savedProfileName = (NSString *)[savedProfile valueForKey:@"Name"];
if ([savedProfileName isEqualToString:profileName])
{
doesExist = YES;
break;
}
}
return doesExist;
}
- (void) updateSelectedProfileName
{
NSInteger profileID = [inputProfileMenu indexOfSelectedItem];
NSMutableDictionary *selectedProfile = (NSMutableDictionary *)[inputProfileController content];
if (profileID < (NSInteger)_defaultProfileListCount || selectedProfile == nil)
{
return;
}
[[inputProfileMenu selectedItem] setTitle:(NSString *)[selectedProfile valueForKey:@"Name"]];
[[NSUserDefaults standardUserDefaults] setObject:savedProfilesList forKey:@"Input_SavedProfiles"];
}
- (void) didEndSettingsSheet:(NSWindow *)sheet returnCode:(NSInteger)returnCode contextInfo:(void *)contextInfo
{
[sheet orderOut:self];
@ -281,6 +309,16 @@
[inputSettingsController setContent:nil];
}
- (void) didEndProfileSheet:(NSWindow *)sheet returnCode:(NSInteger)returnCode contextInfo:(void *)contextInfo
{
[sheet orderOut:self];
}
- (void) didEndProfileRenameSheet:(NSWindow *)sheet returnCode:(NSInteger)returnCode contextInfo:(void *)contextInfo
{
[sheet orderOut:self];
}
#pragma mark InputHIDManagerTarget Protocol
- (BOOL) handleHIDQueue:(IOHIDQueueRef)hidQueue
{
@ -363,13 +401,13 @@
{
if ([item isKindOfClass:[NSArray class]])
{
NSString *commandTag = [self commandTagFromInputList:item];
NSString *commandTag = [inputManager commandTagFromInputList:item];
if (commandTag != nil)
{
NSImage *buttonImage = (NSImage *)[inputPrefProperties valueForKey:commandTag];
NSImage *buttonImage = (NSImage *)[[inputManager commandIcon] valueForKey:commandTag];
if (buttonImage == nil)
{
buttonImage = (NSImage *)[inputPrefProperties valueForKey:@"UNKNOWN COMMAND"];
buttonImage = (NSImage *)[[inputManager commandIcon] valueForKey:@"UNKNOWN COMMAND"];
}
[outCell setTitle:NSLocalizedString(commandTag, nil)];
@ -405,7 +443,7 @@
{
if ([item isKindOfClass:[NSDictionary class]])
{
NSString *commandTag = [self commandTagFromInputList:[outlineView parentForItem:item]];
NSString *commandTag = [inputManager commandTagFromInputList:[outlineView parentForItem:item]];
NSWindow *theSheet = (NSWindow *)[inputSettingsMappings valueForKey:commandTag];
[outCell setEnabled:(theSheet == nil) ? NO : YES];
}
@ -430,7 +468,7 @@
{
if (item == nil)
{
NSString *commandTag = [commandTagList objectAtIndex:index];
NSString *commandTag = [[inputManager commandTagList] objectAtIndex:index];
return [[inputManager inputMappings] valueForKey:commandTag];
}
else if ([item isKindOfClass:[NSArray class]])
@ -457,7 +495,7 @@
if (item == nil)
{
numberChildren = [commandTagList count];
numberChildren = [[inputManager commandTagList] count];
}
else if ([item isKindOfClass:[NSArray class]])
{
@ -517,7 +555,7 @@
- (id)outlineView:(NSOutlineView *)outlineView persistentObjectForItem:(id)item
{
return [self commandTagFromInputList:item];
return [inputManager commandTagFromInputList:item];
}
- (id)outlineView:(NSOutlineView *)outlineView itemForPersistentObject:(id)object
@ -615,7 +653,7 @@
[outlineView selectRowIndexes:[NSIndexSet indexSetWithIndex:rowNumber] byExtendingSelection:NO];
NSArray *inputList = (NSArray *)[outlineView itemAtRow:rowNumber];
[self setConfigInputTargetID:[self commandTagFromInputList:inputList]];
[self setConfigInputTargetID:[inputManager commandTagFromInputList:inputList]];
[prefWindow makeFirstResponder:self];
}
}
@ -650,7 +688,7 @@
const NSInteger rowNumber = [outlineView clickedRow];
NSMutableDictionary *item = (NSMutableDictionary *)[outlineView itemAtRow:rowNumber];
NSString *commandTag = [self commandTagFromInputList:[outlineView parentForItem:item]];
NSString *commandTag = [inputManager commandTagFromInputList:[outlineView parentForItem:item]];
NSWindow *theSheet = (NSWindow *)[inputSettingsMappings valueForKey:commandTag];
if (theSheet == nil)
@ -674,4 +712,186 @@
[NSApp endSheet:sheet returnCode:[CocoaDSUtil getIBActionSenderTag:sender]];
}
- (IBAction) profileNew:(id)sender
{
static NSUInteger untitledCount = 1;
NSString *newProfileName = (untitledCount == 1) ? @"Untitled" : [NSString stringWithFormat:@"Untitled %ld", (unsigned long)untitledCount];
while([self doesProfileNameExist:newProfileName])
{
newProfileName = [NSString stringWithFormat:@"Untitled %ld", (unsigned long)++untitledCount];
}
NSMutableDictionary *newProfile = [NSMutableDictionary dictionaryWithObjectsAndKeys:
newProfileName, @"Name",
[NSNumber numberWithBool:NO], @"IsDefaultType",
[[[NSMutableDictionary alloc] initWithDictionary:[inputManager inputMappings] copyItems:YES] autorelease], @"Mappings",
nil];
[savedProfilesList addObject:newProfile];
NSInteger profileIndex = _defaultProfileListCount + [savedProfilesList count] - 1;
NSMenu *profileMenu = [inputProfileMenu menu];
NSMenuItem *newProfileMenuItem = [[[NSMenuItem alloc] initWithTitle:newProfileName
action:@selector(profileSelect:)
keyEquivalent:@""] autorelease];
[newProfileMenuItem setTag:profileIndex];
[newProfileMenuItem setTarget:self];
[profileMenu insertItem:newProfileMenuItem atIndex:profileIndex+1];
// Remove the "no items" menu item when the first profile is saved.
if ([savedProfilesList count] == 1)
{
[inputProfileMenu removeItemAtIndex:profileIndex+2];
}
[inputProfileMenu selectItemAtIndex:profileIndex+1];
[self profileSelect:newProfileMenuItem];
[[NSUserDefaults standardUserDefaults] setObject:savedProfilesList forKey:@"Input_SavedProfiles"];
// Give the user a chance to name the new profile.
[self profileRename:nil];
}
- (IBAction) profileView:(id)sender
{
[NSApp beginSheet:inputProfileSheet
modalForWindow:prefWindow
modalDelegate:self
didEndSelector:@selector(didEndProfileSheet:returnCode:contextInfo:)
contextInfo:nil];
}
- (IBAction) profileApply:(id)sender
{
NSMutableDictionary *selectedProfile = (NSMutableDictionary *)[inputProfileController content];
NSMutableDictionary *profileMappings = (NSMutableDictionary *)[selectedProfile valueForKey:@"Mappings"];
if (profileMappings != nil)
{
// Use setMappingsWithMappings: instead of replacing the input mappings
// completely since we need to keep this particular pointer address for
// the inputMappings dictionary. If we don't do this, the outline view
// will desync.
[inputManager setMappingsWithMappings:profileMappings];
[inputPrefOutlineView reloadData];
[inputManager writeDefaultsInputMappings];
}
}
- (IBAction) profileRename:(id)sender
{
[NSApp beginSheet:inputProfileRenameSheet
modalForWindow:prefWindow
modalDelegate:self
didEndSelector:@selector(didEndProfileRenameSheet:returnCode:contextInfo:)
contextInfo:nil];
}
- (IBAction) profileSave:(id)sender
{
NSMutableDictionary *selectedProfile = (NSMutableDictionary *)[inputProfileController content];
if (selectedProfile == nil)
{
return;
}
[selectedProfile setValue:[[[NSMutableDictionary alloc] initWithDictionary:[inputManager inputMappings] copyItems:YES] autorelease] forKey:@"Mappings"];
[[NSUserDefaults standardUserDefaults] setObject:savedProfilesList forKey:@"Input_SavedProfiles"];
}
- (IBAction) profileDelete:(id)sender
{
NSMutableDictionary *selectedProfile = (NSMutableDictionary *)[inputProfileController content];
if (selectedProfile == nil)
{
return;
}
NSInteger profileIndex = [inputProfileMenu indexOfSelectedItem] - 1;
NSMenu *profileMenu = [inputProfileMenu menu];
[profileMenu removeItemAtIndex:[inputProfileMenu indexOfSelectedItem]];
[savedProfilesList removeObjectAtIndex:(profileIndex - _defaultProfileListCount)];
[inputProfileMenu selectItemAtIndex:0];
// Add the "no items" menu item if there are no profiles saved.
if ([savedProfilesList count] < 1)
{
NSMenuItem *noSavedConfigItem = [[[NSMenuItem alloc] initWithTitle:NSSTRING_INPUTPREF_NO_SAVED_PROFILES
action:NULL
keyEquivalent:@""] autorelease];
[noSavedConfigItem setEnabled:NO];
[profileMenu insertItem:noSavedConfigItem atIndex:profileIndex+1];
}
else // Update the profile indices in the menu tags.
{
for (NSUInteger i = 0; i < [savedProfilesList count]; i++)
{
[[profileMenu itemAtIndex:_defaultProfileListCount+i+1] setTag:_defaultProfileListCount+i];
}
}
[self profileSelect:[inputProfileMenu itemAtIndex:0]];
[[NSUserDefaults standardUserDefaults] setObject:savedProfilesList forKey:@"Input_SavedProfiles"];
}
- (IBAction) profileSelect:(id)sender
{
NSInteger profileID = [CocoaDSUtil getIBActionSenderTag:sender];
NSArray *profileList = nil;
if (profileID < 0 || profileID >= (NSInteger)(_defaultProfileListCount + [savedProfilesList count]))
{
return;
}
if (profileID < (NSInteger)_defaultProfileListCount) // Select one of the default profiles
{
NSDictionary *defaultKeyMappingsDict = [NSDictionary dictionaryWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"DefaultKeyMappings" ofType:@"plist"]];
profileList = [defaultKeyMappingsDict valueForKey:@"DefaultInputProfiles"];
}
else // Select one of the saved configs
{
profileList = savedProfilesList;
}
[inputProfilePreviousButton setTag:profileID-1];
[inputProfilePreviousButton setEnabled:(profileID > 0) ? YES : NO];
[inputProfileNextButton setTag:profileID+1];
[inputProfileNextButton setEnabled:(profileID < ((NSInteger)_defaultProfileListCount + (NSInteger)[savedProfilesList count] - 1)) ? YES : NO];
if (![sender isMemberOfClass:[NSMenuItem class]])
{
[inputProfileMenu selectItemAtIndex:(profileID < (NSInteger)_defaultProfileListCount) ? profileID : profileID+1];
}
[inputProfileController setContent:[profileList objectAtIndex:(profileID < (NSInteger)_defaultProfileListCount) ? profileID : (profileID - _defaultProfileListCount)]];
[[inputProfileController profileOutlineView] reloadData];
[[inputProfileController profileOutlineView] expandItem:nil expandChildren:YES];
}
- (IBAction) closeProfileSheet:(id)sender
{
NSWindow *sheet = [(NSControl *)sender window];
[sheet makeFirstResponder:nil]; // Force end of editing of any text fields.
[NSApp endSheet:sheet returnCode:[CocoaDSUtil getIBActionSenderTag:sender]];
}
- (IBAction) closeProfileRenameSheet:(id)sender
{
NSWindow *sheet = [(NSControl *)sender window];
[sheet makeFirstResponder:nil]; // Force end of editing of any text fields.
[NSApp endSheet:sheet returnCode:[CocoaDSUtil getIBActionSenderTag:sender]];
}
#pragma mark NSControl Delegate Methods
- (void)controlTextDidEndEditing:(NSNotification *)aNotification
{
// Called when the profile view sheet changes the profile name
[self updateSelectedProfileName];
}
@end