2016-03-30 20:07:55 +00:00
|
|
|
#import "AppDelegate.h"
|
2017-01-24 19:00:56 +00:00
|
|
|
#include "GBButtons.h"
|
2017-10-12 21:02:02 +00:00
|
|
|
#include <Core/gb.h>
|
2017-01-24 19:00:56 +00:00
|
|
|
#import <Carbon/Carbon.h>
|
2016-03-30 20:07:55 +00:00
|
|
|
|
|
|
|
@implementation AppDelegate
|
2016-04-13 19:43:16 +00:00
|
|
|
{
|
|
|
|
NSWindow *preferences_window;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void) applicationDidFinishLaunching:(NSNotification *)notification
|
|
|
|
{
|
2017-01-24 19:00:56 +00:00
|
|
|
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
|
|
|
|
for (unsigned i = 0; i < GBButtonCount; i++) {
|
|
|
|
if ([[defaults objectForKey:button_to_preference_name(i)] isKindOfClass:[NSString class]]) {
|
|
|
|
[defaults removeObjectForKey:button_to_preference_name(i)];
|
|
|
|
}
|
|
|
|
}
|
2016-04-13 19:43:16 +00:00
|
|
|
[[NSUserDefaults standardUserDefaults] registerDefaults:@{
|
2017-01-24 19:00:56 +00:00
|
|
|
@"GBRight": @(kVK_RightArrow),
|
|
|
|
@"GBLeft": @(kVK_LeftArrow),
|
|
|
|
@"GBUp": @(kVK_UpArrow),
|
|
|
|
@"GBDown": @(kVK_DownArrow),
|
2016-04-13 19:43:16 +00:00
|
|
|
|
2017-01-24 19:00:56 +00:00
|
|
|
@"GBA": @(kVK_ANSI_X),
|
|
|
|
@"GBB": @(kVK_ANSI_Z),
|
|
|
|
@"GBSelect": @(kVK_Delete),
|
|
|
|
@"GBStart": @(kVK_Return),
|
2016-04-13 19:43:16 +00:00
|
|
|
|
2017-01-24 19:00:56 +00:00
|
|
|
@"GBTurbo": @(kVK_Space),
|
2018-02-10 12:42:14 +00:00
|
|
|
@"GBRewind": @(kVK_Tab),
|
2018-02-10 21:30:30 +00:00
|
|
|
@"GBSlow-Motion": @(kVK_Shift),
|
2016-04-28 20:07:05 +00:00
|
|
|
|
|
|
|
@"GBFilter": @"NearestNeighbor",
|
2017-10-12 14:22:22 +00:00
|
|
|
@"GBColorCorrection": @(GB_COLOR_CORRECTION_EMULATE_HARDWARE),
|
2018-02-10 12:42:14 +00:00
|
|
|
@"GBHighpassFilter": @(GB_HIGHPASS_REMOVE_DC_OFFSET),
|
|
|
|
@"GBRewindLength": @(10)
|
2016-04-13 19:43:16 +00:00
|
|
|
}];
|
|
|
|
}
|
2016-03-30 20:07:55 +00:00
|
|
|
|
2017-01-24 19:00:56 +00:00
|
|
|
- (IBAction)toggleDeveloperMode:(id)sender
|
|
|
|
{
|
2016-04-08 10:54:34 +00:00
|
|
|
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
|
|
|
|
[defaults setBool:![defaults boolForKey:@"DeveloperMode"] forKey:@"DeveloperMode"];
|
2016-03-30 20:07:55 +00:00
|
|
|
}
|
|
|
|
|
2016-04-08 10:54:34 +00:00
|
|
|
- (BOOL)validateMenuItem:(NSMenuItem *)anItem
|
|
|
|
{
|
|
|
|
if ([anItem action] == @selector(toggleDeveloperMode:)) {
|
|
|
|
[(NSMenuItem*)anItem setState:[[NSUserDefaults standardUserDefaults] boolForKey:@"DeveloperMode"]];
|
|
|
|
}
|
|
|
|
|
2016-04-13 19:43:16 +00:00
|
|
|
return true;
|
2016-03-30 20:07:55 +00:00
|
|
|
}
|
|
|
|
|
2016-04-13 19:43:16 +00:00
|
|
|
- (IBAction) showPreferences: (id) sender
|
|
|
|
{
|
|
|
|
NSArray *objects;
|
|
|
|
if (!_preferencesWindow) {
|
|
|
|
[[NSBundle mainBundle] loadNibNamed:@"Preferences" owner:self topLevelObjects:&objects];
|
|
|
|
}
|
|
|
|
[_preferencesWindow makeKeyAndOrderFront:self];
|
|
|
|
}
|
2016-09-10 16:46:42 +00:00
|
|
|
|
2016-10-01 21:10:09 +00:00
|
|
|
- (BOOL)applicationOpenUntitledFile:(NSApplication *)sender
|
2016-09-10 16:46:42 +00:00
|
|
|
{
|
2016-10-01 21:10:09 +00:00
|
|
|
[[NSDocumentController sharedDocumentController] openDocument:self];
|
|
|
|
return YES;
|
2016-09-10 16:46:42 +00:00
|
|
|
}
|
2016-10-01 21:10:09 +00:00
|
|
|
|
2016-03-30 20:07:55 +00:00
|
|
|
@end
|