diff --git a/CMakeLists.txt b/CMakeLists.txt index e0d117728b..b1e38b10a5 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1292,6 +1292,7 @@ elseif(IOS AND NOT LIBRETRO) ios/DisplayManager.mm ios/Controls.h ios/Controls.mm + ios/ViewControllerCommon.h ios/ViewController.mm ios/ViewController.h ios/iOSCoreAudio.mm diff --git a/ios/CameraHelper.h b/ios/CameraHelper.h index 45de67d5d9..4690a5ff5f 100644 --- a/ios/CameraHelper.h +++ b/ios/CameraHelper.h @@ -10,8 +10,7 @@ @property (nonatomic, strong) id delegate; -- (void) setCameraSize:(int)width h:(int)height; -- (void) startVideo; +- (void) startVideo:(int)width h:(int)height; - (void) stopVideo; @end diff --git a/ios/CameraHelper.mm b/ios/CameraHelper.mm index 86dc9f1aec..ffdb282365 100644 --- a/ios/CameraHelper.mm +++ b/ios/CameraHelper.mm @@ -37,7 +37,7 @@ NSString *getSelectedCamera() { if (granted) { NSLog(@"camera permission granted"); dispatch_async(dispatch_get_main_queue(), ^{ - [self startVideo]; + [self startVideo:mWidth h:mHeight]; }); } else { NSLog(@"camera permission denied"); @@ -56,14 +56,10 @@ NSString *getSelectedCamera() { } } --(void) setCameraSize: (int)width h:(int)height { - NSLog(@"CameraHelper::setCameraSize %dx%d", width, height); +-(void) startVideo: (int)width h:(int)height { + NSLog(@"CameraHelper::startVideo %dx%d", width, height); mWidth = width; mHeight = height; -} - --(void) startVideo { - NSLog(@"CameraHelper::startVideo"); if ([self checkPermission]) { return; } diff --git a/ios/ViewController.h b/ios/ViewController.h index 1e1678685d..fb4fe1c9dc 100644 --- a/ios/ViewController.h +++ b/ios/ViewController.h @@ -7,15 +7,7 @@ #import "CameraHelper.h" #import "LocationHelper.h" -@protocol PPSSPPViewController -@optional -- (void)hideKeyboard; -- (void)showKeyboard; -- (void)shareText:(NSString *)text; -- (void)shutdown; -- (void)bindDefaultFBO; -- (UIView *)getView; -@end +#include "ViewControllerCommon.h" @interface PPSSPPViewControllerGL : GLKViewController < iCadeEventDelegate, LocationHandlerDelegate, CameraFrameDelegate, @@ -23,9 +15,3 @@ @end extern id sharedViewController; - -void setCameraSize(int width, int height); -void startVideo(); -void stopVideo(); -void startLocation(); -void stopLocation(); diff --git a/ios/ViewController.mm b/ios/ViewController.mm index 169cc32de9..e97d67406f 100644 --- a/ios/ViewController.mm +++ b/ios/ViewController.mm @@ -95,13 +95,13 @@ id sharedViewController; // TODO: Reach these through sharedViewController static CameraHelper *cameraHelper; -static LocationHelper *locationHelper; @interface PPSSPPViewControllerGL () { ICadeTracker g_iCadeTracker; TouchTracker g_touchTracker; GraphicsContext *graphicsContext; + LocationHelper *locationHelper; } @property (nonatomic, strong) EAGLContext* context; @@ -382,31 +382,27 @@ extern float g_safeInsetBottom; } } -void setCameraSize(int width, int height) { - [cameraHelper setCameraSize: width h:height]; +- (void)startVideo:(int)width height:(int)height { + [cameraHelper startVideo:width h:height]; } -void startVideo() { - [cameraHelper startVideo]; -} - -void stopVideo() { +- (void)stopVideo { [cameraHelper stopVideo]; } --(void) PushCameraImageIOS:(long long)len buffer:(unsigned char*)data { +- (void)PushCameraImageIOS:(long long)len buffer:(unsigned char*)data { Camera::pushCameraImage(len, data); } -void startLocation() { +- (void)startLocation { [locationHelper startLocationUpdates]; } -void stopLocation() { +- (void)stopLocation { [locationHelper stopLocationUpdates]; } --(void) SetGpsDataIOS:(CLLocation *)newLocation { +- (void)SetGpsDataIOS:(CLLocation *)newLocation { GPS::setGpsData((long long)newLocation.timestamp.timeIntervalSince1970, newLocation.horizontalAccuracy/5.0, newLocation.coordinate.latitude, newLocation.coordinate.longitude, diff --git a/ios/ViewControllerCommon.h b/ios/ViewControllerCommon.h new file mode 100644 index 0000000000..52766bff4d --- /dev/null +++ b/ios/ViewControllerCommon.h @@ -0,0 +1,19 @@ +#pragma once + +#import + +@protocol PPSSPPViewController +@optional + +- (void)hideKeyboard; +- (void)showKeyboard; +- (void)shareText:(NSString *)text; +- (void)shutdown; +- (void)bindDefaultFBO; +- (UIView *)getView; +- (void)startLocation; +- (void)stopLocation; +- (void)startVideo:(int)width height:(int)height; +- (void)stopVideo; + +@end diff --git a/ios/main.mm b/ios/main.mm index 0466c67000..bc0909e8f6 100644 --- a/ios/main.mm +++ b/ios/main.mm @@ -429,17 +429,16 @@ bool System_MakeRequest(SystemRequestType type, int requestId, const std::string if (!strncmp(param1.c_str(), "startVideo", 10)) { int width = 0, height = 0; sscanf(param1.c_str(), "startVideo_%dx%d", &width, &height); - setCameraSize(width, height); - startVideo(); + [sharedViewController startVideo:width height:height]; } else if (!strcmp(param1.c_str(), "stopVideo")) { - stopVideo(); + [sharedViewController stopVideo]; } return true; case SystemRequestType::GPS_COMMAND: if (param1 == "open") { - startLocation(); + [sharedViewController startLocation]; } else if (param1 == "close") { - stopLocation(); + [sharedViewController stopLocation]; } return true; case SystemRequestType::SHARE_TEXT: