mirror of
https://github.com/hrydgard/ppsspp.git
synced 2025-04-02 11:01:50 -04:00
Merge pull request #19171 from hrydgard/ios-even-more-viewcontroller
iOS: Even more viewcontroller refactor
This commit is contained in:
commit
dc68f406aa
7 changed files with 37 additions and 41 deletions
|
@ -1292,6 +1292,7 @@ elseif(IOS AND NOT LIBRETRO)
|
||||||
ios/DisplayManager.mm
|
ios/DisplayManager.mm
|
||||||
ios/Controls.h
|
ios/Controls.h
|
||||||
ios/Controls.mm
|
ios/Controls.mm
|
||||||
|
ios/ViewControllerCommon.h
|
||||||
ios/ViewController.mm
|
ios/ViewController.mm
|
||||||
ios/ViewController.h
|
ios/ViewController.h
|
||||||
ios/iOSCoreAudio.mm
|
ios/iOSCoreAudio.mm
|
||||||
|
|
|
@ -10,8 +10,7 @@
|
||||||
|
|
||||||
@property (nonatomic, strong) id<CameraFrameDelegate> delegate;
|
@property (nonatomic, strong) id<CameraFrameDelegate> delegate;
|
||||||
|
|
||||||
- (void) setCameraSize:(int)width h:(int)height;
|
- (void) startVideo:(int)width h:(int)height;
|
||||||
- (void) startVideo;
|
|
||||||
- (void) stopVideo;
|
- (void) stopVideo;
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
|
@ -37,7 +37,7 @@ NSString *getSelectedCamera() {
|
||||||
if (granted) {
|
if (granted) {
|
||||||
NSLog(@"camera permission granted");
|
NSLog(@"camera permission granted");
|
||||||
dispatch_async(dispatch_get_main_queue(), ^{
|
dispatch_async(dispatch_get_main_queue(), ^{
|
||||||
[self startVideo];
|
[self startVideo:mWidth h:mHeight];
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
NSLog(@"camera permission denied");
|
NSLog(@"camera permission denied");
|
||||||
|
@ -56,14 +56,10 @@ NSString *getSelectedCamera() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
-(void) setCameraSize: (int)width h:(int)height {
|
-(void) startVideo: (int)width h:(int)height {
|
||||||
NSLog(@"CameraHelper::setCameraSize %dx%d", width, height);
|
NSLog(@"CameraHelper::startVideo %dx%d", width, height);
|
||||||
mWidth = width;
|
mWidth = width;
|
||||||
mHeight = height;
|
mHeight = height;
|
||||||
}
|
|
||||||
|
|
||||||
-(void) startVideo {
|
|
||||||
NSLog(@"CameraHelper::startVideo");
|
|
||||||
if ([self checkPermission]) {
|
if ([self checkPermission]) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,15 +7,7 @@
|
||||||
#import "CameraHelper.h"
|
#import "CameraHelper.h"
|
||||||
#import "LocationHelper.h"
|
#import "LocationHelper.h"
|
||||||
|
|
||||||
@protocol PPSSPPViewController<NSObject>
|
#include "ViewControllerCommon.h"
|
||||||
@optional
|
|
||||||
- (void)hideKeyboard;
|
|
||||||
- (void)showKeyboard;
|
|
||||||
- (void)shareText:(NSString *)text;
|
|
||||||
- (void)shutdown;
|
|
||||||
- (void)bindDefaultFBO;
|
|
||||||
- (UIView *)getView;
|
|
||||||
@end
|
|
||||||
|
|
||||||
@interface PPSSPPViewControllerGL : GLKViewController <
|
@interface PPSSPPViewControllerGL : GLKViewController <
|
||||||
iCadeEventDelegate, LocationHandlerDelegate, CameraFrameDelegate,
|
iCadeEventDelegate, LocationHandlerDelegate, CameraFrameDelegate,
|
||||||
|
@ -23,9 +15,3 @@
|
||||||
@end
|
@end
|
||||||
|
|
||||||
extern id <PPSSPPViewController> sharedViewController;
|
extern id <PPSSPPViewController> sharedViewController;
|
||||||
|
|
||||||
void setCameraSize(int width, int height);
|
|
||||||
void startVideo();
|
|
||||||
void stopVideo();
|
|
||||||
void startLocation();
|
|
||||||
void stopLocation();
|
|
||||||
|
|
|
@ -95,13 +95,13 @@ id<PPSSPPViewController> sharedViewController;
|
||||||
|
|
||||||
// TODO: Reach these through sharedViewController
|
// TODO: Reach these through sharedViewController
|
||||||
static CameraHelper *cameraHelper;
|
static CameraHelper *cameraHelper;
|
||||||
static LocationHelper *locationHelper;
|
|
||||||
|
|
||||||
@interface PPSSPPViewControllerGL () {
|
@interface PPSSPPViewControllerGL () {
|
||||||
ICadeTracker g_iCadeTracker;
|
ICadeTracker g_iCadeTracker;
|
||||||
TouchTracker g_touchTracker;
|
TouchTracker g_touchTracker;
|
||||||
|
|
||||||
GraphicsContext *graphicsContext;
|
GraphicsContext *graphicsContext;
|
||||||
|
LocationHelper *locationHelper;
|
||||||
}
|
}
|
||||||
|
|
||||||
@property (nonatomic, strong) EAGLContext* context;
|
@property (nonatomic, strong) EAGLContext* context;
|
||||||
|
@ -382,31 +382,27 @@ extern float g_safeInsetBottom;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void setCameraSize(int width, int height) {
|
- (void)startVideo:(int)width height:(int)height {
|
||||||
[cameraHelper setCameraSize: width h:height];
|
[cameraHelper startVideo:width h:height];
|
||||||
}
|
}
|
||||||
|
|
||||||
void startVideo() {
|
- (void)stopVideo {
|
||||||
[cameraHelper startVideo];
|
|
||||||
}
|
|
||||||
|
|
||||||
void stopVideo() {
|
|
||||||
[cameraHelper 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);
|
Camera::pushCameraImage(len, data);
|
||||||
}
|
}
|
||||||
|
|
||||||
void startLocation() {
|
- (void)startLocation {
|
||||||
[locationHelper startLocationUpdates];
|
[locationHelper startLocationUpdates];
|
||||||
}
|
}
|
||||||
|
|
||||||
void stopLocation() {
|
- (void)stopLocation {
|
||||||
[locationHelper stopLocationUpdates];
|
[locationHelper stopLocationUpdates];
|
||||||
}
|
}
|
||||||
|
|
||||||
-(void) SetGpsDataIOS:(CLLocation *)newLocation {
|
- (void)SetGpsDataIOS:(CLLocation *)newLocation {
|
||||||
GPS::setGpsData((long long)newLocation.timestamp.timeIntervalSince1970,
|
GPS::setGpsData((long long)newLocation.timestamp.timeIntervalSince1970,
|
||||||
newLocation.horizontalAccuracy/5.0,
|
newLocation.horizontalAccuracy/5.0,
|
||||||
newLocation.coordinate.latitude, newLocation.coordinate.longitude,
|
newLocation.coordinate.latitude, newLocation.coordinate.longitude,
|
||||||
|
|
19
ios/ViewControllerCommon.h
Normal file
19
ios/ViewControllerCommon.h
Normal 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
|
|
@ -429,17 +429,16 @@ bool System_MakeRequest(SystemRequestType type, int requestId, const std::string
|
||||||
if (!strncmp(param1.c_str(), "startVideo", 10)) {
|
if (!strncmp(param1.c_str(), "startVideo", 10)) {
|
||||||
int width = 0, height = 0;
|
int width = 0, height = 0;
|
||||||
sscanf(param1.c_str(), "startVideo_%dx%d", &width, &height);
|
sscanf(param1.c_str(), "startVideo_%dx%d", &width, &height);
|
||||||
setCameraSize(width, height);
|
[sharedViewController startVideo:width height:height];
|
||||||
startVideo();
|
|
||||||
} else if (!strcmp(param1.c_str(), "stopVideo")) {
|
} else if (!strcmp(param1.c_str(), "stopVideo")) {
|
||||||
stopVideo();
|
[sharedViewController stopVideo];
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
case SystemRequestType::GPS_COMMAND:
|
case SystemRequestType::GPS_COMMAND:
|
||||||
if (param1 == "open") {
|
if (param1 == "open") {
|
||||||
startLocation();
|
[sharedViewController startLocation];
|
||||||
} else if (param1 == "close") {
|
} else if (param1 == "close") {
|
||||||
stopLocation();
|
[sharedViewController stopLocation];
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
case SystemRequestType::SHARE_TEXT:
|
case SystemRequestType::SHARE_TEXT:
|
||||||
|
|
Loading…
Add table
Reference in a new issue