Move even more stuff into PPSSPPBaseViewController

This commit is contained in:
Henrik Rydgård
2025-10-27 21:38:27 +01:00
parent d5834d0f84
commit c7370c2e72
6 changed files with 153 additions and 263 deletions
+1 -2
View File
@@ -2,14 +2,13 @@
#import <UIKit/UIKit.h> #import <UIKit/UIKit.h>
#import <GLKit/GLKit.h> #import <GLKit/GLKit.h>
#import <GameController/GameController.h>
#import "iCade/iCadeReaderView.h" #import "iCade/iCadeReaderView.h"
#import "LocationHelper.h" #import "LocationHelper.h"
#import "ViewControllerCommon.h" #import "ViewControllerCommon.h"
@interface PPSSPPViewControllerGL : PPSSPPBaseViewController<GLKViewDelegate, iCadeEventDelegate> @interface PPSSPPViewControllerGL : PPSSPPBaseViewController<GLKViewDelegate>
// Public-ish control similar to GLKViewController // Public-ish control similar to GLKViewController
@property (nonatomic, assign) NSInteger preferredFramesPerSecond; // default 60 @property (nonatomic, assign) NSInteger preferredFramesPerSecond; // default 60
+12 -136
View File
@@ -9,10 +9,8 @@
#import "ViewController.h" #import "ViewController.h"
#import "DisplayManager.h" #import "DisplayManager.h"
#import "iOSCoreAudio.h" #import "iOSCoreAudio.h"
#import "IAPManager.h"
#import <GLKit/GLKit.h> #import <GLKit/GLKit.h>
#import "Controls.h"
#import <QuartzCore/QuartzCore.h> #import <QuartzCore/QuartzCore.h>
#include <cassert> #include <cassert>
@@ -97,8 +95,6 @@ static std::thread g_renderLoopThread;
PPSSPPBaseViewController *sharedViewController; PPSSPPBaseViewController *sharedViewController;
@interface PPSSPPViewControllerGL () { @interface PPSSPPViewControllerGL () {
ICadeTracker g_iCadeTracker;
IOSGLESContext *graphicsContext; IOSGLESContext *graphicsContext;
int imageRequestId; int imageRequestId;
@@ -112,10 +108,6 @@ PPSSPPBaseViewController *sharedViewController;
@property (nonatomic, strong) EAGLContext* context; @property (nonatomic, strong) EAGLContext* context;
@property (nonatomic) GCController *gameController __attribute__((weak_import));
@property (strong, nonatomic) CMMotionManager *motionManager;
@property (strong, nonatomic) NSOperationQueue *accelerometerQueue;
@end @end
@implementation PPSSPPViewControllerGL {} @implementation PPSSPPViewControllerGL {}
@@ -124,27 +116,10 @@ PPSSPPBaseViewController *sharedViewController;
self = [super init]; self = [super init];
if (self) { if (self) {
_preferredFramesPerSecond = 60; // default _preferredFramesPerSecond = 60; // default
sharedViewController = self;
g_iCadeTracker.InitKeyMap();
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(appWillTerminate:) name:UIApplicationWillTerminateNotification object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(controllerDidConnect:) name:GCControllerDidConnectNotification object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(controllerDidDisconnect:) name:GCControllerDidDisconnectNotification object:nil];
} }
self.accelerometerQueue = [[NSOperationQueue alloc] init];
self.accelerometerQueue.name = @"AccelerometerQueue";
self.accelerometerQueue.maxConcurrentOperationCount = 1;
return self; return self;
} }
- (BOOL)prefersHomeIndicatorAutoHidden {
if (g_Config.iAppSwitchMode == (int)AppSwitchMode::DOUBLE_SWIPE_INDICATOR) {
return NO;
} else {
return YES;
}
}
// The actual rendering is NOT on this thread, this is the emu thread // The actual rendering is NOT on this thread, this is the emu thread
// that runs game logic. // that runs game logic.
void GLRenderLoop(IOSGLESContext *graphicsContext) { void GLRenderLoop(IOSGLESContext *graphicsContext) {
@@ -264,19 +239,12 @@ void GLRenderLoop(IOSGLESContext *graphicsContext) {
[self hideKeyboard]; [self hideKeyboard];
// Initialize the motion manager for accelerometer control. // Initialize the motion manager for accelerometer control.
self.motionManager = [[CMMotionManager alloc] init];
INFO_LOG(Log::G3D, "Done with viewDidLoad."); INFO_LOG(Log::G3D, "Done with viewDidLoad.");
} }
- (void)viewDidLayoutSubviews { - (void)viewDidLayoutSubviews {
[super viewDidLayoutSubviews]; [super viewDidLayoutSubviews];
self.glView.frame = self.view.bounds; self.glView.frame = self.view.bounds;
/*
// if you need to update viewport:
CGSize s = self.glView.bounds.size;
[EAGLContext setCurrentContext:self.glContext];
glViewport(0, 0, (GLsizei)round(s.width), (GLsizei)round(s.height));
*/
} }
- (void)viewWillAppear:(BOOL)animated { - (void)viewWillAppear:(BOOL)animated {
@@ -340,39 +308,11 @@ void GLRenderLoop(IOSGLESContext *graphicsContext) {
} }
} }
- (void)handleSwipeFrom:(UIScreenEdgePanGestureRecognizer *)recognizer {
if (recognizer.state == UIGestureRecognizerStateEnded) {
KeyInput key;
key.flags = KEY_DOWN | KEY_UP;
key.keyCode = NKCODE_BACK;
key.deviceId = DEVICE_ID_TOUCH;
NativeKey(key);
INFO_LOG(Log::System, "Detected back swipe");
}
}
- (void)appWillTerminate:(NSNotification *)notification
{
[self shutdown];
}
- (void)didBecomeActive { - (void)didBecomeActive {
INFO_LOG(Log::System, "didBecomeActive begin"); [super didBecomeActive];
if (self.motionManager.accelerometerAvailable) {
self.motionManager.accelerometerUpdateInterval = 1.0 / 60.0; INFO_LOG(Log::System, "didBecomeActive begin");
INFO_LOG(Log::G3D, "Starting accelerometer updates.");
[self.motionManager startAccelerometerUpdatesToQueue:self.accelerometerQueue
withHandler:^(CMAccelerometerData *accelerometerData, NSError *error) {
if (error) {
NSLog(@"Accelerometer error: %@", error);
return;
}
ProcessAccelerometerData(accelerometerData);
}];
} else {
INFO_LOG(Log::G3D, "No accelerometer available, not starting updates.");
}
[self runGLRenderLoop]; [self runGLRenderLoop];
[[DisplayManager shared] updateResolution:[UIScreen mainScreen]]; [[DisplayManager shared] updateResolution:[UIScreen mainScreen]];
@@ -382,29 +322,26 @@ void GLRenderLoop(IOSGLESContext *graphicsContext) {
} }
- (void)willResignActive { - (void)willResignActive {
INFO_LOG(Log::System, "willResignActive begin"); INFO_LOG(Log::System, "willResignActive GL");
[self requestExitGLRenderLoop]; [self requestExitGLRenderLoop];
// Stop accelerometer updates
if (self.motionManager.accelerometerActive) {
INFO_LOG(Log::G3D, "Stopping accelerometer updates");
[self.motionManager stopAccelerometerUpdates];
}
INFO_LOG(Log::System, "willResignActive end");
self.displayLink.paused = YES; self.displayLink.paused = YES;
[super willResignActive];
} }
- (void)shutdown - (void)shutdown {
{ [super shutdown];
INFO_LOG(Log::System, "shutdown GL"); INFO_LOG(Log::System, "shutdown GL");
g_Config.Save("shutdown GL"); g_Config.Save("shutdown GL");
_dbg_assert_(graphicsContext);
_dbg_assert_(sharedViewController != nil); _dbg_assert_(sharedViewController != nil);
sharedViewController = nil; sharedViewController = nil;
_dbg_assert_(graphicsContext);
if (self.context) { if (self.context) {
if ([EAGLContext currentContext] == self.context) { if ([EAGLContext currentContext] == self.context) {
[EAGLContext setCurrentContext:nil]; [EAGLContext setCurrentContext:nil];
@@ -414,8 +351,6 @@ void GLRenderLoop(IOSGLESContext *graphicsContext) {
[[NSNotificationCenter defaultCenter] removeObserver:self]; [[NSNotificationCenter defaultCenter] removeObserver:self];
self.gameController = nil;
graphicsContext->BeginShutdown(); graphicsContext->BeginShutdown();
// Skipping GL calls here because the old context is lost. // Skipping GL calls here because the old context is lost.
graphicsContext->ThreadFrameUntilCondition([]() -> bool { graphicsContext->ThreadFrameUntilCondition([]() -> bool {
@@ -429,75 +364,16 @@ void GLRenderLoop(IOSGLESContext *graphicsContext) {
INFO_LOG(Log::System, "Done shutting down GL"); INFO_LOG(Log::System, "Done shutting down GL");
} }
- (UIInterfaceOrientationMask)supportedInterfaceOrientations
{
return UIInterfaceOrientationMaskAll;
}
- (void)bindDefaultFBO - (void)bindDefaultFBO
{ {
[(GLKView*)self.glView bindDrawable]; [(GLKView*)self.glView bindDrawable];
} }
- (void)buttonDown:(iCadeState)button
{
g_iCadeTracker.ButtonDown(button);
}
- (void)buttonUp:(iCadeState)button
{
g_iCadeTracker.ButtonUp(button);
}
- (void)controllerDidConnect:(NSNotification *)note
{
if (![[GCController controllers] containsObject:self.gameController]) self.gameController = nil;
if (self.gameController != nil) return; // already have a connected controller
[self setupController:(GCController *)note.object];
}
- (void)controllerDidDisconnect:(NSNotification *)note
{
if (self.gameController == note.object) {
self.gameController = nil;
if ([[GCController controllers] count] > 0) {
[self setupController:[[GCController controllers] firstObject]];
}
}
}
- (UIView *)getView { - (UIView *)getView {
return [self view]; return [self view];
} }
- (void)setupController:(GCController *)controller // Can't consolidate this yet.
{
self.gameController = controller;
if (!InitController(controller)) {
self.gameController = nil;
}
}
// See PPSSPPUIApplication.mm for the other method
#if PPSSPP_PLATFORM(IOS_APP_STORE)
- (void)pressesBegan:(NSSet<UIPress *> *)presses withEvent:(UIPressesEvent *)event {
KeyboardPressesBegan(presses, event);
}
- (void)pressesEnded:(NSSet<UIPress *> *)presses withEvent:(UIPressesEvent *)event {
KeyboardPressesEnded(presses, event);
}
- (void)pressesCancelled:(NSSet<UIPress *> *)presses withEvent:(UIPressesEvent *)event {
KeyboardPressesEnded(presses, event);
}
#endif
- (void)viewWillTransitionToSize:(CGSize)size - (void)viewWillTransitionToSize:(CGSize)size
withTransitionCoordinator:(id<UIViewControllerTransitionCoordinator>)coordinator { withTransitionCoordinator:(id<UIViewControllerTransitionCoordinator>)coordinator {
[super viewWillTransitionToSize:size withTransitionCoordinator:coordinator]; [super viewWillTransitionToSize:size withTransitionCoordinator:coordinator];
+5 -1
View File
@@ -2,13 +2,16 @@
#import <UIKit/UIKit.h> #import <UIKit/UIKit.h>
#import <GameController/GameController.h>
#import "CameraHelper.h" #import "CameraHelper.h"
#import "LocationHelper.h" #import "LocationHelper.h"
#import "iCade/iCadeReaderView.h"
@interface PPSSPPBaseViewController : UIViewController< @interface PPSSPPBaseViewController : UIViewController<
UIImagePickerControllerDelegate, UINavigationControllerDelegate, UIImagePickerControllerDelegate, UINavigationControllerDelegate,
CameraFrameDelegate, LocationHandlerDelegate, UIKeyInput, CameraFrameDelegate, LocationHandlerDelegate, UIKeyInput,
UIGestureRecognizerDelegate> UIGestureRecognizerDelegate, iCadeEventDelegate>
- (void)hideKeyboard; - (void)hideKeyboard;
- (void)showKeyboard; - (void)showKeyboard;
@@ -21,6 +24,7 @@
- (void)startVideo:(int)width height:(int)height; - (void)startVideo:(int)width height:(int)height;
- (void)stopVideo; - (void)stopVideo;
- (void)appSwitchModeChanged; - (void)appSwitchModeChanged;
- (void)setupController:(GCController *)controller;
// Forwarded from the AppDelegate // Forwarded from the AppDelegate
- (void)didBecomeActive; - (void)didBecomeActive;
+125
View File
@@ -16,15 +16,84 @@
NSString *imageFilename; NSString *imageFilename;
CameraHelper *cameraHelper; CameraHelper *cameraHelper;
LocationHelper *locationHelper; LocationHelper *locationHelper;
ICadeTracker g_iCadeTracker;
TouchTracker g_touchTracker; TouchTracker g_touchTracker;
} }
@property (strong, nonatomic) NSOperationQueue *accelerometerQueue;
@property (nonatomic) GCController *gameController __attribute__((weak_import));
@property (strong, nonatomic) CMMotionManager *motionManager;
@end @end
@implementation PPSSPPBaseViewController { @implementation PPSSPPBaseViewController {
UIScreenEdgePanGestureRecognizer *mBackGestureRecognizer; UIScreenEdgePanGestureRecognizer *mBackGestureRecognizer;
} }
- (id)init {
self = [super init];
if (self) {
sharedViewController = self;
g_iCadeTracker.InitKeyMap();
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(appWillTerminate:) name:UIApplicationWillTerminateNotification object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(controllerDidConnect:) name:GCControllerDidConnectNotification object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(controllerDidDisconnect:) name:GCControllerDidDisconnectNotification object:nil];
}
self.accelerometerQueue = [[NSOperationQueue alloc] init];
self.accelerometerQueue.name = @"AccelerometerQueue";
self.accelerometerQueue.maxConcurrentOperationCount = 1;
return self;
}
- (void)shutdown {
self.gameController = nil;
[[NSNotificationCenter defaultCenter] removeObserver:self];
_dbg_assert_(sharedViewController != nil);
sharedViewController = nil;
}
- (BOOL)prefersHomeIndicatorAutoHidden {
if (g_Config.iAppSwitchMode == (int)AppSwitchMode::DOUBLE_SWIPE_INDICATOR) {
return NO;
} else {
return YES;
}
}
- (void)didBecomeActive {
if (self.motionManager.accelerometerAvailable) {
self.motionManager.accelerometerUpdateInterval = 1.0 / 60.0;
INFO_LOG(Log::G3D, "Starting accelerometer updates.");
[self.motionManager startAccelerometerUpdatesToQueue:self.accelerometerQueue
withHandler:^(CMAccelerometerData *accelerometerData, NSError *error) {
if (error) {
NSLog(@"Accelerometer error: %@", error);
return;
}
ProcessAccelerometerData(accelerometerData);
}];
} else {
INFO_LOG(Log::G3D, "No accelerometer available, not starting updates.");
}
}
- (void)willResignActive {
// Stop accelerometer updates
if (self.motionManager.accelerometerActive) {
INFO_LOG(Log::G3D, "Stopping accelerometer updates");
[self.motionManager stopAccelerometerUpdates];
}
}
- (void)appWillTerminate:(NSNotification *)notification {
[self shutdown];
}
- (void)viewDidAppear:(BOOL)animated { - (void)viewDidAppear:(BOOL)animated {
[super viewDidAppear:animated]; [super viewDidAppear:animated];
INFO_LOG(Log::G3D, "viewDidAppear"); INFO_LOG(Log::G3D, "viewDidAppear");
@@ -57,6 +126,33 @@
} }
} }
- (void)controllerDidConnect:(NSNotification *)note
{
if (![[GCController controllers] containsObject:self.gameController]) self.gameController = nil;
if (self.gameController != nil) return; // already have a connected controller
[self setupController:(GCController *)note.object];
}
- (void)controllerDidDisconnect:(NSNotification *)note
{
if (self.gameController == note.object) {
self.gameController = nil;
if ([[GCController controllers] count] > 0) {
[self setupController:[[GCController controllers] firstObject]];
}
}
}
- (void)setupController:(GCController *)controller {
self.gameController = controller;
if (!InitController(controller)) {
self.gameController = nil;
}
}
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event - (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{ {
g_touchTracker.Began(touches, self.view); g_touchTracker.Began(touches, self.view);
@@ -189,6 +285,8 @@
locationHelper = [[LocationHelper alloc] init]; locationHelper = [[LocationHelper alloc] init];
[locationHelper setDelegate:self]; [locationHelper setDelegate:self];
self.motionManager = [[CMMotionManager alloc] init];
} }
extern float g_safeInsetLeft; extern float g_safeInsetLeft;
@@ -271,4 +369,31 @@ static float BoostInset(float inset) {
return YES; return YES;
} }
- (void)buttonDown:(iCadeState)button
{
g_iCadeTracker.ButtonDown(button);
}
- (void)buttonUp:(iCadeState)button
{
g_iCadeTracker.ButtonUp(button);
}
// See PPSSPPUIApplication.mm for the other method
#if PPSSPP_PLATFORM(IOS_APP_STORE)
- (void)pressesBegan:(NSSet<UIPress *> *)presses withEvent:(UIPressesEvent *)event {
KeyboardPressesBegan(presses, event);
}
- (void)pressesEnded:(NSSet<UIPress *> *)presses withEvent:(UIPressesEvent *)event {
KeyboardPressesEnded(presses, event);
}
- (void)pressesCancelled:(NSSet<UIPress *> *)presses withEvent:(UIPressesEvent *)event {
KeyboardPressesEnded(presses, event);
}
#endif
@end @end
+1 -1
View File
@@ -6,7 +6,7 @@
#import "ViewControllerCommon.h" #import "ViewControllerCommon.h"
#import "iCade/iCadeReaderView.h" #import "iCade/iCadeReaderView.h"
@interface PPSSPPViewControllerMetal : PPSSPPBaseViewController<iCadeEventDelegate> @interface PPSSPPViewControllerMetal : PPSSPPBaseViewController
@end @end
/** The Metal-compatibile view. */ /** The Metal-compatibile view. */
+9 -123
View File
@@ -1,9 +1,7 @@
#import "AppDelegate.h" #import "AppDelegate.h"
#import "ViewControllerMetal.h" #import "ViewControllerMetal.h"
#import "DisplayManager.h" #import "DisplayManager.h"
#include "Controls.h"
#import "iOSCoreAudio.h" #import "iOSCoreAudio.h"
#import "IAPManager.h"
#include "Common/Log.h" #include "Common/Log.h"
@@ -178,41 +176,18 @@ static std::atomic<bool> renderLoopRunning;
static std::thread g_renderLoopThread; static std::thread g_renderLoopThread;
@interface PPSSPPViewControllerMetal () { @interface PPSSPPViewControllerMetal () {
ICadeTracker g_iCadeTracker;
IOSVulkanContext *graphicsContext; IOSVulkanContext *graphicsContext;
CameraHelper *cameraHelper;
} }
@property (nonatomic) GCController *gameController __attribute__((weak_import));
@property (strong, nonatomic) CMMotionManager *motionManager;
@property (strong, nonatomic) NSOperationQueue *accelerometerQueue;
@end // @interface @end // @interface
@implementation PPSSPPViewControllerMetal {} @implementation PPSSPPViewControllerMetal {}
- (id)init { - (id)init {
self = [super init]; self = [super init];
if (self) {
sharedViewController = self;
g_iCadeTracker.InitKeyMap();
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(appWillTerminate:) name:UIApplicationWillTerminateNotification object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(controllerDidConnect:) name:GCControllerDidConnectNotification object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(controllerDidDisconnect:) name:GCControllerDidDisconnectNotification object:nil];
}
self.accelerometerQueue = [[NSOperationQueue alloc] init];
self.accelerometerQueue.name = @"AccelerometerQueue";
self.accelerometerQueue.maxConcurrentOperationCount = 1;
return self; return self;
} }
- (void)appWillTerminate:(NSNotification *)notification
{
[self shutdown];
}
// Should be very similar to the Android one, probably mergeable. // Should be very similar to the Android one, probably mergeable.
// This is the EmuThread for iOS. // This is the EmuThread for iOS.
void VulkanRenderLoop(IOSVulkanContext *graphicsContext, CAMetalLayer *metalLayer) { void VulkanRenderLoop(IOSVulkanContext *graphicsContext, CAMetalLayer *metalLayer) {
@@ -315,22 +290,9 @@ void VulkanRenderLoop(IOSVulkanContext *graphicsContext, CAMetalLayer *metalLaye
// These two are forwarded from the appDelegate // These two are forwarded from the appDelegate
- (void)didBecomeActive { - (void)didBecomeActive {
INFO_LOG(Log::G3D, "didBecomeActive GL"); [super didBecomeActive];
if (self.motionManager.accelerometerAvailable) { INFO_LOG(Log::G3D, "didBecomeActive Metal");
self.motionManager.accelerometerUpdateInterval = 1.0 / 60.0;
INFO_LOG(Log::G3D, "Starting accelerometer updates.");
[self.motionManager startAccelerometerUpdatesToQueue:self.accelerometerQueue
withHandler:^(CMAccelerometerData *accelerometerData, NSError *error) {
if (error) {
NSLog(@"Accelerometer error: %@", error);
return;
}
ProcessAccelerometerData(accelerometerData);
}];
} else {
INFO_LOG(Log::G3D, "No accelerometer available, not starting updates.");
}
// Spin up the emu thread. It will in turn spin up the Vulkan render thread // Spin up the emu thread. It will in turn spin up the Vulkan render thread
// on its own. // on its own.
[self runVulkanRenderLoop]; [self runVulkanRenderLoop];
@@ -338,29 +300,19 @@ void VulkanRenderLoop(IOSVulkanContext *graphicsContext, CAMetalLayer *metalLaye
} }
- (void)willResignActive { - (void)willResignActive {
INFO_LOG(Log::G3D, "willResignActive GL"); INFO_LOG(Log::G3D, "willResignActive Metal");
[self requestExitVulkanRenderLoop]; [self requestExitVulkanRenderLoop];
// Stop accelerometer updates [super willResignActive];
if (self.motionManager.accelerometerActive) {
INFO_LOG(Log::G3D, "Stopping accelerometer updates");
[self.motionManager stopAccelerometerUpdates];
}
} }
- (void)shutdown - (void)shutdown {
{ [super shutdown];
INFO_LOG(Log::System, "shutdown VK");
INFO_LOG(Log::System, "shutdown");
g_Config.Save("shutdown vk"); g_Config.Save("shutdown vk");
_dbg_assert_(sharedViewController != nil);
sharedViewController = nil;
[[NSNotificationCenter defaultCenter] removeObserver:self];
self.gameController = nil;
if (graphicsContext) { if (graphicsContext) {
graphicsContext->Shutdown(); graphicsContext->Shutdown();
delete graphicsContext; delete graphicsContext;
@@ -408,9 +360,6 @@ void VulkanRenderLoop(IOSVulkanContext *graphicsContext, CAMetalLayer *metalLaye
} }
INFO_LOG(Log::G3D, "Detected size: %dx%d", g_display.pixel_xres, g_display.pixel_yres); INFO_LOG(Log::G3D, "Detected size: %dx%d", g_display.pixel_xres, g_display.pixel_yres);
// Initialize the motion manager for accelerometer control.
self.motionManager = [[CMMotionManager alloc] init];
} }
- (UIView *)getView { - (UIView *)getView {
@@ -433,74 +382,11 @@ void VulkanRenderLoop(IOSVulkanContext *graphicsContext, CAMetalLayer *metalLaye
INFO_LOG(Log::G3D, "viewWillDisappear"); INFO_LOG(Log::G3D, "viewWillDisappear");
} }
- (BOOL)prefersHomeIndicatorAutoHidden {
if (g_Config.iAppSwitchMode == (int)AppSwitchMode::DOUBLE_SWIPE_INDICATOR) {
return NO;
} else {
return YES;
}
}
- (void)bindDefaultFBO - (void)bindDefaultFBO
{ {
// Do nothing // Do nothing
} }
- (void)buttonDown:(iCadeState)button
{
g_iCadeTracker.ButtonDown(button);
}
- (void)buttonUp:(iCadeState)button
{
g_iCadeTracker.ButtonUp(button);
}
// See PPSSPPUIApplication.mm for the other method
#if PPSSPP_PLATFORM(IOS_APP_STORE)
- (void)pressesBegan:(NSSet<UIPress *> *)presses withEvent:(UIPressesEvent *)event {
KeyboardPressesBegan(presses, event);
}
- (void)pressesEnded:(NSSet<UIPress *> *)presses withEvent:(UIPressesEvent *)event {
KeyboardPressesEnded(presses, event);
}
- (void)pressesCancelled:(NSSet<UIPress *> *)presses withEvent:(UIPressesEvent *)event {
KeyboardPressesEnded(presses, event);
}
#endif
- (void)controllerDidConnect:(NSNotification *)note
{
if (![[GCController controllers] containsObject:self.gameController]) self.gameController = nil;
if (self.gameController != nil) return; // already have a connected controller
[self setupController:(GCController *)note.object];
}
- (void)controllerDidDisconnect:(NSNotification *)note
{
if (self.gameController == note.object) {
self.gameController = nil;
if ([[GCController controllers] count] > 0) {
[self setupController:[[GCController controllers] firstObject]];
}
}
}
- (void)setupController:(GCController *)controller
{
self.gameController = controller;
if (!InitController(controller)) {
self.gameController = nil;
}
}
- (void)viewWillTransitionToSize:(CGSize)size - (void)viewWillTransitionToSize:(CGSize)size
withTransitionCoordinator:(id<UIViewControllerTransitionCoordinator>)coordinator { withTransitionCoordinator:(id<UIViewControllerTransitionCoordinator>)coordinator {
[super viewWillTransitionToSize:size withTransitionCoordinator:coordinator]; [super viewWillTransitionToSize:size withTransitionCoordinator:coordinator];