Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add toggle for using mirrored display as top screen. #196

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion iNDS/AppDelegate.m
Original file line number Diff line number Diff line change
Expand Up @@ -519,7 +519,9 @@ - (WCEasySettingsViewController *)getSettingsViewController
interfaceSection.items = @[[[WCEasySettingsSwitch alloc] initWithIdentifier:@"fullScreenSettings"
title:@"Full Screen Settings"],
[[WCEasySettingsSwitch alloc] initWithIdentifier:@"showFPS"
title:@"Show FPS"]];
title:@"Show FPS"],
[[WCEasySettingsSwitch alloc] initWithIdentifier:@"mirrorDisplay"
title:@"Mirror Display"]];


// Credits
Expand Down
15 changes: 12 additions & 3 deletions iNDS/iNDSEmulatorViewController.mm
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,7 @@ - (void)viewDidLoad
[notificationCenter addObserver:self selector:@selector(screenChanged:) name:UIScreenDidDisconnectNotification object:nil];
[notificationCenter addObserver:self selector:@selector(controllerActivated:) name:GCControllerDidConnectNotification object:nil];
[notificationCenter addObserver:self selector:@selector(controllerDeactivated:) name:GCControllerDidDisconnectNotification object:nil];
[[NSUserDefaults standardUserDefaults] addObserver:self forKeyPath:@"mirrorDisplay" options:NSKeyValueObservingOptionNew context:NULL];

if ([[GCController controllers] count] > 0) {
[self controllerActivated:nil];
Expand Down Expand Up @@ -338,6 +339,13 @@ - (void)loadProfile:(iNDSEmulationProfile *)profile

}

-(void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context
{
if([keyPath isEqual: @"mirrorDisplay"] && emuLoopLock) {
[self performSelector:@selector(screenChanged:)];
}
}

- (void)defaultsChanged:(NSNotification*)notification
{
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
Expand Down Expand Up @@ -403,7 +411,7 @@ - (void)viewWillLayoutSubviews
self.controllerContainerView.alpha = [[NSUserDefaults standardUserDefaults] floatForKey:@"controlOpacity"];
self.startButton.alpha = [[NSUserDefaults standardUserDefaults] floatForKey:@"controlOpacity"];
self.selectButton.alpha = [[NSUserDefaults standardUserDefaults] floatForKey:@"controlOpacity"];
if ([UIScreen screens].count > 1) {
if ([UIScreen screens].count > 1 && ![[NSUserDefaults standardUserDefaults] boolForKey:@"mirrorDisplay"]) {
CGSize screenSize = [UIScreen screens][1].bounds.size;
CGSize viewSize = CGSizeMake(MIN(screenSize.width, screenSize.height * 1.333), MIN(screenSize.width, screenSize.height * 1.333) * 0.75);
glkView[0].frame = CGRectMake(screenSize.width/2 - viewSize.width/2, screenSize.height/2 - viewSize.height/2, viewSize.width, viewSize.height);
Expand All @@ -415,12 +423,13 @@ - (void)dealloc
{
EMU_closeRom();
[[NSNotificationCenter defaultCenter] removeObserver:self];
[[NSUserDefaults standardUserDefaults] removeObserver:self forKeyPath:@"mirrorDisplay"];
}

- (void)screenChanged:(NSNotification*)notification
{
[self pauseEmulation];
if ([UIScreen screens].count > 1) {
if ([UIScreen screens].count > 1 && ![[NSUserDefaults standardUserDefaults] boolForKey:@"mirrorDisplay"]) {
UIScreen *extScreen = [UIScreen screens][1];
extScreen.currentMode = extScreen.availableModes[0];
extWindow = [[UIWindow alloc] initWithFrame:extScreen.bounds];
Expand Down Expand Up @@ -466,7 +475,7 @@ - (void)initGL
//self.context.multiThreaded = YES;
NSLog(@"Is multi: %d", self.context.isMultiThreaded);

if ([UIScreen screens].count > 1) {
if ([UIScreen screens].count > 1 && ![[NSUserDefaults standardUserDefaults] boolForKey:@"mirrorDisplay"]) {
UIScreen *extScreen = [UIScreen screens][1];
extScreen.currentMode = extScreen.availableModes[0];
extWindow = [[UIWindow alloc] initWithFrame:extScreen.bounds];
Expand Down
2 changes: 2 additions & 0 deletions iNDS/settings/Defaults.plist
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>mirrorDisplay</key>
<false/>
<key>videoFilter</key>
<integer>5</integer>
<key>enableMic</key>
Expand Down