From 87f34277255ce7028952cd6b2a6481caf6f69012 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jesu=CC=81s=20A=2E=20A=CC=81lvarez?= Date: Mon, 25 Mar 2024 20:20:19 +0100 Subject: [PATCH] ifdefs for watchOS --- Mini vMac/EmulatorProtocol.h | 8 ++++++++ Mini vMac/MYOSGLUE.m | 20 ++++++++++++++++---- 2 files changed, 24 insertions(+), 4 deletions(-) diff --git a/Mini vMac/EmulatorProtocol.h b/Mini vMac/EmulatorProtocol.h index 852662f..0d8a4d0 100644 --- a/Mini vMac/EmulatorProtocol.h +++ b/Mini vMac/EmulatorProtocol.h @@ -8,7 +8,15 @@ @import Foundation; @import CoreGraphics; +#if TARGET_OS_WATCH +#define CALayer NSObject +#define UIViewController NSObject +@interface NSObject (CALayer) +- (void)setContents:(id)contents; +@end +#else @import QuartzCore; +#endif typedef NS_ENUM(NSInteger, EmulatorSpeed) { EmulatorSpeedAllOut = -1, diff --git a/Mini vMac/MYOSGLUE.m b/Mini vMac/MYOSGLUE.m index 6bdb06c..02650c7 100644 --- a/Mini vMac/MYOSGLUE.m +++ b/Mini vMac/MYOSGLUE.m @@ -25,22 +25,26 @@ */ @import UIKit; -@import AudioUnit; -@import AudioToolbox; + #include "OSGCOMUI.h" #include "OSGCOMUD.h" #import "EmulatorProtocol.h" +#if MySoundEnabled +@import AudioUnit; +@import AudioToolbox; +#endif + #define kRAM_Size (kRAMa_Size + kRAMb_Size) EXPORTVAR(ui3p, RAM) EXPORTVAR(ui3p, VidROM) EXPORTVAR(ui3p, VidMem) @interface MNVMBundleClassName : NSObject - +#if IncludeSonyNew - (void)makeNewDisk:(NSString*)name size:(NSInteger)size; +#endif - (void)updateScreen:(CGImageRef)screenImage; - @end static __weak MNVMBundleClassName *sharedEmulator = nil; @@ -1646,7 +1650,9 @@ GLOBALPROC WaitForNextTick(void) { @implementation MNVMBundleClassName { +#if IncludeSonyNew __block __weak UITextField *nameTextField; +#endif } @synthesize dataPath; @@ -1760,9 +1766,13 @@ GLOBALPROC WaitForNextTick(void) { } - (void)updateScreen:(CGImageRef)screenImage { +#if TARGET_OS_WATCH + [screenLayer setContents:(__bridge id)screenImage]; +#else if ([UIApplication sharedApplication].applicationState == UIApplicationStateActive) { screenLayer.contents = (__bridge id)screenImage; } +#endif } #pragma mark - Disk @@ -1789,6 +1799,7 @@ GLOBALPROC WaitForNextTick(void) { return @"didEjectDisk"; } +#if IncludeSonyNew - (void)makeNewDisk:(NSString*)name size:(NSInteger)size { UIAlertController *alertController = [UIAlertController alertControllerWithTitle:NSLocalizedString(@"Export File", nil) message:NSLocalizedString(@"Enter new name", nil) preferredStyle:UIAlertControllerStyleAlert]; [alertController addTextFieldWithConfigurationHandler:^(UITextField * _Nonnull textField) { @@ -1819,6 +1830,7 @@ GLOBALPROC WaitForNextTick(void) { vSonyNewDiskWanted = falseblnr; SpeedStopped = falseblnr; } +#endif #pragma mark - Keyboard