|
@@ -1,34 +1,42 @@
|
|
#include "ios_system.h"
|
|
#include "ios_system.h"
|
|
|
|
+#include <wchar.h>
|
|
#include <iron_gpu.h>
|
|
#include <iron_gpu.h>
|
|
#include <iron_system.h>
|
|
#include <iron_system.h>
|
|
-#import <Foundation/Foundation.h>
|
|
|
|
#include <iron_math.h>
|
|
#include <iron_math.h>
|
|
#include <objc/runtime.h>
|
|
#include <objc/runtime.h>
|
|
-#import <AVFAudio/AVFAudio.h>
|
|
|
|
-#include <wchar.h>
|
|
|
|
-#import <UIKit/UIKit.h>
|
|
|
|
-#include <iron_video.h>
|
|
|
|
-#import <AudioToolbox/AudioToolbox.h>
|
|
|
|
#include <mach/mach_time.h>
|
|
#include <mach/mach_time.h>
|
|
|
|
+#import <Foundation/Foundation.h>
|
|
|
|
+#import <UIKit/UIKit.h>
|
|
|
|
+
|
|
|
|
+#define touchmaxcount 20
|
|
|
|
|
|
-static const int touchmaxcount = 20;
|
|
|
|
|
|
+extern char mobile_title[1024];
|
|
static void *touches[touchmaxcount];
|
|
static void *touches[touchmaxcount];
|
|
|
|
+static int backing_width;
|
|
|
|
+static int backing_height;
|
|
|
|
+static bool shift_down = false;
|
|
|
|
+static bool visible;
|
|
|
|
+static MyView *myView;
|
|
|
|
+static MyViewController *myViewController;
|
|
|
|
+static bool keyboard_shown = false;
|
|
|
|
+static char language[3];
|
|
|
|
+static char sysid[512];
|
|
|
|
+static const char *video_formats[] = {"mp4", NULL};
|
|
|
|
+static void (*resize_callback)(int x, int y, void *data) = NULL;
|
|
|
|
+static void *resize_callback_data = NULL;
|
|
|
|
|
|
-static void initTouches(void) {
|
|
|
|
- for (int i = 0; i < touchmaxcount; ++i) {
|
|
|
|
- touches[i] = NULL;
|
|
|
|
- }
|
|
|
|
-}
|
|
|
|
|
|
+void iron_internal_call_resize_callback(int width, int height);
|
|
|
|
|
|
-static int getTouchIndex(void *touch) {
|
|
|
|
|
|
+static int get_touch_index(void *touch) {
|
|
for (int i = 0; i < touchmaxcount; ++i) {
|
|
for (int i = 0; i < touchmaxcount; ++i) {
|
|
- if (touches[i] == touch)
|
|
|
|
|
|
+ if (touches[i] == touch) {
|
|
return i;
|
|
return i;
|
|
|
|
+ }
|
|
}
|
|
}
|
|
return -1;
|
|
return -1;
|
|
}
|
|
}
|
|
|
|
|
|
-static int addTouch(void *touch) {
|
|
|
|
|
|
+static int add_touch(void *touch) {
|
|
for (int i = 0; i < touchmaxcount; ++i) {
|
|
for (int i = 0; i < touchmaxcount; ++i) {
|
|
if (touches[i] == NULL) {
|
|
if (touches[i] == NULL) {
|
|
touches[i] = touch;
|
|
touches[i] = touch;
|
|
@@ -38,7 +46,7 @@ static int addTouch(void *touch) {
|
|
return -1;
|
|
return -1;
|
|
}
|
|
}
|
|
|
|
|
|
-static int removeTouch(void *touch) {
|
|
|
|
|
|
+static int remove_touch(void *touch) {
|
|
for (int i = 0; i < touchmaxcount; ++i) {
|
|
for (int i = 0; i < touchmaxcount; ++i) {
|
|
if (touches[i] == touch) {
|
|
if (touches[i] == touch) {
|
|
touches[i] = NULL;
|
|
touches[i] = NULL;
|
|
@@ -48,17 +56,15 @@ static int removeTouch(void *touch) {
|
|
return -1;
|
|
return -1;
|
|
}
|
|
}
|
|
|
|
|
|
-static GLint backingWidth, backingHeight;
|
|
|
|
-
|
|
|
|
int iron_window_width() {
|
|
int iron_window_width() {
|
|
- return backingWidth;
|
|
|
|
|
|
+ return backing_width;
|
|
}
|
|
}
|
|
|
|
|
|
int iron_window_height() {
|
|
int iron_window_height() {
|
|
- return backingHeight;
|
|
|
|
|
|
+ return backing_height;
|
|
}
|
|
}
|
|
|
|
|
|
-@implementation GLView
|
|
|
|
|
|
+@implementation MyView
|
|
|
|
|
|
+ (Class)layerClass {
|
|
+ (Class)layerClass {
|
|
return [CAMetalLayer class];
|
|
return [CAMetalLayer class];
|
|
@@ -68,62 +74,52 @@ int iron_window_height() {
|
|
CGPoint point = [recognizer locationInView:self];
|
|
CGPoint point = [recognizer locationInView:self];
|
|
float x = point.x * self.contentScaleFactor;
|
|
float x = point.x * self.contentScaleFactor;
|
|
float y = point.y * self.contentScaleFactor;
|
|
float y = point.y * self.contentScaleFactor;
|
|
- // Pencil hover
|
|
|
|
- iron_internal_pen_trigger_move(x, y, 0.0);
|
|
|
|
|
|
+ iron_internal_pen_trigger_move(x, y, 0.0); // Pencil hover
|
|
}
|
|
}
|
|
|
|
|
|
- (id)initWithFrame:(CGRect)frame {
|
|
- (id)initWithFrame:(CGRect)frame {
|
|
self = [super initWithFrame:(CGRect)frame];
|
|
self = [super initWithFrame:(CGRect)frame];
|
|
self.contentScaleFactor = [UIScreen mainScreen].scale;
|
|
self.contentScaleFactor = [UIScreen mainScreen].scale;
|
|
|
|
+ backing_width = frame.size.width * self.contentScaleFactor;
|
|
|
|
+ backing_height = frame.size.height * self.contentScaleFactor;
|
|
|
|
|
|
- backingWidth = frame.size.width * self.contentScaleFactor;
|
|
|
|
- backingHeight = frame.size.height * self.contentScaleFactor;
|
|
|
|
-
|
|
|
|
- initTouches();
|
|
|
|
|
|
+ for (int i = 0; i < touchmaxcount; ++i) {
|
|
|
|
+ touches[i] = NULL;
|
|
|
|
+ }
|
|
|
|
|
|
device = MTLCreateSystemDefaultDevice();
|
|
device = MTLCreateSystemDefaultDevice();
|
|
commandQueue = [device newCommandQueue];
|
|
commandQueue = [device newCommandQueue];
|
|
library = [device newDefaultLibrary];
|
|
library = [device newDefaultLibrary];
|
|
|
|
|
|
CAMetalLayer *metalLayer = (CAMetalLayer *)self.layer;
|
|
CAMetalLayer *metalLayer = (CAMetalLayer *)self.layer;
|
|
-
|
|
|
|
metalLayer.device = device;
|
|
metalLayer.device = device;
|
|
metalLayer.pixelFormat = MTLPixelFormatBGRA8Unorm;
|
|
metalLayer.pixelFormat = MTLPixelFormatBGRA8Unorm;
|
|
metalLayer.framebufferOnly = YES;
|
|
metalLayer.framebufferOnly = YES;
|
|
- // metalLayer.presentsWithTransaction = YES;
|
|
|
|
-
|
|
|
|
metalLayer.opaque = YES;
|
|
metalLayer.opaque = YES;
|
|
metalLayer.backgroundColor = nil;
|
|
metalLayer.backgroundColor = nil;
|
|
|
|
|
|
[self addGestureRecognizer:[[UIHoverGestureRecognizer alloc] initWithTarget:self action:@selector(hoverGesture:)]];
|
|
[self addGestureRecognizer:[[UIHoverGestureRecognizer alloc] initWithTarget:self action:@selector(hoverGesture:)]];
|
|
-
|
|
|
|
return self;
|
|
return self;
|
|
}
|
|
}
|
|
|
|
|
|
-- (void)begin {
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
-- (void)end {
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
-void iron_internal_call_resize_callback(int width, int height);
|
|
|
|
|
|
+- (void)begin {}
|
|
|
|
+- (void)end {}
|
|
|
|
+- (void)dealloc {}
|
|
|
|
|
|
- (void)layoutSubviews {
|
|
- (void)layoutSubviews {
|
|
- backingWidth = self.frame.size.width * self.contentScaleFactor;
|
|
|
|
- backingHeight = self.frame.size.height * self.contentScaleFactor;
|
|
|
|
|
|
+ backing_width = self.frame.size.width * self.contentScaleFactor;
|
|
|
|
+ backing_height = self.frame.size.height * self.contentScaleFactor;
|
|
|
|
|
|
- gpu_resize();
|
|
|
|
- iron_internal_call_resize_callback(backingWidth, backingHeight);
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
-- (void)dealloc {
|
|
|
|
|
|
+ gpu_resize(backing_width, backing_height);
|
|
|
|
+ iron_internal_call_resize_callback(backing_width, backing_height);
|
|
}
|
|
}
|
|
|
|
|
|
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
|
|
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
|
|
for (UITouch *touch in touches) {
|
|
for (UITouch *touch in touches) {
|
|
- int index = getTouchIndex((__bridge void *)touch);
|
|
|
|
- if (index == -1)
|
|
|
|
- index = addTouch((__bridge void *)touch);
|
|
|
|
|
|
+ int index = get_touch_index((__bridge void *)touch);
|
|
|
|
+ if (index == -1) {
|
|
|
|
+ index = add_touch((__bridge void *)touch);
|
|
|
|
+ }
|
|
if (index >= 0) {
|
|
if (index >= 0) {
|
|
CGPoint point = [touch locationInView:self];
|
|
CGPoint point = [touch locationInView:self];
|
|
float x = point.x * self.contentScaleFactor;
|
|
float x = point.x * self.contentScaleFactor;
|
|
@@ -132,7 +128,6 @@ void iron_internal_call_resize_callback(int width, int height);
|
|
iron_internal_mouse_trigger_press(event.buttonMask == UIEventButtonMaskSecondary ? 1 : 0, x, y);
|
|
iron_internal_mouse_trigger_press(event.buttonMask == UIEventButtonMaskSecondary ? 1 : 0, x, y);
|
|
}
|
|
}
|
|
iron_internal_surface_trigger_touch_start(index, x, y);
|
|
iron_internal_surface_trigger_touch_start(index, x, y);
|
|
-
|
|
|
|
if (touch.type == UITouchTypePencil) {
|
|
if (touch.type == UITouchTypePencil) {
|
|
iron_internal_pen_trigger_press(x, y, 0.0);
|
|
iron_internal_pen_trigger_press(x, y, 0.0);
|
|
}
|
|
}
|
|
@@ -142,7 +137,7 @@ void iron_internal_call_resize_callback(int width, int height);
|
|
|
|
|
|
- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event {
|
|
- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event {
|
|
for (UITouch *touch in touches) {
|
|
for (UITouch *touch in touches) {
|
|
- int index = getTouchIndex((__bridge void *)touch);
|
|
|
|
|
|
+ int index = get_touch_index((__bridge void *)touch);
|
|
if (index >= 0) {
|
|
if (index >= 0) {
|
|
CGPoint point = [touch locationInView:self];
|
|
CGPoint point = [touch locationInView:self];
|
|
float x = point.x * self.contentScaleFactor;
|
|
float x = point.x * self.contentScaleFactor;
|
|
@@ -168,7 +163,7 @@ void iron_internal_call_resize_callback(int width, int height);
|
|
|
|
|
|
- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event {
|
|
- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event {
|
|
for (UITouch *touch in touches) {
|
|
for (UITouch *touch in touches) {
|
|
- int index = removeTouch((__bridge void *)touch);
|
|
|
|
|
|
+ int index = remove_touch((__bridge void *)touch);
|
|
if (index >= 0) {
|
|
if (index >= 0) {
|
|
CGPoint point = [touch locationInView:self];
|
|
CGPoint point = [touch locationInView:self];
|
|
float x = point.x * self.contentScaleFactor;
|
|
float x = point.x * self.contentScaleFactor;
|
|
@@ -177,7 +172,6 @@ void iron_internal_call_resize_callback(int width, int height);
|
|
iron_internal_mouse_trigger_release(event.buttonMask == UIEventButtonMaskSecondary ? 1 : 0, x, y);
|
|
iron_internal_mouse_trigger_release(event.buttonMask == UIEventButtonMaskSecondary ? 1 : 0, x, y);
|
|
}
|
|
}
|
|
iron_internal_surface_trigger_touch_end(index, x, y);
|
|
iron_internal_surface_trigger_touch_end(index, x, y);
|
|
-
|
|
|
|
if (touch.type == UITouchTypePencil) {
|
|
if (touch.type == UITouchTypePencil) {
|
|
iron_internal_pen_trigger_release(x, y, 0.0);
|
|
iron_internal_pen_trigger_release(x, y, 0.0);
|
|
}
|
|
}
|
|
@@ -187,7 +181,7 @@ void iron_internal_call_resize_callback(int width, int height);
|
|
|
|
|
|
- (void)touchesCancelled:(NSSet *)touches withEvent:(UIEvent *)event {
|
|
- (void)touchesCancelled:(NSSet *)touches withEvent:(UIEvent *)event {
|
|
for (UITouch *touch in touches) {
|
|
for (UITouch *touch in touches) {
|
|
- int index = removeTouch((__bridge void *)touch);
|
|
|
|
|
|
+ int index = remove_touch((__bridge void *)touch);
|
|
if (index >= 0) {
|
|
if (index >= 0) {
|
|
CGPoint point = [touch locationInView:self];
|
|
CGPoint point = [touch locationInView:self];
|
|
float x = point.x * self.contentScaleFactor;
|
|
float x = point.x * self.contentScaleFactor;
|
|
@@ -196,7 +190,6 @@ void iron_internal_call_resize_callback(int width, int height);
|
|
iron_internal_mouse_trigger_release(event.buttonMask == UIEventButtonMaskSecondary ? 1 : 0, x, y);
|
|
iron_internal_mouse_trigger_release(event.buttonMask == UIEventButtonMaskSecondary ? 1 : 0, x, y);
|
|
}
|
|
}
|
|
iron_internal_surface_trigger_touch_end(index, x, y);
|
|
iron_internal_surface_trigger_touch_end(index, x, y);
|
|
-
|
|
|
|
if (touch.type == UITouchTypePencil) {
|
|
if (touch.type == UITouchTypePencil) {
|
|
iron_internal_pen_trigger_release(x, y, 0.0);
|
|
iron_internal_pen_trigger_release(x, y, 0.0);
|
|
}
|
|
}
|
|
@@ -204,10 +197,6 @@ void iron_internal_call_resize_callback(int width, int height);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
-static NSString *keyboardstring;
|
|
|
|
-static UITextField *myTextField = NULL;
|
|
|
|
-static bool shiftDown = false;
|
|
|
|
-
|
|
|
|
- (void)showKeyboard {
|
|
- (void)showKeyboard {
|
|
[self becomeFirstResponder];
|
|
[self becomeFirstResponder];
|
|
}
|
|
}
|
|
@@ -223,14 +212,14 @@ static bool shiftDown = false;
|
|
- (void)insertText:(NSString *)text {
|
|
- (void)insertText:(NSString *)text {
|
|
if ([text length] == 1) {
|
|
if ([text length] == 1) {
|
|
unichar ch = [text characterAtIndex:[text length] - 1];
|
|
unichar ch = [text characterAtIndex:[text length] - 1];
|
|
- if (ch == 8212)
|
|
|
|
|
|
+ if (ch == 8212) {
|
|
ch = '_';
|
|
ch = '_';
|
|
|
|
+ }
|
|
if (ch == L'\n') {
|
|
if (ch == L'\n') {
|
|
iron_internal_keyboard_trigger_key_down(IRON_KEY_RETURN);
|
|
iron_internal_keyboard_trigger_key_down(IRON_KEY_RETURN);
|
|
iron_internal_keyboard_trigger_key_up(IRON_KEY_RETURN);
|
|
iron_internal_keyboard_trigger_key_up(IRON_KEY_RETURN);
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
-
|
|
|
|
if (ch == L'.') {
|
|
if (ch == L'.') {
|
|
iron_internal_keyboard_trigger_key_down(IRON_KEY_PERIOD);
|
|
iron_internal_keyboard_trigger_key_down(IRON_KEY_PERIOD);
|
|
iron_internal_keyboard_trigger_key_up(IRON_KEY_PERIOD);
|
|
iron_internal_keyboard_trigger_key_up(IRON_KEY_PERIOD);
|
|
@@ -256,22 +245,21 @@ static bool shiftDown = false;
|
|
iron_internal_keyboard_trigger_key_up(IRON_KEY_HASH);
|
|
iron_internal_keyboard_trigger_key_up(IRON_KEY_HASH);
|
|
}
|
|
}
|
|
else if (ch >= L'a' && ch <= L'z') {
|
|
else if (ch >= L'a' && ch <= L'z') {
|
|
- if (shiftDown) {
|
|
|
|
|
|
+ if (shift_down) {
|
|
iron_internal_keyboard_trigger_key_up(IRON_KEY_SHIFT);
|
|
iron_internal_keyboard_trigger_key_up(IRON_KEY_SHIFT);
|
|
- shiftDown = false;
|
|
|
|
|
|
+ shift_down = false;
|
|
}
|
|
}
|
|
iron_internal_keyboard_trigger_key_down(ch + IRON_KEY_A - L'a');
|
|
iron_internal_keyboard_trigger_key_down(ch + IRON_KEY_A - L'a');
|
|
iron_internal_keyboard_trigger_key_up(ch + IRON_KEY_A - L'a');
|
|
iron_internal_keyboard_trigger_key_up(ch + IRON_KEY_A - L'a');
|
|
}
|
|
}
|
|
else {
|
|
else {
|
|
- if (!shiftDown) {
|
|
|
|
|
|
+ if (!shift_down) {
|
|
iron_internal_keyboard_trigger_key_down(IRON_KEY_SHIFT);
|
|
iron_internal_keyboard_trigger_key_down(IRON_KEY_SHIFT);
|
|
- shiftDown = true;
|
|
|
|
|
|
+ shift_down = true;
|
|
}
|
|
}
|
|
iron_internal_keyboard_trigger_key_down(ch + IRON_KEY_A - L'A');
|
|
iron_internal_keyboard_trigger_key_down(ch + IRON_KEY_A - L'A');
|
|
iron_internal_keyboard_trigger_key_up(ch + IRON_KEY_A - L'A');
|
|
iron_internal_keyboard_trigger_key_up(ch + IRON_KEY_A - L'A');
|
|
}
|
|
}
|
|
-
|
|
|
|
iron_internal_keyboard_trigger_key_press(ch);
|
|
iron_internal_keyboard_trigger_key_press(ch);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -303,49 +291,31 @@ static bool shiftDown = false;
|
|
|
|
|
|
@end
|
|
@end
|
|
|
|
|
|
-static GLView *glView;
|
|
|
|
-static bool visible;
|
|
|
|
-
|
|
|
|
-void beginGL(void) {
|
|
|
|
- if (!visible) {
|
|
|
|
- return;
|
|
|
|
- }
|
|
|
|
- [glView begin];
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
-void endGL(void) {
|
|
|
|
- if (!visible) {
|
|
|
|
- return;
|
|
|
|
- }
|
|
|
|
- [glView end];
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
void showKeyboard(void) {
|
|
void showKeyboard(void) {
|
|
- [glView showKeyboard];
|
|
|
|
|
|
+ [myView showKeyboard];
|
|
}
|
|
}
|
|
|
|
|
|
void hideKeyboard(void) {
|
|
void hideKeyboard(void) {
|
|
- [glView hideKeyboard];
|
|
|
|
|
|
+ [myView hideKeyboard];
|
|
}
|
|
}
|
|
|
|
|
|
CAMetalLayer *getMetalLayer(void) {
|
|
CAMetalLayer *getMetalLayer(void) {
|
|
- return [glView metalLayer];
|
|
|
|
|
|
+ return [myView metalLayer];
|
|
}
|
|
}
|
|
|
|
|
|
id getMetalDevice(void) {
|
|
id getMetalDevice(void) {
|
|
- return [glView metalDevice];
|
|
|
|
|
|
+ return [myView metalDevice];
|
|
}
|
|
}
|
|
|
|
|
|
id getMetalQueue(void) {
|
|
id getMetalQueue(void) {
|
|
- return [glView metalQueue];
|
|
|
|
|
|
+ return [myView metalQueue];
|
|
}
|
|
}
|
|
|
|
|
|
-@implementation GLViewController
|
|
|
|
|
|
+@implementation MyViewController
|
|
|
|
|
|
- (void)loadView {
|
|
- (void)loadView {
|
|
visible = true;
|
|
visible = true;
|
|
- self.view = glView = [[GLView alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
|
|
|
|
-
|
|
|
|
|
|
+ self.view = myView = [[MyView alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
|
|
[self.view addInteraction: [[UIDropInteraction alloc] initWithDelegate: self]];
|
|
[self.view addInteraction: [[UIDropInteraction alloc] initWithDelegate: self]];
|
|
[self setNeedsUpdateOfScreenEdgesDeferringSystemGestures];
|
|
[self setNeedsUpdateOfScreenEdgesDeferringSystemGestures];
|
|
}
|
|
}
|
|
@@ -354,10 +324,6 @@ id getMetalQueue(void) {
|
|
visible = value;
|
|
visible = value;
|
|
}
|
|
}
|
|
|
|
|
|
-#include <iron_system.h>
|
|
|
|
-
|
|
|
|
-extern char mobile_title[1024];
|
|
|
|
-
|
|
|
|
void importFile(NSURL *url) {
|
|
void importFile(NSURL *url) {
|
|
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
|
|
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
|
|
NSString *folderName = [NSString stringWithUTF8String:mobile_title];
|
|
NSString *folderName = [NSString stringWithUTF8String:mobile_title];
|
|
@@ -386,11 +352,10 @@ void importFile(NSURL *url) {
|
|
|
|
|
|
- (void)dropInteraction:(UIDropInteraction *)interaction performDrop:(id<UIDropSession>)session {
|
|
- (void)dropInteraction:(UIDropInteraction *)interaction performDrop:(id<UIDropSession>)session {
|
|
CGPoint point = [session locationInView:self.view];
|
|
CGPoint point = [session locationInView:self.view];
|
|
- float x = point.x * glView.contentScaleFactor;
|
|
|
|
- float y = point.y * glView.contentScaleFactor;
|
|
|
|
|
|
+ float x = point.x * myView.contentScaleFactor;
|
|
|
|
+ float y = point.y * myView.contentScaleFactor;
|
|
iron_internal_mouse_trigger_move(x, y);
|
|
iron_internal_mouse_trigger_move(x, y);
|
|
iron_internal_surface_trigger_move(0, x, y);
|
|
iron_internal_surface_trigger_move(0, x, y);
|
|
-
|
|
|
|
for (UIDragItem *item in session.items) {
|
|
for (UIDragItem *item in session.items) {
|
|
[item.itemProvider loadInPlaceFileRepresentationForTypeIdentifier:item.itemProvider.registeredTypeIdentifiers[0] completionHandler:^(NSURL * _Nullable url, BOOL isInPlace, NSError * _Nullable error) {
|
|
[item.itemProvider loadInPlaceFileRepresentationForTypeIdentifier:item.itemProvider.registeredTypeIdentifiers[0] completionHandler:^(NSURL * _Nullable url, BOOL isInPlace, NSError * _Nullable error) {
|
|
importFile(url);
|
|
importFile(url);
|
|
@@ -402,17 +367,13 @@ void importFile(NSURL *url) {
|
|
return [[UIDropProposal alloc] initWithDropOperation: UIDropOperationCopy];
|
|
return [[UIDropProposal alloc] initWithDropOperation: UIDropOperationCopy];
|
|
}
|
|
}
|
|
|
|
|
|
-- (UIRectEdge)preferredScreenEdgesDeferringSystemGestures
|
|
|
|
-{
|
|
|
|
|
|
+- (UIRectEdge)preferredScreenEdgesDeferringSystemGestures {
|
|
return UIRectEdgeAll;
|
|
return UIRectEdgeAll;
|
|
}
|
|
}
|
|
|
|
|
|
@end
|
|
@end
|
|
|
|
|
|
-@implementation IronAppDelegate
|
|
|
|
-
|
|
|
|
-static UIWindow *window;
|
|
|
|
-static GLViewController *glViewController;
|
|
|
|
|
|
+@implementation IronSceneDelegate
|
|
|
|
|
|
void loadURL(const char *url) {
|
|
void loadURL(const char *url) {
|
|
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:[NSString stringWithUTF8String:url]]];
|
|
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:[NSString stringWithUTF8String:url]]];
|
|
@@ -424,52 +385,51 @@ void loadURL(const char *url) {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
-- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
|
|
|
|
|
|
+- (void)scene:(UIScene *)scene willConnectToSession:(UISceneSession *)session options:(UISceneConnectionOptions *)connectionOptions {
|
|
|
|
+ #ifdef IRON_A2
|
|
AVAudioSession *sessionInstance = [AVAudioSession sharedInstance];
|
|
AVAudioSession *sessionInstance = [AVAudioSession sharedInstance];
|
|
NSError *error;
|
|
NSError *error;
|
|
-
|
|
|
|
- // set the session category
|
|
|
|
NSString *category = AVAudioSessionCategoryAmbient;
|
|
NSString *category = AVAudioSessionCategoryAmbient;
|
|
- bool success = [sessionInstance setCategory:category error:&error];
|
|
|
|
- if (!success)
|
|
|
|
- NSLog(@"Error setting AVAudioSession category! %@\n", [error localizedDescription]);
|
|
|
|
-
|
|
|
|
- window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
|
|
|
|
- [window setBackgroundColor:[UIColor blackColor]];
|
|
|
|
-
|
|
|
|
- glViewController = [[GLViewController alloc] init];
|
|
|
|
- glViewController.view.multipleTouchEnabled = YES;
|
|
|
|
-
|
|
|
|
- [window setRootViewController:glViewController];
|
|
|
|
- [window makeKeyAndVisible];
|
|
|
|
-
|
|
|
|
|
|
+ [sessionInstance setCategory:category error:&error];
|
|
|
|
+ #endif
|
|
|
|
+
|
|
|
|
+ UIWindowScene *windowScene = (UIWindowScene *)scene;
|
|
|
|
+ self.window = [[UIWindow alloc] initWithWindowScene:windowScene];
|
|
|
|
+ // self.window.frame = windowScene.coordinateSpace.bounds;
|
|
|
|
+ self.window.frame = [UIScreen mainScreen].bounds;
|
|
|
|
+ [self.window setBackgroundColor:[UIColor blackColor]];
|
|
|
|
+
|
|
|
|
+ myViewController = [[MyViewController alloc] init];
|
|
|
|
+ myViewController.view.multipleTouchEnabled = YES;
|
|
|
|
+ [self.window setRootViewController:myViewController];
|
|
|
|
+ [self.window makeKeyAndVisible];
|
|
|
|
+
|
|
|
|
+ [myViewController setVisible:YES];
|
|
|
|
+ // iron_internal_foreground_callback();
|
|
[self performSelectorOnMainThread:@selector(mainLoop) withObject:nil waitUntilDone:NO];
|
|
[self performSelectorOnMainThread:@selector(mainLoop) withObject:nil waitUntilDone:NO];
|
|
-
|
|
|
|
- return YES;
|
|
|
|
}
|
|
}
|
|
|
|
|
|
-void IronUpdateKeyboard(void);
|
|
|
|
-
|
|
|
|
-- (void)applicationWillEnterForeground:(UIApplication *)application {
|
|
|
|
- [glViewController setVisible:YES];
|
|
|
|
- iron_internal_foreground_callback();
|
|
|
|
|
|
+- (void)sceneDidDisconnect:(UIScene *)scene {
|
|
|
|
+ [myViewController setVisible:NO];
|
|
|
|
+ iron_internal_shutdown_callback();
|
|
}
|
|
}
|
|
|
|
|
|
-- (void)applicationDidBecomeActive:(UIApplication *)application {
|
|
|
|
- iron_internal_resume_callback();
|
|
|
|
|
|
+- (void)sceneDidBecomeActive:(UIScene *)scene {
|
|
|
|
+ iron_internal_resume_callback();
|
|
}
|
|
}
|
|
|
|
|
|
-- (void)applicationWillResignActive:(UIApplication *)application {
|
|
|
|
- iron_internal_pause_callback();
|
|
|
|
|
|
+- (void)sceneWillResignActive:(UIScene *)scene {
|
|
|
|
+ iron_internal_pause_callback();
|
|
}
|
|
}
|
|
|
|
|
|
-- (void)applicationDidEnterBackground:(UIApplication *)application {
|
|
|
|
- [glViewController setVisible:NO];
|
|
|
|
- iron_internal_background_callback();
|
|
|
|
|
|
+- (void)sceneWillEnterForeground:(UIScene *)scene {
|
|
|
|
+ [myViewController setVisible:YES];
|
|
|
|
+ iron_internal_foreground_callback();
|
|
}
|
|
}
|
|
|
|
|
|
-- (void)applicationWillTerminate:(UIApplication *)application {
|
|
|
|
- iron_internal_shutdown_callback();
|
|
|
|
|
|
+- (void)sceneDidEnterBackground:(UIScene *)scene {
|
|
|
|
+ [myViewController setVisible:NO];
|
|
|
|
+ iron_internal_background_callback();
|
|
}
|
|
}
|
|
|
|
|
|
@end
|
|
@end
|
|
@@ -493,12 +453,7 @@ int iron_primary_display(void) {
|
|
return 0;
|
|
return 0;
|
|
}
|
|
}
|
|
|
|
|
|
-@implementation Motion
|
|
|
|
-
|
|
|
|
-@end
|
|
|
|
-
|
|
|
|
void iron_internal_mouse_lock(void) {}
|
|
void iron_internal_mouse_lock(void) {}
|
|
-
|
|
|
|
void iron_internal_mouse_unlock(void) {}
|
|
void iron_internal_mouse_unlock(void) {}
|
|
|
|
|
|
bool iron_mouse_can_lock(void) {
|
|
bool iron_mouse_can_lock(void) {
|
|
@@ -506,23 +461,17 @@ bool iron_mouse_can_lock(void) {
|
|
}
|
|
}
|
|
|
|
|
|
void iron_mouse_show(void) {}
|
|
void iron_mouse_show(void) {}
|
|
-
|
|
|
|
void iron_mouse_hide(void) {}
|
|
void iron_mouse_hide(void) {}
|
|
-
|
|
|
|
void iron_mouse_set_position(int x, int y) {}
|
|
void iron_mouse_set_position(int x, int y) {}
|
|
-
|
|
|
|
void iron_mouse_get_position(int *x, int *y) {}
|
|
void iron_mouse_get_position(int *x, int *y) {}
|
|
-
|
|
|
|
void iron_mouse_set_cursor(int cursor_index) {}
|
|
void iron_mouse_set_cursor(int cursor_index) {}
|
|
|
|
|
|
-bool withAutoreleasepool(bool (*f)(void)) {
|
|
|
|
|
|
+bool with_autoreleasepool(bool (*f)(void)) {
|
|
@autoreleasepool {
|
|
@autoreleasepool {
|
|
return f();
|
|
return f();
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
-static bool keyboardshown = false;
|
|
|
|
-
|
|
|
|
const char *iphonegetresourcepath(void) {
|
|
const char *iphonegetresourcepath(void) {
|
|
return [[[NSBundle mainBundle] resourcePath] cStringUsingEncoding:1];
|
|
return [[[NSBundle mainBundle] resourcePath] cStringUsingEncoding:1];
|
|
}
|
|
}
|
|
@@ -537,31 +486,24 @@ bool iron_internal_handle_messages(void) {
|
|
|
|
|
|
void iron_set_keep_screen_on(bool on) {}
|
|
void iron_set_keep_screen_on(bool on) {}
|
|
|
|
|
|
-void showKeyboard(void);
|
|
|
|
-void hideKeyboard(void);
|
|
|
|
-
|
|
|
|
void iron_keyboard_show(void) {
|
|
void iron_keyboard_show(void) {
|
|
- keyboardshown = true;
|
|
|
|
|
|
+ keyboard_shown = true;
|
|
showKeyboard();
|
|
showKeyboard();
|
|
}
|
|
}
|
|
|
|
|
|
void iron_keyboard_hide(void) {
|
|
void iron_keyboard_hide(void) {
|
|
- keyboardshown = false;
|
|
|
|
|
|
+ keyboard_shown = false;
|
|
hideKeyboard();
|
|
hideKeyboard();
|
|
}
|
|
}
|
|
|
|
|
|
bool iron_keyboard_active(void) {
|
|
bool iron_keyboard_active(void) {
|
|
- return keyboardshown;
|
|
|
|
|
|
+ return keyboard_shown;
|
|
}
|
|
}
|
|
|
|
|
|
-void loadURL(const char *url);
|
|
|
|
-
|
|
|
|
void iron_load_url(const char *url) {
|
|
void iron_load_url(const char *url) {
|
|
loadURL(url);
|
|
loadURL(url);
|
|
}
|
|
}
|
|
|
|
|
|
-static char language[3];
|
|
|
|
-
|
|
|
|
const char *iron_language(void) {
|
|
const char *iron_language(void) {
|
|
NSString *nsstr = [[NSLocale preferredLanguages] objectAtIndex:0];
|
|
NSString *nsstr = [[NSLocale preferredLanguages] objectAtIndex:0];
|
|
const char *lang = [nsstr UTF8String];
|
|
const char *lang = [nsstr UTF8String];
|
|
@@ -571,35 +513,17 @@ const char *iron_language(void) {
|
|
return language;
|
|
return language;
|
|
}
|
|
}
|
|
|
|
|
|
-void IronUpdateKeyboard(void) {
|
|
|
|
- if (keyboardshown) {
|
|
|
|
- hideKeyboard();
|
|
|
|
- showKeyboard();
|
|
|
|
- }
|
|
|
|
- else {
|
|
|
|
- hideKeyboard();
|
|
|
|
- }
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
void iron_internal_shutdown(void) {}
|
|
void iron_internal_shutdown(void) {}
|
|
|
|
|
|
void iron_init(const char *name, int width, int height, struct iron_window_options *win) {
|
|
void iron_init(const char *name, int width, int height, struct iron_window_options *win) {
|
|
- iron_window_options_t defaultWin;
|
|
|
|
|
|
+ iron_window_options_t default_win;
|
|
if (win == NULL) {
|
|
if (win == NULL) {
|
|
- iron_window_options_set_defaults(&defaultWin);
|
|
|
|
- win = &defaultWin;
|
|
|
|
|
|
+ iron_window_options_set_defaults(&default_win);
|
|
|
|
+ win = &default_win;
|
|
}
|
|
}
|
|
gpu_init(win->depth_bits, true);
|
|
gpu_init(win->depth_bits, true);
|
|
}
|
|
}
|
|
|
|
|
|
-void endGL(void);
|
|
|
|
-
|
|
|
|
-void swapBuffersiOS(void) {
|
|
|
|
- endGL();
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
-static char sysid[512];
|
|
|
|
-
|
|
|
|
const char *iron_system_id(void) {
|
|
const char *iron_system_id(void) {
|
|
const char *name = [[[UIDevice currentDevice] name] UTF8String];
|
|
const char *name = [[[UIDevice currentDevice] name] UTF8String];
|
|
const char *vendorId = [[[[UIDevice currentDevice] identifierForVendor] UUIDString] UTF8String];
|
|
const char *vendorId = [[[[UIDevice currentDevice] identifierForVendor] UUIDString] UTF8String];
|
|
@@ -609,29 +533,20 @@ const char *iron_system_id(void) {
|
|
return sysid;
|
|
return sysid;
|
|
}
|
|
}
|
|
|
|
|
|
-static const char *getSavePath(void) {
|
|
|
|
|
|
+const char *iron_internal_save_path(void) {
|
|
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSApplicationSupportDirectory, NSUserDomainMask, YES);
|
|
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSApplicationSupportDirectory, NSUserDomainMask, YES);
|
|
NSString *resolvedPath = [paths objectAtIndex:0];
|
|
NSString *resolvedPath = [paths objectAtIndex:0];
|
|
NSString *appName = [NSString stringWithUTF8String:iron_application_name()];
|
|
NSString *appName = [NSString stringWithUTF8String:iron_application_name()];
|
|
resolvedPath = [resolvedPath stringByAppendingPathComponent:appName];
|
|
resolvedPath = [resolvedPath stringByAppendingPathComponent:appName];
|
|
-
|
|
|
|
NSFileManager *fileMgr = [[NSFileManager alloc] init];
|
|
NSFileManager *fileMgr = [[NSFileManager alloc] init];
|
|
-
|
|
|
|
NSError *error;
|
|
NSError *error;
|
|
[fileMgr createDirectoryAtPath:resolvedPath withIntermediateDirectories:YES attributes:nil error:&error];
|
|
[fileMgr createDirectoryAtPath:resolvedPath withIntermediateDirectories:YES attributes:nil error:&error];
|
|
-
|
|
|
|
resolvedPath = [resolvedPath stringByAppendingString:@"/"];
|
|
resolvedPath = [resolvedPath stringByAppendingString:@"/"];
|
|
return [resolvedPath cStringUsingEncoding:1];
|
|
return [resolvedPath cStringUsingEncoding:1];
|
|
}
|
|
}
|
|
|
|
|
|
-const char *iron_internal_save_path(void) {
|
|
|
|
- return getSavePath();
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
-static const char *videoFormats[] = {"mp4", NULL};
|
|
|
|
-
|
|
|
|
const char **iron_video_formats(void) {
|
|
const char **iron_video_formats(void) {
|
|
- return videoFormats;
|
|
|
|
|
|
+ return video_formats;
|
|
}
|
|
}
|
|
|
|
|
|
double iron_frequency(void) {
|
|
double iron_frequency(void) {
|
|
@@ -645,36 +560,15 @@ uint64_t iron_timestamp(void) {
|
|
return time;
|
|
return time;
|
|
}
|
|
}
|
|
|
|
|
|
-#ifdef WITH_GAMEPAD
|
|
|
|
-
|
|
|
|
-const char *iron_gamepad_vendor(int gamepad) {
|
|
|
|
- return "nobody";
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
-const char *iron_gamepad_product_name(int gamepad) {
|
|
|
|
- return "none";
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
-bool iron_gamepad_connected(int num) {
|
|
|
|
- return true;
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
-void iron_gamepad_rumble(int gamepad, float left, float right) {}
|
|
|
|
-
|
|
|
|
-#endif
|
|
|
|
-
|
|
|
|
int main(int argc, char *argv[]) {
|
|
int main(int argc, char *argv[]) {
|
|
- int retVal = 0;
|
|
|
|
|
|
+ int res = 0;
|
|
@autoreleasepool {
|
|
@autoreleasepool {
|
|
- [IronAppDelegate description]; // otherwise removed by the linker
|
|
|
|
- retVal = UIApplicationMain(argc, argv, nil, @"IronAppDelegate");
|
|
|
|
|
|
+ [IronSceneDelegate description]; // otherwise removed by the linker
|
|
|
|
+ res = UIApplicationMain(argc, argv, nil, nil);
|
|
}
|
|
}
|
|
- return retVal;
|
|
|
|
|
|
+ return res;
|
|
}
|
|
}
|
|
|
|
|
|
-static void (*resizeCallback)(int x, int y, void *data) = NULL;
|
|
|
|
-static void *resizeCallbackData = NULL;
|
|
|
|
-
|
|
|
|
int iron_window_x() {
|
|
int iron_window_x() {
|
|
return 0;
|
|
return 0;
|
|
}
|
|
}
|
|
@@ -684,29 +578,22 @@ int iron_window_y() {
|
|
}
|
|
}
|
|
|
|
|
|
void iron_window_resize(int width, int height) {}
|
|
void iron_window_resize(int width, int height) {}
|
|
-
|
|
|
|
void iron_window_move(int x, int y) {}
|
|
void iron_window_move(int x, int y) {}
|
|
-
|
|
|
|
void iron_window_change_mode(iron_window_mode_t mode) {}
|
|
void iron_window_change_mode(iron_window_mode_t mode) {}
|
|
-
|
|
|
|
void iron_window_destroy() {}
|
|
void iron_window_destroy() {}
|
|
-
|
|
|
|
void iron_window_show() {}
|
|
void iron_window_show() {}
|
|
-
|
|
|
|
void iron_window_hide() {}
|
|
void iron_window_hide() {}
|
|
-
|
|
|
|
void iron_window_set_title(const char *title) {}
|
|
void iron_window_set_title(const char *title) {}
|
|
-
|
|
|
|
void iron_window_create(iron_window_options_t *win) {}
|
|
void iron_window_create(iron_window_options_t *win) {}
|
|
|
|
|
|
void iron_window_set_resize_callback(void (*callback)(int x, int y, void *data), void *data) {
|
|
void iron_window_set_resize_callback(void (*callback)(int x, int y, void *data), void *data) {
|
|
- resizeCallback = callback;
|
|
|
|
- resizeCallbackData = data;
|
|
|
|
|
|
+ resize_callback = callback;
|
|
|
|
+ resize_callback_data = data;
|
|
}
|
|
}
|
|
|
|
|
|
void iron_internal_call_resize_callback(int width, int height) {
|
|
void iron_internal_call_resize_callback(int width, int height) {
|
|
- if (resizeCallback != NULL) {
|
|
|
|
- resizeCallback(width, height, resizeCallbackData);
|
|
|
|
|
|
+ if (resize_callback != NULL) {
|
|
|
|
+ resize_callback(width, height, resize_callback_data);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
@@ -719,3 +606,21 @@ iron_window_mode_t iron_window_get_mode() {
|
|
int iron_window_display() {
|
|
int iron_window_display() {
|
|
return 0;
|
|
return 0;
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+#ifdef WITH_GAMEPAD
|
|
|
|
+
|
|
|
|
+const char *iron_gamepad_vendor(int gamepad) {
|
|
|
|
+ return "nobody";
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+const char *iron_gamepad_product_name(int gamepad) {
|
|
|
|
+ return "none";
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+bool iron_gamepad_connected(int num) {
|
|
|
|
+ return true;
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+void iron_gamepad_rumble(int gamepad, float left, float right) {}
|
|
|
|
+
|
|
|
|
+#endif
|