Merge pull request #19171 from hrydgard/ios-even-more-viewcontroller

iOS: Even more viewcontroller refactor
This commit is contained in:
Henrik Rydgård 2024-05-22 16:56:39 +02:00 committed by GitHub
commit dc68f406aa
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
7 changed files with 37 additions and 41 deletions

View file

@ -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

View file

@ -10,8 +10,7 @@
@property (nonatomic, strong) id<CameraFrameDelegate> delegate;
- (void) setCameraSize:(int)width h:(int)height;
- (void) startVideo;
- (void) startVideo:(int)width h:(int)height;
- (void) stopVideo;
@end

View file

@ -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;
}

View file

@ -7,15 +7,7 @@
#import "CameraHelper.h"
#import "LocationHelper.h"
@protocol PPSSPPViewController<NSObject>
@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 <PPSSPPViewController> sharedViewController;
void setCameraSize(int width, int height);
void startVideo();
void stopVideo();
void startLocation();
void stopLocation();

View file

@ -95,13 +95,13 @@ id<PPSSPPViewController> 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,

View file

@ -0,0 +1,19 @@
#pragma once
#import <UIKit/UIKit.h>
@protocol PPSSPPViewController<NSObject>
@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

View file

@ -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: