2013-08-19 03:17:33 +00:00
|
|
|
// main.mm boilerplate
|
2013-02-17 14:04:44 +00:00
|
|
|
|
|
|
|
#import <UIKit/UIKit.h>
|
2013-08-19 03:17:33 +00:00
|
|
|
#import <string>
|
2014-02-12 09:26:53 +00:00
|
|
|
#import <stdio.h>
|
|
|
|
#import <stdlib.h>
|
2014-05-22 06:20:43 +00:00
|
|
|
#import <AudioToolbox/AudioToolbox.h>
|
2013-02-17 14:04:44 +00:00
|
|
|
|
|
|
|
#import "AppDelegate.h"
|
2014-05-17 05:55:31 +00:00
|
|
|
#import <AudioToolbox/AudioToolbox.h>
|
2013-02-17 14:04:44 +00:00
|
|
|
|
2013-09-06 08:12:48 +00:00
|
|
|
#include "base/NativeApp.h"
|
|
|
|
|
2015-11-03 18:57:10 +00:00
|
|
|
@interface UIApplication (Private)
|
|
|
|
-(void) suspend;
|
|
|
|
-(void) terminateWithSuccess;
|
|
|
|
@end
|
|
|
|
|
|
|
|
@interface UIApplication (SpringBoardAnimatedExit)
|
|
|
|
-(void) animatedExit;
|
|
|
|
@end
|
|
|
|
|
|
|
|
@implementation UIApplication (SpringBoardAnimatedExit)
|
|
|
|
-(void) animatedExit {
|
|
|
|
BOOL multitaskingSupported = NO;
|
|
|
|
if ([[UIDevice currentDevice] respondsToSelector:@selector(isMultitaskingSupported)]) {
|
|
|
|
multitaskingSupported = [UIDevice currentDevice].multitaskingSupported;
|
|
|
|
}
|
|
|
|
if ([self respondsToSelector:@selector(suspend)]) {
|
|
|
|
if (multitaskingSupported) {
|
|
|
|
[self beginBackgroundTaskWithExpirationHandler:^{}];
|
|
|
|
[self performSelector:@selector(exit) withObject:nil afterDelay:0.4];
|
|
|
|
}
|
|
|
|
[self suspend];
|
|
|
|
} else {
|
|
|
|
[self exit];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
-(void) exit {
|
|
|
|
if ([self respondsToSelector:@selector(terminateWithSuccess)]) {
|
|
|
|
[self terminateWithSuccess];
|
|
|
|
} else {
|
|
|
|
exit(0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
@end
|
|
|
|
|
2013-09-04 09:29:38 +00:00
|
|
|
std::string System_GetProperty(SystemProperty prop) {
|
|
|
|
switch (prop) {
|
|
|
|
case SYSPROP_NAME:
|
|
|
|
return "iOS:";
|
|
|
|
case SYSPROP_LANGREGION:
|
|
|
|
return "en_US";
|
|
|
|
default:
|
|
|
|
return "";
|
|
|
|
}
|
2013-08-19 03:17:33 +00:00
|
|
|
}
|
|
|
|
|
2015-01-11 18:30:25 +00:00
|
|
|
int System_GetPropertyInt(SystemProperty prop) {
|
2016-08-28 16:07:54 +00:00
|
|
|
switch (prop) {
|
|
|
|
case SYSPROP_AUDIO_SAMPLE_RATE:
|
|
|
|
return 44100;
|
|
|
|
case SYSPROP_DISPLAY_REFRESH_RATE:
|
|
|
|
return 60000;
|
|
|
|
case SYSPROP_DEVICE_TYPE:
|
|
|
|
return DEVICE_TYPE_MOBILE;
|
|
|
|
default:
|
|
|
|
return -1;
|
|
|
|
}
|
2015-01-11 18:30:25 +00:00
|
|
|
}
|
2014-07-20 10:11:50 +00:00
|
|
|
|
2013-12-04 16:41:59 +00:00
|
|
|
void System_SendMessage(const char *command, const char *parameter) {
|
2014-02-12 09:26:53 +00:00
|
|
|
if (!strcmp(command, "finish")) {
|
2015-11-03 18:57:10 +00:00
|
|
|
[[UIApplication sharedApplication] animatedExit];
|
2014-02-12 09:26:53 +00:00
|
|
|
}
|
2013-12-04 16:41:59 +00:00
|
|
|
}
|
|
|
|
|
2015-12-17 21:41:50 +00:00
|
|
|
void System_AskForPermission(SystemPermission permission) {}
|
|
|
|
PermissionStatus System_GetPermissionStatus(SystemPermission permission) { return PERMISSION_STATUS_GRANTED; }
|
|
|
|
|
2014-05-22 07:54:09 +00:00
|
|
|
FOUNDATION_EXTERN void AudioServicesPlaySystemSoundWithVibration(unsigned long, objc_object*, NSDictionary*);
|
|
|
|
|
2013-10-13 19:12:36 +00:00
|
|
|
void Vibrate(int length_ms) {
|
2014-05-22 07:56:33 +00:00
|
|
|
NSMutableDictionary *dictionary = [NSMutableDictionary dictionary];
|
|
|
|
NSArray *pattern = @[@YES, @30, @NO, @2];
|
|
|
|
|
|
|
|
dictionary[@"VibePattern"] = pattern;
|
|
|
|
dictionary[@"Intensity"] = @2;
|
|
|
|
|
|
|
|
AudioServicesPlaySystemSoundWithVibration(kSystemSoundID_Vibrate, nil, dictionary);
|
2014-05-22 07:54:09 +00:00
|
|
|
// TODO: Actually make use of length_ms if PPSSPP ever adds that in the config
|
2013-10-13 19:12:36 +00:00
|
|
|
}
|
|
|
|
|
2013-02-17 14:04:44 +00:00
|
|
|
int main(int argc, char *argv[])
|
|
|
|
{
|
2016-08-28 16:07:54 +00:00
|
|
|
// Simulates a debugger. Makes it possible to use JIT (though only W^X)
|
|
|
|
syscall(SYS_ptrace, 0 /*PTRACE_TRACEME*/, 0, 0, 0);
|
2013-02-17 14:04:44 +00:00
|
|
|
@autoreleasepool {
|
|
|
|
return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class]));
|
|
|
|
}
|
|
|
|
}
|