clean up UIKit watchOS stuff
This commit is contained in:
parent
20ba0d8d52
commit
bebdac3c71
|
@ -17,27 +17,10 @@
|
||||||
#import "EmulatorProtocol.h"
|
#import "EmulatorProtocol.h"
|
||||||
#import "TrackPad.h"
|
#import "TrackPad.h"
|
||||||
|
|
||||||
@interface NSObject (fs_override)
|
@interface NSObject ()
|
||||||
+(id)sharedApplication;
|
@property(nonatomic, copy) NSArray<__kindof UIViewController *> *viewControllers;
|
||||||
-(id)keyWindow;
|
- (UIView*)timeLabel;
|
||||||
-(id)rootViewController;
|
- (NSString*)timeText;
|
||||||
-(NSArray *)viewControllers;
|
|
||||||
-(id)view;
|
|
||||||
-(NSArray *)subviews;
|
|
||||||
-(id)timeLabel;
|
|
||||||
-(id)layer;
|
|
||||||
-(void)addSubview:(id)subview;
|
|
||||||
-(CGPoint)center;
|
|
||||||
-(NSString*)timeText;
|
|
||||||
-(id)sharedPUICApplication;
|
|
||||||
-(void)_setStatusBarTimeHidden:(BOOL)hidden animated:(BOOL)animated completion:(void (^)(void))completion;
|
|
||||||
-(void)setAffineTransform:(CGAffineTransform)transform;
|
|
||||||
-(void)setContentsScale:(CGFloat)value;
|
|
||||||
-(void)setContentsGravity:(NSString*)gravity;
|
|
||||||
-(void)setMinificationFilter:(NSString*)filter;
|
|
||||||
-(void)addTarget:(nullable id)target action:(SEL)action forControlEvents:(NSUInteger)controlEvents;
|
|
||||||
-(void)setIdleTimerDisabled:(BOOL)disabled;
|
|
||||||
-(BOOL)prefersStatusBarHidden;
|
|
||||||
@end
|
@end
|
||||||
|
|
||||||
@interface InterfaceController () <WKExtendedRuntimeSessionDelegate>
|
@interface InterfaceController () <WKExtendedRuntimeSessionDelegate>
|
||||||
|
@ -77,22 +60,24 @@ static NSObject<Emulator> *sharedEmulator = nil;
|
||||||
|
|
||||||
- (void)hideTimeLabel {
|
- (void)hideTimeLabel {
|
||||||
/* Hack to make the digital time overlay disappear (on watchOS 5) */
|
/* Hack to make the digital time overlay disappear (on watchOS 5) */
|
||||||
id fullScreenView = [self fullScreenView];
|
UIView *fullScreenView = [self fullScreenView];
|
||||||
if ([fullScreenView respondsToSelector:@selector(timeLabel)]) {
|
if ([fullScreenView respondsToSelector:@selector(timeLabel)]) {
|
||||||
[[[fullScreenView timeLabel] layer] setOpacity:0];
|
fullScreenView.timeLabel.layer.opacity = 0.0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Hack to make the digital time overlay disappear (on watchOS 7 and 8) */
|
/* Hack to make the digital time overlay disappear (on watchOS 7 and 8) */
|
||||||
Class PUICApplication = NSClassFromString(@"PUICApplication");
|
Class clsPUICApplication = NSClassFromString(@"PUICApplication");
|
||||||
if ([PUICApplication instancesRespondToSelector:@selector(_setStatusBarTimeHidden:animated:completion:)]) {
|
if ([clsPUICApplication instancesRespondToSelector:@selector(_setStatusBarTimeHidden:animated:completion:)]) {
|
||||||
[[PUICApplication sharedApplication] _setStatusBarTimeHidden:YES animated:NO completion:nil];
|
PUICApplication *app = (PUICApplication*)[clsPUICApplication sharedApplication];
|
||||||
|
[app _setStatusBarTimeHidden:YES animated:NO completion:nil];
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
- (UIView*)fullScreenView {
|
- (UIView*)fullScreenView {
|
||||||
id parentView = [[[[[[NSClassFromString(@"UIApplication") sharedApplication] keyWindow] rootViewController] viewControllers] firstObject] view];
|
UIApplication *app = [NSClassFromString(@"UIApplication") sharedApplication];
|
||||||
id view = [self findDescendantViewOfClass:NSClassFromString(@"SPFullScreenView") inView:parentView]; // watchOS 5
|
UIView *parentView = app.keyWindow.rootViewController.viewControllers.firstObject.view;
|
||||||
|
UIView *view = [self findDescendantViewOfClass:NSClassFromString(@"SPFullScreenView") inView:parentView]; // watchOS 5
|
||||||
if (view == nil) {
|
if (view == nil) {
|
||||||
view = [self findDescendantViewOfClass:NSClassFromString(@"SPInterfaceRemoteView") inView:parentView]; // watchOS 6
|
view = [self findDescendantViewOfClass:NSClassFromString(@"SPInterfaceRemoteView") inView:parentView]; // watchOS 6
|
||||||
}
|
}
|
||||||
|
@ -176,15 +161,25 @@ static NSObject<Emulator> *sharedEmulator = nil;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
sharedEmulator.dataPath = documentsPath;
|
sharedEmulator.dataPath = documentsPath;
|
||||||
sharedEmulator.screenLayer = fullScreenView.layer;
|
|
||||||
sharedEmulator.speed = sharedEmulator.initialSpeed;
|
|
||||||
[sharedEmulator.screenLayer setContentsGravity:@"CAGravityResizeAspectFill"];
|
|
||||||
CGFloat scale = [self bestScaleForScreen];
|
|
||||||
[sharedEmulator.screenLayer setAffineTransform:CGAffineTransformScale(CGAffineTransformMakeRotation(M_PI_2), scale, scale)];
|
|
||||||
[sharedEmulator.screenLayer setMinificationFilter:@"CAFilterTrilinear"];
|
|
||||||
|
|
||||||
TrackPad *trackpad = [[TrackPad alloc] initWithFrame:fullScreenView.bounds];
|
// screen
|
||||||
|
CALayer *screenLayer = [NSClassFromString(@"CALayer") layer];
|
||||||
|
[fullScreenView.layer addSublayer:screenLayer];
|
||||||
|
screenLayer.frame = fullScreenView.layer.bounds;
|
||||||
|
sharedEmulator.screenLayer = screenLayer;
|
||||||
|
sharedEmulator.speed = sharedEmulator.initialSpeed;
|
||||||
|
[screenLayer setContentsGravity:@"CAGravityResizeAspectFill"];
|
||||||
|
CGFloat scale = [self bestScaleForScreen];
|
||||||
|
[screenLayer setAffineTransform:CGAffineTransformScale(CGAffineTransformMakeRotation(M_PI_2), scale, scale)];
|
||||||
|
[screenLayer setMinificationFilter:@"CAFilterTrilinear"];
|
||||||
|
|
||||||
|
// trackpad
|
||||||
|
TrackPad *trackpad = [[TrackPad alloc] initWithFrame:CGRectMake(0, 0, 512, 342)];
|
||||||
[fullScreenView addSubview:trackpad];
|
[fullScreenView addSubview:trackpad];
|
||||||
|
trackpad.center = fullScreenView.center;
|
||||||
|
[trackpad.layer setAffineTransform:CGAffineTransformScale(CGAffineTransformMakeRotation(M_PI_2), 0.5, 0.5)];
|
||||||
|
trackpad.layer.masksToBounds = YES;
|
||||||
|
fullScreenView.clipsToBounds = NO;
|
||||||
|
|
||||||
[self startRuntimeSession];
|
[self startRuntimeSession];
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,6 +13,29 @@
|
||||||
|
|
||||||
NS_ASSUME_NONNULL_BEGIN
|
NS_ASSUME_NONNULL_BEGIN
|
||||||
|
|
||||||
|
typedef NSString *CALayerContentsFilter;
|
||||||
|
typedef NSString *CALayerContentsGravity;
|
||||||
|
|
||||||
|
@interface CALayer : NSObject
|
||||||
|
|
||||||
|
@property(strong) id contents;
|
||||||
|
@property CGRect contentsRect;
|
||||||
|
@property CGRect contentsCenter;
|
||||||
|
@property(copy) CALayerContentsFilter minificationFilter;
|
||||||
|
@property(copy) CALayerContentsGravity contentsGravity;
|
||||||
|
@property float opacity;
|
||||||
|
@property BOOL hidden;
|
||||||
|
@property CGRect bounds;
|
||||||
|
@property CGRect frame;
|
||||||
|
@property CGPoint position;
|
||||||
|
@property CGPoint anchorPoint;
|
||||||
|
@property BOOL masksToBounds;
|
||||||
|
|
||||||
|
+ (instancetype)layer;
|
||||||
|
- (void)addSublayer:(CALayer *)layer;
|
||||||
|
- (void)setAffineTransform:(CGAffineTransform)m;
|
||||||
|
|
||||||
|
@end
|
||||||
|
|
||||||
@interface UIResponder : NSObject
|
@interface UIResponder : NSObject
|
||||||
|
|
||||||
|
@ -21,8 +44,15 @@ NS_ASSUME_NONNULL_BEGIN
|
||||||
@interface UIView : UIResponder
|
@interface UIView : UIResponder
|
||||||
@property(nonatomic,getter=isMultipleTouchEnabled) BOOL multipleTouchEnabled;
|
@property(nonatomic,getter=isMultipleTouchEnabled) BOOL multipleTouchEnabled;
|
||||||
@property(nonatomic) CGRect bounds;
|
@property(nonatomic) CGRect bounds;
|
||||||
|
@property(nullable, nonatomic, copy) UIColor *backgroundColor;
|
||||||
|
@property(nullable, readonly, unsafe_unretained) UIView *superview;
|
||||||
|
@property(nonatomic, readonly, copy) NSArray<__kindof UIView *> *subviews;
|
||||||
|
@property(nonatomic, readonly, strong) CALayer *layer;
|
||||||
|
@property(nonatomic) CGPoint center;
|
||||||
|
@property(nonatomic) BOOL clipsToBounds;
|
||||||
|
|
||||||
- (instancetype)initWithFrame:(CGRect)frame NS_DESIGNATED_INITIALIZER;
|
- (instancetype)initWithFrame:(CGRect)frame NS_DESIGNATED_INITIALIZER;
|
||||||
|
- (void)addSubview:(UIView *)subview;
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
||||||
|
@ -49,6 +79,34 @@ NS_ASSUME_NONNULL_BEGIN
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
||||||
|
@interface UIViewController : UIResponder
|
||||||
|
|
||||||
|
@property(nonatomic, strong) UIView *view;
|
||||||
|
|
||||||
|
-(BOOL)prefersStatusBarHidden;
|
||||||
|
|
||||||
|
@end
|
||||||
|
|
||||||
|
@interface UIWindow : UIView
|
||||||
|
|
||||||
|
@property(nullable, nonatomic,strong) UIViewController *rootViewController;
|
||||||
|
|
||||||
|
@end
|
||||||
|
|
||||||
|
@interface UIApplication : NSObject
|
||||||
|
|
||||||
|
@property(class, nonatomic, readonly) UIApplication *sharedApplication;
|
||||||
|
@property(nullable, nonatomic,readonly) UIWindow *keyWindow;
|
||||||
|
|
||||||
|
@end
|
||||||
|
|
||||||
|
@interface PUICApplication : UIApplication
|
||||||
|
|
||||||
|
+(instancetype)sharedPUICApplication;
|
||||||
|
-(void)_setStatusBarTimeHidden:(BOOL)hidden animated:(BOOL)animated completion:(void (^_Nullable)(void))completion;
|
||||||
|
|
||||||
|
@end
|
||||||
|
|
||||||
NS_ASSUME_NONNULL_END
|
NS_ASSUME_NONNULL_END
|
||||||
|
|
||||||
#endif /* UIKit_h */
|
#endif /* UIKit_h */
|
||||||
|
|
|
@ -1950,6 +1950,7 @@
|
||||||
"\"$(SRCROOT)/minivmac/src/\"",
|
"\"$(SRCROOT)/minivmac/src/\"",
|
||||||
"\"$(SRCROOT)/Mini vMac/\"",
|
"\"$(SRCROOT)/Mini vMac/\"",
|
||||||
"\"$(SRCROOT)/Mini vMac/MacPlus4M-WatchOS\"",
|
"\"$(SRCROOT)/Mini vMac/MacPlus4M-WatchOS\"",
|
||||||
|
"\"$(SRCROOT)/Mini vMac WatchKit Extension\"",
|
||||||
);
|
);
|
||||||
USE_HEADERMAP = NO;
|
USE_HEADERMAP = NO;
|
||||||
VERSIONING_SYSTEM = "apple-generic";
|
VERSIONING_SYSTEM = "apple-generic";
|
||||||
|
@ -2003,6 +2004,7 @@
|
||||||
"\"$(SRCROOT)/minivmac/src/\"",
|
"\"$(SRCROOT)/minivmac/src/\"",
|
||||||
"\"$(SRCROOT)/Mini vMac/\"",
|
"\"$(SRCROOT)/Mini vMac/\"",
|
||||||
"\"$(SRCROOT)/Mini vMac/MacPlus4M-WatchOS\"",
|
"\"$(SRCROOT)/Mini vMac/MacPlus4M-WatchOS\"",
|
||||||
|
"\"$(SRCROOT)/Mini vMac WatchKit Extension\"",
|
||||||
);
|
);
|
||||||
USE_HEADERMAP = NO;
|
USE_HEADERMAP = NO;
|
||||||
VERSIONING_SYSTEM = "apple-generic";
|
VERSIONING_SYSTEM = "apple-generic";
|
||||||
|
|
|
@ -9,13 +9,14 @@
|
||||||
@import Foundation;
|
@import Foundation;
|
||||||
@import CoreGraphics;
|
@import CoreGraphics;
|
||||||
#if TARGET_OS_WATCH
|
#if TARGET_OS_WATCH
|
||||||
#define CALayer NSObject
|
#import "UIKit+Watch.h"
|
||||||
@class InterfaceController;
|
@class InterfaceController;
|
||||||
#define UIViewController InterfaceController
|
#define RootViewControllerClass InterfaceController
|
||||||
@interface NSObject (CALayer)
|
@interface NSObject (CALayer)
|
||||||
- (void)setContents:(id)contents;
|
- (void)setContents:(id)contents;
|
||||||
@end
|
@end
|
||||||
#else
|
#else
|
||||||
|
#define RootViewControllerClass UIViewController
|
||||||
@import QuartzCore;
|
@import QuartzCore;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -48,7 +49,7 @@ typedef NS_ENUM(NSInteger, EmulatorSpeed) {
|
||||||
@property (nonatomic, readonly) NSString *currentApplication;
|
@property (nonatomic, readonly) NSString *currentApplication;
|
||||||
|
|
||||||
@property (nonatomic, strong) void (^showAlert)(NSString *title, NSString *message);
|
@property (nonatomic, strong) void (^showAlert)(NSString *title, NSString *message);
|
||||||
@property (nonatomic, strong) UIViewController *rootViewController;
|
@property (nonatomic, strong) RootViewControllerClass *rootViewController;
|
||||||
|
|
||||||
- (void)run;
|
- (void)run;
|
||||||
- (void)reset;
|
- (void)reset;
|
||||||
|
|
|
@ -10,10 +10,11 @@
|
||||||
#if TARGET_OS_WATCH
|
#if TARGET_OS_WATCH
|
||||||
#import "InterfaceController.h"
|
#import "InterfaceController.h"
|
||||||
#define AppDelegate InterfaceController
|
#define AppDelegate InterfaceController
|
||||||
#define AudioServicesPlaySystemSound
|
#define PlayHapticFeedback
|
||||||
#else
|
#else
|
||||||
#import "AppDelegate.h"
|
#import "AppDelegate.h"
|
||||||
@import AudioToolbox;
|
@import AudioToolbox;
|
||||||
|
#define PlayHapticFeedback AudioServicesPlaySystemSound(1519)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define TRACKPAD_ACCEL_N 1
|
#define TRACKPAD_ACCEL_N 1
|
||||||
|
@ -121,7 +122,7 @@
|
||||||
if (currentTouches.count > 0) {
|
if (currentTouches.count > 0) {
|
||||||
return;
|
return;
|
||||||
} else if (didForceClick) {
|
} else if (didForceClick) {
|
||||||
AudioServicesPlaySystemSound(1519);
|
PlayHapticFeedback;
|
||||||
didForceClick = NO;
|
didForceClick = NO;
|
||||||
[self cancelScheduledClick];
|
[self cancelScheduledClick];
|
||||||
[self mouseUp];
|
[self mouseUp];
|
||||||
|
@ -163,7 +164,7 @@
|
||||||
|
|
||||||
- (void)handleForceClick:(UITouch *)touch {
|
- (void)handleForceClick:(UITouch *)touch {
|
||||||
if (touch.force > 3.0 && !didForceClick) {
|
if (touch.force > 3.0 && !didForceClick) {
|
||||||
AudioServicesPlaySystemSound(1519);
|
PlayHapticFeedback;
|
||||||
didForceClick = YES;
|
didForceClick = YES;
|
||||||
[self startDragging];
|
[self startDragging];
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue