mirror of
https://github.com/zydeco/minivmac4ios.git
synced 2024-06-14 07:29:31 +00:00
dreadful abominations for networking to work on watchOS
This commit is contained in:
parent
54f6496031
commit
4684df5fc6
|
@ -30,6 +30,15 @@
|
|||
<key>NSExtensionPointIdentifier</key>
|
||||
<string>com.apple.watchkit</string>
|
||||
</dict>
|
||||
<key>UIBackgroundModes</key>
|
||||
<array>
|
||||
<string>audio</string>
|
||||
<string>fetch</string>
|
||||
</array>
|
||||
<key>WKBackgroundModes</key>
|
||||
<array>
|
||||
<string>mindfulness</string>
|
||||
</array>
|
||||
<key>WKExtensionDelegateClassName</key>
|
||||
<string>ExtensionDelegate</string>
|
||||
</dict>
|
||||
|
|
|
@ -10,6 +10,7 @@
|
|||
@import UIKit;
|
||||
@import ObjectiveC.runtime;
|
||||
@import WatchConnectivity;
|
||||
@import AVFAudio;
|
||||
|
||||
#import "UIKit+Watch.h"
|
||||
#import "InterfaceController.h"
|
||||
|
@ -38,7 +39,7 @@
|
|||
-(void)setIdleTimerDisabled:(BOOL)disabled;
|
||||
@end
|
||||
|
||||
@interface InterfaceController ()
|
||||
@interface InterfaceController () <WKExtendedRuntimeSessionDelegate>
|
||||
|
||||
@end
|
||||
|
||||
|
@ -46,7 +47,7 @@ static NSObject<Emulator> *sharedEmulator = nil;
|
|||
|
||||
@implementation InterfaceController
|
||||
{
|
||||
|
||||
WKExtendedRuntimeSession *runtimeSession;
|
||||
}
|
||||
|
||||
+ (void)load {
|
||||
|
@ -128,27 +129,66 @@ static NSObject<Emulator> *sharedEmulator = nil;
|
|||
}
|
||||
|
||||
- (void)loadAndStartEmulator {
|
||||
#ifdef LTOVRTCP_SERVER
|
||||
setenv("LTOVRTCP_SERVER", LTOVRTCP_SERVER, 1);
|
||||
#endif
|
||||
UIView *fullScreenView = [self fullScreenView];
|
||||
Class emulatorClass = NSClassFromString(@"MacPlus4MEmulator");
|
||||
sharedEmulator = [emulatorClass new];
|
||||
sharedEmulator.rootViewController = nil;
|
||||
sharedEmulator.rootViewController = self;
|
||||
sharedEmulator.showAlert = ^(NSString *title, NSString *message) {
|
||||
[self presentAlertControllerWithTitle:title message:message preferredStyle:WKAlertControllerStyleAlert actions:@[
|
||||
[WKAlertAction actionWithTitle:@"OK" style:WKAlertActionStyleDefault handler:^{}]]];
|
||||
};
|
||||
sharedEmulator.dataPath = [NSBundle mainBundle].resourcePath;
|
||||
|
||||
NSString *documentsPath = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES).firstObject.stringByStandardizingPath;
|
||||
NSString *resourcePath = [NSBundle mainBundle].resourcePath;
|
||||
NSFileManager *fm = [NSFileManager defaultManager];
|
||||
for (NSString *fileName in @[@"vMac.rom", @"disk1.dsk"]) {
|
||||
NSString *srcPath = [resourcePath stringByAppendingPathComponent:fileName];
|
||||
NSString *dstPath = [documentsPath stringByAppendingPathComponent:fileName];
|
||||
if ([fm fileExistsAtPath:srcPath] && ![fm fileExistsAtPath:dstPath]) {
|
||||
[fm copyItemAtPath:srcPath toPath:dstPath error:NULL];
|
||||
}
|
||||
}
|
||||
sharedEmulator.dataPath = documentsPath;
|
||||
sharedEmulator.screenLayer = fullScreenView.layer;
|
||||
sharedEmulator.speed = sharedEmulator.initialSpeed;
|
||||
[sharedEmulator.screenLayer setContentsGravity:@"CAGravityResizeAspectFill"];
|
||||
[sharedEmulator.screenLayer setAffineTransform:CGAffineTransformScale(CGAffineTransformMakeRotation(M_PI_2), 0.375, 0.375)];
|
||||
[sharedEmulator.screenLayer setMinificationFilter:@"CAFilterTrilinear"];
|
||||
#if TARGET_OS_SIMULATOR
|
||||
[sharedEmulator performSelector:@selector(run) withObject:nil afterDelay:0.1];
|
||||
|
||||
id app = [NSClassFromString(@"UIApplication") sharedApplication];
|
||||
[app setIdleTimerDisabled:YES];
|
||||
#endif
|
||||
|
||||
TrackPad *trackpad = [[TrackPad alloc] initWithFrame:fullScreenView.bounds];
|
||||
[fullScreenView addSubview:trackpad];
|
||||
|
||||
runtimeSession = [WKExtendedRuntimeSession new];
|
||||
runtimeSession.delegate = self;
|
||||
[runtimeSession start];
|
||||
}
|
||||
|
||||
- (void)extendedRuntimeSessionDidStart:(WKExtendedRuntimeSession *)extendedRuntimeSession {
|
||||
#if TARGET_OS_SIMULATOR == 0
|
||||
[[AVAudioSession sharedInstance] setCategory:AVAudioSessionCategoryPlayback
|
||||
mode:AVAudioSessionModeDefault
|
||||
routeSharingPolicy:AVAudioSessionRouteSharingPolicyLongFormAudio
|
||||
options:0
|
||||
error:NULL];
|
||||
[[AVAudioSession sharedInstance] activateWithOptions:0 completionHandler:^(BOOL activated, NSError * _Nullable error) {
|
||||
// network only works on watchOS when there's an active audio session
|
||||
[sharedEmulator performSelectorOnMainThread:@selector(run) withObject:nil waitUntilDone:NO];
|
||||
}];
|
||||
#endif
|
||||
}
|
||||
|
||||
- (void)extendedRuntimeSession:(WKExtendedRuntimeSession *)extendedRuntimeSession didInvalidateWithReason:(WKExtendedRuntimeSessionInvalidationReason)reason error:(NSError *)error {
|
||||
NSLog(@"Runtime session invalidated: %@", error);
|
||||
}
|
||||
|
||||
- (void)extendedRuntimeSessionWillExpire:(WKExtendedRuntimeSession *)extendedRuntimeSession {
|
||||
NSLog(@"Extended runtime session will expire");
|
||||
}
|
||||
|
||||
@end
|
||||
|
|
|
@ -332,6 +332,8 @@
|
|||
/* End PBXCopyFilesBuildPhase section */
|
||||
|
||||
/* Begin PBXFileReference section */
|
||||
2810D4722BB7441600A00C47 /* CoreAudioTypes.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreAudioTypes.framework; path = Platforms/WatchOS.platform/Developer/SDKs/WatchOS10.4.sdk/System/Library/Frameworks/CoreAudioTypes.framework; sourceTree = DEVELOPER_DIR; };
|
||||
2810D4732BB7441600A00C47 /* CoreAudio.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreAudio.framework; path = Platforms/WatchOS.platform/Developer/SDKs/WatchOS10.4.sdk/System/Library/Frameworks/CoreAudio.framework; sourceTree = DEVELOPER_DIR; };
|
||||
2834204B2B96558700D7DB68 /* LTOVRUDP.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = LTOVRUDP.h; sourceTree = "<group>"; };
|
||||
283422CA1CF8EF8C0088B634 /* MacPlus4M.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = MacPlus4M.framework; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||
283422D71CF8EFD80088B634 /* EmulatorProtocol.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = EmulatorProtocol.h; sourceTree = "<group>"; };
|
||||
|
@ -675,6 +677,8 @@
|
|||
2896738F2BB4947A0014D8E7 /* Frameworks */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
2810D4732BB7441600A00C47 /* CoreAudio.framework */,
|
||||
2810D4722BB7441600A00C47 /* CoreAudioTypes.framework */,
|
||||
);
|
||||
name = Frameworks;
|
||||
sourceTree = "<group>";
|
||||
|
@ -2268,7 +2272,7 @@
|
|||
SUPPORTED_PLATFORMS = "watchsimulator watchos";
|
||||
TARGETED_DEVICE_FAMILY = 4;
|
||||
USER_HEADER_SEARCH_PATHS = "\"$(SRCROOT)/../Mini vMac\"";
|
||||
WATCHOS_DEPLOYMENT_TARGET = 5.0;
|
||||
WATCHOS_DEPLOYMENT_TARGET = 8.5;
|
||||
};
|
||||
name = Debug;
|
||||
};
|
||||
|
@ -2293,7 +2297,7 @@
|
|||
SUPPORTED_PLATFORMS = "watchsimulator watchos";
|
||||
TARGETED_DEVICE_FAMILY = 4;
|
||||
USER_HEADER_SEARCH_PATHS = "\"$(SRCROOT)/../Mini vMac\"";
|
||||
WATCHOS_DEPLOYMENT_TARGET = 5.0;
|
||||
WATCHOS_DEPLOYMENT_TARGET = 8.5;
|
||||
};
|
||||
name = Release;
|
||||
};
|
||||
|
@ -2311,7 +2315,7 @@
|
|||
SKIP_INSTALL = YES;
|
||||
SUPPORTED_PLATFORMS = "watchsimulator watchos";
|
||||
TARGETED_DEVICE_FAMILY = 4;
|
||||
WATCHOS_DEPLOYMENT_TARGET = 5.0;
|
||||
WATCHOS_DEPLOYMENT_TARGET = 8.5;
|
||||
};
|
||||
name = Debug;
|
||||
};
|
||||
|
@ -2329,7 +2333,7 @@
|
|||
SKIP_INSTALL = YES;
|
||||
SUPPORTED_PLATFORMS = "watchsimulator watchos";
|
||||
TARGETED_DEVICE_FAMILY = 4;
|
||||
WATCHOS_DEPLOYMENT_TARGET = 5.0;
|
||||
WATCHOS_DEPLOYMENT_TARGET = 8.5;
|
||||
};
|
||||
name = Release;
|
||||
};
|
||||
|
|
|
@ -10,7 +10,8 @@
|
|||
@import CoreGraphics;
|
||||
#if TARGET_OS_WATCH
|
||||
#define CALayer NSObject
|
||||
#define UIViewController NSObject
|
||||
@class InterfaceController;
|
||||
#define UIViewController InterfaceController
|
||||
@interface NSObject (CALayer)
|
||||
- (void)setContents:(id)contents;
|
||||
@end
|
||||
|
|
Loading…
Reference in New Issue
Block a user