iOS: fix deprecations
Change deprecated method calls to new ones. Guard iOS version dependant functionality behind availability checks.
This commit is contained in:
parent
bdfe93bad2
commit
3386fac02c
|
@ -47,4 +47,4 @@ jobs:
|
||||||
env:
|
env:
|
||||||
SCONS_CACHE: ${{github.workspace}}/.scons_cache/
|
SCONS_CACHE: ${{github.workspace}}/.scons_cache/
|
||||||
run: |
|
run: |
|
||||||
scons -j2 verbose=yes warnings=all werror=no platform=iphone target=release tools=no
|
scons -j2 verbose=yes warnings=all werror=yes platform=iphone target=release tools=no
|
||||||
|
|
|
@ -319,7 +319,7 @@
|
||||||
GCC_WARN_UNINITIALIZED_AUTOS = YES;
|
GCC_WARN_UNINITIALIZED_AUTOS = YES;
|
||||||
GCC_WARN_UNUSED_FUNCTION = YES;
|
GCC_WARN_UNUSED_FUNCTION = YES;
|
||||||
GCC_WARN_UNUSED_VARIABLE = YES;
|
GCC_WARN_UNUSED_VARIABLE = YES;
|
||||||
IPHONEOS_DEPLOYMENT_TARGET = 9.0;
|
IPHONEOS_DEPLOYMENT_TARGET = 10.0;
|
||||||
OTHER_LDFLAGS = "$linker_flags";
|
OTHER_LDFLAGS = "$linker_flags";
|
||||||
SDKROOT = iphoneos;
|
SDKROOT = iphoneos;
|
||||||
TARGETED_DEVICE_FAMILY = "1,2";
|
TARGETED_DEVICE_FAMILY = "1,2";
|
||||||
|
@ -358,7 +358,7 @@
|
||||||
GCC_WARN_UNINITIALIZED_AUTOS = YES;
|
GCC_WARN_UNINITIALIZED_AUTOS = YES;
|
||||||
GCC_WARN_UNUSED_FUNCTION = YES;
|
GCC_WARN_UNUSED_FUNCTION = YES;
|
||||||
GCC_WARN_UNUSED_VARIABLE = YES;
|
GCC_WARN_UNUSED_VARIABLE = YES;
|
||||||
IPHONEOS_DEPLOYMENT_TARGET = 9.0;
|
IPHONEOS_DEPLOYMENT_TARGET = 10.0;
|
||||||
OTHER_LDFLAGS = "$linker_flags";
|
OTHER_LDFLAGS = "$linker_flags";
|
||||||
SDKROOT = iphoneos;
|
SDKROOT = iphoneos;
|
||||||
TARGETED_DEVICE_FAMILY = "1,2";
|
TARGETED_DEVICE_FAMILY = "1,2";
|
||||||
|
@ -378,7 +378,7 @@
|
||||||
CONFIGURATION_BUILD_DIR = "$(BUILD_DIR)/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME)";
|
CONFIGURATION_BUILD_DIR = "$(BUILD_DIR)/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME)";
|
||||||
DEVELOPMENT_TEAM = $team_id;
|
DEVELOPMENT_TEAM = $team_id;
|
||||||
INFOPLIST_FILE = "$binary/$binary-Info.plist";
|
INFOPLIST_FILE = "$binary/$binary-Info.plist";
|
||||||
IPHONEOS_DEPLOYMENT_TARGET = 9.0;
|
IPHONEOS_DEPLOYMENT_TARGET = 10.0;
|
||||||
LD_RUNPATH_SEARCH_PATHS = (
|
LD_RUNPATH_SEARCH_PATHS = (
|
||||||
"$(inherited)",
|
"$(inherited)",
|
||||||
"@executable_path/Frameworks",
|
"@executable_path/Frameworks",
|
||||||
|
@ -408,7 +408,7 @@
|
||||||
CONFIGURATION_BUILD_DIR = "$(BUILD_DIR)/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME)";
|
CONFIGURATION_BUILD_DIR = "$(BUILD_DIR)/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME)";
|
||||||
DEVELOPMENT_TEAM = $team_id;
|
DEVELOPMENT_TEAM = $team_id;
|
||||||
INFOPLIST_FILE = "$binary/$binary-Info.plist";
|
INFOPLIST_FILE = "$binary/$binary-Info.plist";
|
||||||
IPHONEOS_DEPLOYMENT_TARGET = 9.0;
|
IPHONEOS_DEPLOYMENT_TARGET = 10.0;
|
||||||
LD_RUNPATH_SEARCH_PATHS = (
|
LD_RUNPATH_SEARCH_PATHS = (
|
||||||
"$(inherited)",
|
"$(inherited)",
|
||||||
"@executable_path/Frameworks",
|
"@executable_path/Frameworks",
|
||||||
|
|
|
@ -42,7 +42,9 @@
|
||||||
#include "arkit_session_delegate.h"
|
#include "arkit_session_delegate.h"
|
||||||
|
|
||||||
// just a dirty workaround for now, declare these as globals. I'll probably encapsulate ARSession and associated logic into an mm object and change ARKitInterface to a normal cpp object that consumes it.
|
// just a dirty workaround for now, declare these as globals. I'll probably encapsulate ARSession and associated logic into an mm object and change ARKitInterface to a normal cpp object that consumes it.
|
||||||
|
API_AVAILABLE(ios(11.0))
|
||||||
ARSession *ar_session;
|
ARSession *ar_session;
|
||||||
|
|
||||||
ARKitSessionDelegate *ar_delegate;
|
ARKitSessionDelegate *ar_delegate;
|
||||||
NSTimeInterval last_timestamp;
|
NSTimeInterval last_timestamp;
|
||||||
|
|
||||||
|
@ -55,12 +57,17 @@ void ARKitInterface::start_session() {
|
||||||
if (initialized) {
|
if (initialized) {
|
||||||
print_line("Starting ARKit session");
|
print_line("Starting ARKit session");
|
||||||
|
|
||||||
|
if (@available(iOS 11, *)) {
|
||||||
Class ARWorldTrackingConfigurationClass = NSClassFromString(@"ARWorldTrackingConfiguration");
|
Class ARWorldTrackingConfigurationClass = NSClassFromString(@"ARWorldTrackingConfiguration");
|
||||||
ARWorldTrackingConfiguration *configuration = [ARWorldTrackingConfigurationClass new];
|
ARWorldTrackingConfiguration *configuration = [ARWorldTrackingConfigurationClass new];
|
||||||
|
|
||||||
configuration.lightEstimationEnabled = light_estimation_is_enabled;
|
configuration.lightEstimationEnabled = light_estimation_is_enabled;
|
||||||
if (plane_detection_is_enabled) {
|
if (plane_detection_is_enabled) {
|
||||||
|
if (@available(iOS 11.3, *)) {
|
||||||
configuration.planeDetection = ARPlaneDetectionVertical | ARPlaneDetectionHorizontal;
|
configuration.planeDetection = ARPlaneDetectionVertical | ARPlaneDetectionHorizontal;
|
||||||
|
} else {
|
||||||
|
configuration.planeDetection = ARPlaneDetectionHorizontal;
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
configuration.planeDetection = 0;
|
configuration.planeDetection = 0;
|
||||||
}
|
}
|
||||||
|
@ -72,6 +79,7 @@ void ARKitInterface::start_session() {
|
||||||
|
|
||||||
[ar_session runWithConfiguration:configuration];
|
[ar_session runWithConfiguration:configuration];
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ARKitInterface::stop_session() {
|
void ARKitInterface::stop_session() {
|
||||||
|
@ -84,8 +92,10 @@ void ARKitInterface::stop_session() {
|
||||||
feed->set_active(false);
|
feed->set_active(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (@available(iOS 11.0, *)) {
|
||||||
[ar_session pause];
|
[ar_session pause];
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ARKitInterface::notification(int p_what) {
|
void ARKitInterface::notification(int p_what) {
|
||||||
|
@ -162,6 +172,7 @@ int ARKitInterface::get_capabilities() const {
|
||||||
}
|
}
|
||||||
|
|
||||||
Array ARKitInterface::raycast(Vector2 p_screen_coord) {
|
Array ARKitInterface::raycast(Vector2 p_screen_coord) {
|
||||||
|
if (@available(iOS 11, *)) {
|
||||||
Array arr;
|
Array arr;
|
||||||
Size2 screen_size = OS::get_singleton()->get_window_size();
|
Size2 screen_size = OS::get_singleton()->get_window_size();
|
||||||
CGPoint point;
|
CGPoint point;
|
||||||
|
@ -169,7 +180,7 @@ Array ARKitInterface::raycast(Vector2 p_screen_coord) {
|
||||||
point.y = p_screen_coord.y / screen_size.y;
|
point.y = p_screen_coord.y / screen_size.y;
|
||||||
|
|
||||||
///@TODO maybe give more options here, for now we're taking just ARAchors into account that were found during plane detection keeping their size into account
|
///@TODO maybe give more options here, for now we're taking just ARAchors into account that were found during plane detection keeping their size into account
|
||||||
NSArray<ARHitTestResult *> *results = [ar_session.currentFrame hittest:point types:ARHitTestResultTypeExistingPlaneUsingExtent];
|
NSArray<ARHitTestResult *> *results = [ar_session.currentFrame hitTest:point types:ARHitTestResultTypeExistingPlaneUsingExtent];
|
||||||
|
|
||||||
for (ARHitTestResult *result in results) {
|
for (ARHitTestResult *result in results) {
|
||||||
Transform transform;
|
Transform transform;
|
||||||
|
@ -193,6 +204,9 @@ Array ARKitInterface::raycast(Vector2 p_screen_coord) {
|
||||||
}
|
}
|
||||||
|
|
||||||
return arr;
|
return arr;
|
||||||
|
} else {
|
||||||
|
return Array();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ARKitInterface::_bind_methods() {
|
void ARKitInterface::_bind_methods() {
|
||||||
|
@ -221,6 +235,7 @@ bool ARKitInterface::initialize() {
|
||||||
ARVRServer *arvr_server = ARVRServer::get_singleton();
|
ARVRServer *arvr_server = ARVRServer::get_singleton();
|
||||||
ERR_FAIL_NULL_V(arvr_server, false);
|
ERR_FAIL_NULL_V(arvr_server, false);
|
||||||
|
|
||||||
|
if (@available(iOS 11, *)) {
|
||||||
if (!initialized) {
|
if (!initialized) {
|
||||||
print_line("initializing ARKit");
|
print_line("initializing ARKit");
|
||||||
|
|
||||||
|
@ -266,6 +281,9 @@ bool ARKitInterface::initialize() {
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
} else {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ARKitInterface::uninitialize() {
|
void ARKitInterface::uninitialize() {
|
||||||
|
@ -286,9 +304,12 @@ void ARKitInterface::uninitialize() {
|
||||||
|
|
||||||
remove_all_anchors();
|
remove_all_anchors();
|
||||||
|
|
||||||
|
if (@available(iOS 11.0, *)) {
|
||||||
[ar_session release];
|
[ar_session release];
|
||||||
[ar_delegate release];
|
|
||||||
ar_session = NULL;
|
ar_session = NULL;
|
||||||
|
}
|
||||||
|
[ar_delegate release];
|
||||||
|
|
||||||
ar_delegate = NULL;
|
ar_delegate = NULL;
|
||||||
initialized = false;
|
initialized = false;
|
||||||
session_was_started = false;
|
session_was_started = false;
|
||||||
|
@ -444,7 +465,15 @@ void ARKitInterface::process() {
|
||||||
|
|
||||||
// get some info about our screen and orientation
|
// get some info about our screen and orientation
|
||||||
Size2 screen_size = OS::get_singleton()->get_window_size();
|
Size2 screen_size = OS::get_singleton()->get_window_size();
|
||||||
UIInterfaceOrientation orientation = [[UIApplication sharedApplication] statusBarOrientation];
|
UIInterfaceOrientation orientation = UIInterfaceOrientationUnknown;
|
||||||
|
|
||||||
|
if (@available(iOS 13, *)) {
|
||||||
|
orientation = [UIApplication sharedApplication].delegate.window.windowScene.interfaceOrientation;
|
||||||
|
#if !defined(TARGET_OS_SIMULATOR) || !TARGET_OS_SIMULATOR
|
||||||
|
} else {
|
||||||
|
orientation = [[UIApplication sharedApplication] statusBarOrientation];
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
// Grab our camera image for our backbuffer
|
// Grab our camera image for our backbuffer
|
||||||
CVPixelBufferRef pixelBuffer = current_frame.capturedImage;
|
CVPixelBufferRef pixelBuffer = current_frame.capturedImage;
|
||||||
|
@ -660,6 +689,7 @@ void ARKitInterface::process() {
|
||||||
void ARKitInterface::_add_or_update_anchor(void *p_anchor) {
|
void ARKitInterface::_add_or_update_anchor(void *p_anchor) {
|
||||||
_THREAD_SAFE_METHOD_
|
_THREAD_SAFE_METHOD_
|
||||||
|
|
||||||
|
if (@available(iOS 11.0, *)) {
|
||||||
ARAnchor *anchor = (ARAnchor *)p_anchor;
|
ARAnchor *anchor = (ARAnchor *)p_anchor;
|
||||||
|
|
||||||
unsigned char uuid[16];
|
unsigned char uuid[16];
|
||||||
|
@ -673,6 +703,7 @@ void ARKitInterface::_add_or_update_anchor(void *p_anchor) {
|
||||||
// can we safely cast this?
|
// can we safely cast this?
|
||||||
ARPlaneAnchor *planeAnchor = (ARPlaneAnchor *)anchor;
|
ARPlaneAnchor *planeAnchor = (ARPlaneAnchor *)anchor;
|
||||||
|
|
||||||
|
if (@available(iOS 11.3, *)) {
|
||||||
if (planeAnchor.geometry.triangleCount > 0) {
|
if (planeAnchor.geometry.triangleCount > 0) {
|
||||||
Ref<SurfaceTool> surftool;
|
Ref<SurfaceTool> surftool;
|
||||||
surftool.instance();
|
surftool.instance();
|
||||||
|
@ -693,6 +724,10 @@ void ARKitInterface::_add_or_update_anchor(void *p_anchor) {
|
||||||
Ref<Mesh> nomesh;
|
Ref<Mesh> nomesh;
|
||||||
tracker->set_mesh(nomesh);
|
tracker->set_mesh(nomesh);
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
Ref<Mesh> nomesh;
|
||||||
|
tracker->set_mesh(nomesh);
|
||||||
|
}
|
||||||
|
|
||||||
// Note, this also contains a scale factor which gives us an idea of the size of the anchor
|
// Note, this also contains a scale factor which gives us an idea of the size of the anchor
|
||||||
// We may extract that in our ARVRAnchor class
|
// We may extract that in our ARVRAnchor class
|
||||||
|
@ -710,17 +745,20 @@ void ARKitInterface::_add_or_update_anchor(void *p_anchor) {
|
||||||
tracker->set_orientation(b);
|
tracker->set_orientation(b);
|
||||||
tracker->set_rw_position(Vector3(m44.columns[3][0], m44.columns[3][1], m44.columns[3][2]));
|
tracker->set_rw_position(Vector3(m44.columns[3][0], m44.columns[3][1], m44.columns[3][2]));
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ARKitInterface::_remove_anchor(void *p_anchor) {
|
void ARKitInterface::_remove_anchor(void *p_anchor) {
|
||||||
_THREAD_SAFE_METHOD_
|
_THREAD_SAFE_METHOD_
|
||||||
|
|
||||||
|
if (@available(iOS 11.0, *)) {
|
||||||
ARAnchor *anchor = (ARAnchor *)p_anchor;
|
ARAnchor *anchor = (ARAnchor *)p_anchor;
|
||||||
|
|
||||||
unsigned char uuid[16];
|
unsigned char uuid[16];
|
||||||
[anchor.identifier getUUIDBytes:uuid];
|
[anchor.identifier getUUIDBytes:uuid];
|
||||||
|
|
||||||
remove_anchor_for_uuid(uuid);
|
remove_anchor_for_uuid(uuid);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ARKitInterface::ARKitInterface() {
|
ARKitInterface::ARKitInterface() {
|
||||||
|
@ -728,7 +766,9 @@ ARKitInterface::ARKitInterface() {
|
||||||
session_was_started = false;
|
session_was_started = false;
|
||||||
plane_detection_is_enabled = false;
|
plane_detection_is_enabled = false;
|
||||||
light_estimation_is_enabled = false;
|
light_estimation_is_enabled = false;
|
||||||
|
if (@available(iOS 11.0, *)) {
|
||||||
ar_session = NULL;
|
ar_session = NULL;
|
||||||
|
}
|
||||||
z_near = 0.01;
|
z_near = 0.01;
|
||||||
z_far = 1000.0;
|
z_far = 1000.0;
|
||||||
projection.set_perspective(60.0, 1.0, z_near, z_far, false);
|
projection.set_perspective(60.0, 1.0, z_near, z_far, false);
|
||||||
|
|
|
@ -42,9 +42,9 @@ class ARKitInterface;
|
||||||
|
|
||||||
@property(nonatomic) ARKitInterface *arkit_interface;
|
@property(nonatomic) ARKitInterface *arkit_interface;
|
||||||
|
|
||||||
- (void)session:(ARSession *)session didAddAnchors:(NSArray<ARAnchor *> *)anchors;
|
- (void)session:(ARSession *)session didAddAnchors:(NSArray<ARAnchor *> *)anchors API_AVAILABLE(ios(11.0));
|
||||||
- (void)session:(ARSession *)session didRemoveAnchors:(NSArray<ARAnchor *> *)anchors;
|
- (void)session:(ARSession *)session didRemoveAnchors:(NSArray<ARAnchor *> *)anchors API_AVAILABLE(ios(11.0));
|
||||||
- (void)session:(ARSession *)session didUpdateAnchors:(NSArray<ARAnchor *> *)anchors;
|
- (void)session:(ARSession *)session didUpdateAnchors:(NSArray<ARAnchor *> *)anchors API_AVAILABLE(ios(11.0));
|
||||||
@end
|
@end
|
||||||
|
|
||||||
#endif /* !ARKIT_SESSION_DELEGATE_H */
|
#endif /* !ARKIT_SESSION_DELEGATE_H */
|
||||||
|
|
|
@ -163,13 +163,10 @@
|
||||||
|
|
||||||
{
|
{
|
||||||
// do Y
|
// do Y
|
||||||
int new_width = CVPixelBufferGetWidthOfPlane(pixelBuffer, 0);
|
size_t new_width = CVPixelBufferGetWidthOfPlane(pixelBuffer, 0);
|
||||||
int new_height = CVPixelBufferGetHeightOfPlane(pixelBuffer, 0);
|
size_t new_height = CVPixelBufferGetHeightOfPlane(pixelBuffer, 0);
|
||||||
int _bytes_per_row = CVPixelBufferGetBytesPerRowOfPlane(pixelBuffer, 0);
|
|
||||||
|
|
||||||
if ((width[0] != new_width) || (height[0] != new_height)) {
|
if ((width[0] != new_width) || (height[0] != new_height)) {
|
||||||
// printf("Camera Y plane %i, %i - %i\n", new_width, new_height, bytes_per_row);
|
|
||||||
|
|
||||||
width[0] = new_width;
|
width[0] = new_width;
|
||||||
height[0] = new_height;
|
height[0] = new_height;
|
||||||
img_data[0].resize(new_width * new_height);
|
img_data[0].resize(new_width * new_height);
|
||||||
|
@ -184,13 +181,10 @@
|
||||||
|
|
||||||
{
|
{
|
||||||
// do CbCr
|
// do CbCr
|
||||||
int new_width = CVPixelBufferGetWidthOfPlane(pixelBuffer, 1);
|
size_t new_width = CVPixelBufferGetWidthOfPlane(pixelBuffer, 1);
|
||||||
int new_height = CVPixelBufferGetHeightOfPlane(pixelBuffer, 1);
|
size_t new_height = CVPixelBufferGetHeightOfPlane(pixelBuffer, 1);
|
||||||
int bytes_per_row = CVPixelBufferGetBytesPerRowOfPlane(pixelBuffer, 1);
|
|
||||||
|
|
||||||
if ((width[1] != new_width) || (height[1] != new_height)) {
|
if ((width[1] != new_width) || (height[1] != new_height)) {
|
||||||
// printf("Camera CbCr plane %i, %i - %i\n", new_width, new_height, bytes_per_row);
|
|
||||||
|
|
||||||
width[1] = new_width;
|
width[1] = new_width;
|
||||||
height[1] = new_height;
|
height[1] = new_height;
|
||||||
img_data[1].resize(2 * new_width * new_height);
|
img_data[1].resize(2 * new_width * new_height);
|
||||||
|
@ -359,7 +353,23 @@ void CameraIOS::update_feeds() {
|
||||||
// this way of doing things is deprecated but still works,
|
// this way of doing things is deprecated but still works,
|
||||||
// rewrite to using AVCaptureDeviceDiscoverySession
|
// rewrite to using AVCaptureDeviceDiscoverySession
|
||||||
|
|
||||||
AVCaptureDeviceDiscoverySession *session = [AVCaptureDeviceDiscoverySession discoverySessionWithDeviceTypes:[NSArray arrayWithObjects:AVCaptureDeviceTypeBuiltInTelephotoCamera, AVCaptureDeviceTypeBuiltInDualCamera, AVCaptureDeviceTypeBuiltInTrueDepthCamera, AVCaptureDeviceTypeBuiltInWideAngleCamera, nil] mediaType:AVMediaTypeVideo position:AVCaptureDevicePositionUnspecified];
|
NSMutableArray *deviceTypes = [NSMutableArray array];
|
||||||
|
|
||||||
|
[deviceTypes addObject:AVCaptureDeviceTypeBuiltInWideAngleCamera];
|
||||||
|
[deviceTypes addObject:AVCaptureDeviceTypeBuiltInTelephotoCamera];
|
||||||
|
|
||||||
|
if (@available(iOS 10.2, *)) {
|
||||||
|
[deviceTypes addObject:AVCaptureDeviceTypeBuiltInDualCamera];
|
||||||
|
}
|
||||||
|
|
||||||
|
if (@available(iOS 11.1, *)) {
|
||||||
|
[deviceTypes addObject:AVCaptureDeviceTypeBuiltInTrueDepthCamera];
|
||||||
|
}
|
||||||
|
|
||||||
|
AVCaptureDeviceDiscoverySession *session = [AVCaptureDeviceDiscoverySession
|
||||||
|
discoverySessionWithDeviceTypes:deviceTypes
|
||||||
|
mediaType:AVMediaTypeVideo
|
||||||
|
position:AVCaptureDevicePositionUnspecified];
|
||||||
|
|
||||||
// remove devices that are gone..
|
// remove devices that are gone..
|
||||||
for (int i = feeds.size() - 1; i >= 0; i--) {
|
for (int i = feeds.size() - 1; i >= 0; i--) {
|
||||||
|
|
|
@ -6,7 +6,7 @@ iphone_lib = [
|
||||||
"godot_iphone.cpp",
|
"godot_iphone.cpp",
|
||||||
"os_iphone.mm",
|
"os_iphone.mm",
|
||||||
"semaphore_iphone.cpp",
|
"semaphore_iphone.cpp",
|
||||||
"gl_view.mm",
|
"godot_view.mm",
|
||||||
"main.m",
|
"main.m",
|
||||||
"app_delegate.mm",
|
"app_delegate.mm",
|
||||||
"view_controller.mm",
|
"view_controller.mm",
|
||||||
|
@ -14,7 +14,7 @@ iphone_lib = [
|
||||||
"in_app_store.mm",
|
"in_app_store.mm",
|
||||||
"icloud.mm",
|
"icloud.mm",
|
||||||
"ios.mm",
|
"ios.mm",
|
||||||
"gl_view_gesture_recognizer.mm",
|
"godot_view_gesture_recognizer.mm",
|
||||||
]
|
]
|
||||||
|
|
||||||
env_ios = env.Clone()
|
env_ios = env.Clone()
|
||||||
|
|
|
@ -28,20 +28,19 @@
|
||||||
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||||
/*************************************************************************/
|
/*************************************************************************/
|
||||||
|
|
||||||
#import "gl_view.h"
|
#import "godot_view.h"
|
||||||
#import "view_controller.h"
|
#import "view_controller.h"
|
||||||
#import <UIKit/UIKit.h>
|
#import <UIKit/UIKit.h>
|
||||||
|
|
||||||
#import <CoreMotion/CoreMotion.h>
|
#import <CoreMotion/CoreMotion.h>
|
||||||
|
|
||||||
@interface AppDelegate : NSObject <UIApplicationDelegate, GLViewDelegate> {
|
@interface AppDelegate : NSObject <UIApplicationDelegate, GodotViewDelegate> {
|
||||||
//@property (strong, nonatomic) UIWindow *window;
|
//@property (strong, nonatomic) UIWindow *window;
|
||||||
ViewController *view_controller;
|
ViewController *view_controller;
|
||||||
bool is_focus_out;
|
bool is_focus_out;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@property(strong, class, readonly, nonatomic) ViewController *viewController;
|
||||||
@property(strong, nonatomic) UIWindow *window;
|
@property(strong, nonatomic) UIWindow *window;
|
||||||
|
|
||||||
+ (ViewController *)getViewController;
|
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
|
@ -32,7 +32,7 @@
|
||||||
|
|
||||||
#include "core/project_settings.h"
|
#include "core/project_settings.h"
|
||||||
#include "drivers/coreaudio/audio_driver_coreaudio.h"
|
#include "drivers/coreaudio/audio_driver_coreaudio.h"
|
||||||
#import "gl_view.h"
|
#import "godot_view.h"
|
||||||
#include "main/main.h"
|
#include "main/main.h"
|
||||||
#include "os_iphone.h"
|
#include "os_iphone.h"
|
||||||
|
|
||||||
|
@ -47,16 +47,18 @@ Error _shell_open(String);
|
||||||
void _set_keep_screen_on(bool p_enabled);
|
void _set_keep_screen_on(bool p_enabled);
|
||||||
|
|
||||||
Error _shell_open(String p_uri) {
|
Error _shell_open(String p_uri) {
|
||||||
NSString *url = [[NSString alloc] initWithUTF8String:p_uri.utf8().get_data()];
|
NSString *urlPath = [[NSString alloc] initWithUTF8String:p_uri.utf8().get_data()];
|
||||||
|
NSURL *url = [NSURL URLWithString:urlPath];
|
||||||
|
[urlPath release];
|
||||||
|
|
||||||
if (![[UIApplication sharedApplication] canOpenURL:[NSURL URLWithString:url]]) {
|
if (![[UIApplication sharedApplication] canOpenURL:url]) {
|
||||||
[url release];
|
[url release];
|
||||||
return ERR_CANT_OPEN;
|
return ERR_CANT_OPEN;
|
||||||
}
|
}
|
||||||
|
|
||||||
printf("opening url %ls\n", p_uri.c_str());
|
printf("opening url %ls\n", p_uri.c_str());
|
||||||
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:url]];
|
[[UIApplication sharedApplication] openURL:url options:@{} completionHandler:nil];
|
||||||
[url release];
|
|
||||||
return OK;
|
return OK;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -81,7 +83,8 @@ CMMotionManager *motionManager;
|
||||||
bool motionInitialised;
|
bool motionInitialised;
|
||||||
|
|
||||||
static ViewController *mainViewController = nil;
|
static ViewController *mainViewController = nil;
|
||||||
+ (ViewController *)getViewController {
|
|
||||||
|
+ (ViewController *)viewController {
|
||||||
return mainViewController;
|
return mainViewController;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -154,7 +157,7 @@ static void on_focus_out(ViewController *view_controller, bool *is_focus_out) {
|
||||||
OS::get_singleton()->get_main_loop()->notification(
|
OS::get_singleton()->get_main_loop()->notification(
|
||||||
MainLoop::NOTIFICATION_WM_FOCUS_OUT);
|
MainLoop::NOTIFICATION_WM_FOCUS_OUT);
|
||||||
|
|
||||||
[view_controller.view stopAnimation];
|
[view_controller.godotView stopAnimation];
|
||||||
if (OS::get_singleton()->native_video_is_playing()) {
|
if (OS::get_singleton()->native_video_is_playing()) {
|
||||||
OSIPhone::get_singleton()->native_video_focus_out();
|
OSIPhone::get_singleton()->native_video_focus_out();
|
||||||
}
|
}
|
||||||
|
@ -172,7 +175,7 @@ static void on_focus_in(ViewController *view_controller, bool *is_focus_out) {
|
||||||
OS::get_singleton()->get_main_loop()->notification(
|
OS::get_singleton()->get_main_loop()->notification(
|
||||||
MainLoop::NOTIFICATION_WM_FOCUS_IN);
|
MainLoop::NOTIFICATION_WM_FOCUS_IN);
|
||||||
|
|
||||||
[view_controller.view startAnimation];
|
[view_controller.godotView startAnimation];
|
||||||
if (OSIPhone::get_singleton()->native_video_is_playing()) {
|
if (OSIPhone::get_singleton()->native_video_is_playing()) {
|
||||||
OSIPhone::get_singleton()->native_video_unpause();
|
OSIPhone::get_singleton()->native_video_unpause();
|
||||||
}
|
}
|
||||||
|
@ -301,45 +304,6 @@ static void on_focus_in(ViewController *view_controller, bool *is_focus_out) {
|
||||||
OSIPhone::get_singleton()->joy_axis(joy_id, JOY_ANALOG_R2, jx);
|
OSIPhone::get_singleton()->joy_axis(joy_id, JOY_ANALOG_R2, jx);
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
} else if (controller.gamepad != nil) {
|
|
||||||
// gamepad is the standard profile with 4 buttons, shoulder buttons and a
|
|
||||||
// D-pad
|
|
||||||
controller.gamepad.valueChangedHandler = ^(GCGamepad *gamepad,
|
|
||||||
GCControllerElement *element) {
|
|
||||||
int joy_id = [self getJoyIdForController:controller];
|
|
||||||
|
|
||||||
if (element == gamepad.buttonA) {
|
|
||||||
OSIPhone::get_singleton()->joy_button(joy_id, JOY_BUTTON_0,
|
|
||||||
gamepad.buttonA.isPressed);
|
|
||||||
} else if (element == gamepad.buttonB) {
|
|
||||||
OSIPhone::get_singleton()->joy_button(joy_id, JOY_BUTTON_1,
|
|
||||||
gamepad.buttonB.isPressed);
|
|
||||||
} else if (element == gamepad.buttonX) {
|
|
||||||
OSIPhone::get_singleton()->joy_button(joy_id, JOY_BUTTON_2,
|
|
||||||
gamepad.buttonX.isPressed);
|
|
||||||
} else if (element == gamepad.buttonY) {
|
|
||||||
OSIPhone::get_singleton()->joy_button(joy_id, JOY_BUTTON_3,
|
|
||||||
gamepad.buttonY.isPressed);
|
|
||||||
} else if (element == gamepad.leftShoulder) {
|
|
||||||
OSIPhone::get_singleton()->joy_button(joy_id, JOY_L,
|
|
||||||
gamepad.leftShoulder.isPressed);
|
|
||||||
} else if (element == gamepad.rightShoulder) {
|
|
||||||
OSIPhone::get_singleton()->joy_button(joy_id, JOY_R,
|
|
||||||
gamepad.rightShoulder.isPressed);
|
|
||||||
} else if (element == gamepad.dpad) {
|
|
||||||
OSIPhone::get_singleton()->joy_button(joy_id, JOY_DPAD_UP,
|
|
||||||
gamepad.dpad.up.isPressed);
|
|
||||||
OSIPhone::get_singleton()->joy_button(joy_id, JOY_DPAD_DOWN,
|
|
||||||
gamepad.dpad.down.isPressed);
|
|
||||||
OSIPhone::get_singleton()->joy_button(joy_id, JOY_DPAD_LEFT,
|
|
||||||
gamepad.dpad.left.isPressed);
|
|
||||||
OSIPhone::get_singleton()->joy_button(joy_id, JOY_DPAD_RIGHT,
|
|
||||||
gamepad.dpad.right.isPressed);
|
|
||||||
};
|
|
||||||
};
|
|
||||||
#ifdef ADD_MICRO_GAMEPAD // disabling this for now, only available on iOS 9+,
|
|
||||||
// while we are setting that as the minimum, seems our
|
|
||||||
// build environment doesn't like it
|
|
||||||
} else if (controller.microGamepad != nil) {
|
} else if (controller.microGamepad != nil) {
|
||||||
// micro gamepads were added in OS 9 and feature just 2 buttons and a d-pad
|
// micro gamepads were added in OS 9 and feature just 2 buttons and a d-pad
|
||||||
controller.microGamepad.valueChangedHandler =
|
controller.microGamepad.valueChangedHandler =
|
||||||
|
@ -363,8 +327,7 @@ static void on_focus_in(ViewController *view_controller, bool *is_focus_out) {
|
||||||
gamepad.dpad.right.isPressed);
|
gamepad.dpad.right.isPressed);
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
#endif
|
}
|
||||||
};
|
|
||||||
|
|
||||||
///@TODO need to add support for controller.motion which gives us access to
|
///@TODO need to add support for controller.motion which gives us access to
|
||||||
/// the orientation of the device (if supported)
|
/// the orientation of the device (if supported)
|
||||||
|
@ -428,8 +391,7 @@ OS::VideoMode _get_video_mode() {
|
||||||
};
|
};
|
||||||
|
|
||||||
static int frame_count = 0;
|
static int frame_count = 0;
|
||||||
- (void)drawView:(GLView *)view;
|
- (void)drawView:(GodotView *)view {
|
||||||
{
|
|
||||||
|
|
||||||
switch (frame_count) {
|
switch (frame_count) {
|
||||||
case 0: {
|
case 0: {
|
||||||
|
@ -439,7 +401,6 @@ static int frame_count = 0;
|
||||||
exit(0);
|
exit(0);
|
||||||
};
|
};
|
||||||
++frame_count;
|
++frame_count;
|
||||||
|
|
||||||
}; break;
|
}; break;
|
||||||
|
|
||||||
case 1: {
|
case 1: {
|
||||||
|
@ -611,10 +572,10 @@ static int frame_count = 0;
|
||||||
return FALSE;
|
return FALSE;
|
||||||
};
|
};
|
||||||
|
|
||||||
// WARNING: We must *always* create the GLView after we have constructed the
|
// WARNING: We must *always* create the GodotView after we have constructed the
|
||||||
// OS with iphone_main. This allows the GLView to access project settings so
|
// OS with iphone_main. This allows the GodotView to access project settings so
|
||||||
// it can properly initialize the OpenGL context
|
// it can properly initialize the OpenGL context
|
||||||
GLView *glView = [[GLView alloc] initWithFrame:rect];
|
GodotView *glView = [[GodotView alloc] initWithFrame:rect];
|
||||||
glView.delegate = self;
|
glView.delegate = self;
|
||||||
|
|
||||||
view_controller = [[ViewController alloc] init];
|
view_controller = [[ViewController alloc] init];
|
||||||
|
|
|
@ -206,7 +206,7 @@ void GameCenter::request_achievement_descriptions() {
|
||||||
Array hidden;
|
Array hidden;
|
||||||
Array replayable;
|
Array replayable;
|
||||||
|
|
||||||
for (int i = 0; i < [descriptions count]; i++) {
|
for (NSUInteger i = 0; i < [descriptions count]; i++) {
|
||||||
|
|
||||||
GKAchievementDescription *description = [descriptions objectAtIndex:i];
|
GKAchievementDescription *description = [descriptions objectAtIndex:i];
|
||||||
|
|
||||||
|
@ -256,7 +256,7 @@ void GameCenter::request_achievements() {
|
||||||
PoolStringArray names;
|
PoolStringArray names;
|
||||||
PoolRealArray percentages;
|
PoolRealArray percentages;
|
||||||
|
|
||||||
for (int i = 0; i < [achievements count]; i++) {
|
for (NSUInteger i = 0; i < [achievements count]; i++) {
|
||||||
|
|
||||||
GKAchievement *achievement = [achievements objectAtIndex:i];
|
GKAchievement *achievement = [achievements objectAtIndex:i];
|
||||||
const char *str = [achievement.identifier UTF8String];
|
const char *str = [achievement.identifier UTF8String];
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*************************************************************************/
|
/*************************************************************************/
|
||||||
/* gl_view.h */
|
/* godot_view.h */
|
||||||
/*************************************************************************/
|
/*************************************************************************/
|
||||||
/* This file is part of: */
|
/* This file is part of: */
|
||||||
/* GODOT ENGINE */
|
/* GODOT ENGINE */
|
||||||
|
@ -35,10 +35,10 @@
|
||||||
#import <OpenGLES/ES1/glext.h>
|
#import <OpenGLES/ES1/glext.h>
|
||||||
#import <UIKit/UIKit.h>
|
#import <UIKit/UIKit.h>
|
||||||
|
|
||||||
@protocol GLViewDelegate;
|
@protocol GodotViewDelegate;
|
||||||
@class GLViewGestureRecognizer;
|
@class GodotViewGestureRecognizer;
|
||||||
|
|
||||||
@interface GLView : UIView <UIKeyInput> {
|
@interface GodotView : UIView <UIKeyInput> {
|
||||||
@private
|
@private
|
||||||
// The pixel dimensions of the backbuffer
|
// The pixel dimensions of the backbuffer
|
||||||
GLint backingWidth;
|
GLint backingWidth;
|
||||||
|
@ -63,7 +63,7 @@
|
||||||
NSTimeInterval animationInterval;
|
NSTimeInterval animationInterval;
|
||||||
|
|
||||||
// Delegate to do our drawing, called by -drawView, which can be called manually or via the animation timer.
|
// Delegate to do our drawing, called by -drawView, which can be called manually or via the animation timer.
|
||||||
id<GLViewDelegate> delegate;
|
id<GodotViewDelegate> delegate;
|
||||||
|
|
||||||
// Flag to denote that the -setupView method of a delegate has been called.
|
// Flag to denote that the -setupView method of a delegate has been called.
|
||||||
// Resets to NO whenever the delegate changes.
|
// Resets to NO whenever the delegate changes.
|
||||||
|
@ -72,10 +72,10 @@
|
||||||
float screen_scale;
|
float screen_scale;
|
||||||
|
|
||||||
// Delay gesture recognizer
|
// Delay gesture recognizer
|
||||||
GLViewGestureRecognizer *delayGestureRecognizer;
|
GodotViewGestureRecognizer *delayGestureRecognizer;
|
||||||
}
|
}
|
||||||
|
|
||||||
@property(nonatomic, assign) id<GLViewDelegate> delegate;
|
@property(nonatomic, assign) id<GodotViewDelegate> delegate;
|
||||||
|
|
||||||
// AVPlayer-related properties
|
// AVPlayer-related properties
|
||||||
@property(strong, nonatomic) AVAsset *avAsset;
|
@property(strong, nonatomic) AVAsset *avAsset;
|
||||||
|
@ -112,16 +112,16 @@
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
||||||
@protocol GLViewDelegate <NSObject>
|
@protocol GodotViewDelegate <NSObject>
|
||||||
|
|
||||||
@required
|
@required
|
||||||
|
|
||||||
// Draw with OpenGL ES
|
// Draw with OpenGL ES
|
||||||
- (void)drawView:(GLView *)view;
|
- (void)drawView:(GodotView *)view;
|
||||||
|
|
||||||
@optional
|
@optional
|
||||||
|
|
||||||
// Called whenever you need to do some initialization before rendering.
|
// Called whenever you need to do some initialization before rendering.
|
||||||
- (void)setupView:(GLView *)view;
|
- (void)setupView:(GodotView *)view;
|
||||||
|
|
||||||
@end
|
@end
|
|
@ -1,5 +1,5 @@
|
||||||
/*************************************************************************/
|
/*************************************************************************/
|
||||||
/* gl_view.mm */
|
/* godot_view.mm */
|
||||||
/*************************************************************************/
|
/*************************************************************************/
|
||||||
/* This file is part of: */
|
/* This file is part of: */
|
||||||
/* GODOT ENGINE */
|
/* GODOT ENGINE */
|
||||||
|
@ -28,8 +28,8 @@
|
||||||
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||||
/*************************************************************************/
|
/*************************************************************************/
|
||||||
|
|
||||||
#import "gl_view.h"
|
#import "godot_view.h"
|
||||||
#import "gl_view_gesture_recognizer.h"
|
#import "godot_view_gesture_recognizer.h"
|
||||||
|
|
||||||
#include "core/os/keyboard.h"
|
#include "core/os/keyboard.h"
|
||||||
#include "core/project_settings.h"
|
#include "core/project_settings.h"
|
||||||
|
@ -40,7 +40,7 @@
|
||||||
#import <QuartzCore/QuartzCore.h>
|
#import <QuartzCore/QuartzCore.h>
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@interface GLView (private)
|
@interface GodotView (private)
|
||||||
|
|
||||||
- (id)initGLES;
|
- (id)initGLES;
|
||||||
- (BOOL)createFramebuffer;
|
- (BOOL)createFramebuffer;
|
||||||
|
@ -51,7 +51,7 @@
|
||||||
bool gles3_available = true;
|
bool gles3_available = true;
|
||||||
int gl_view_base_fb;
|
int gl_view_base_fb;
|
||||||
static String keyboard_text;
|
static String keyboard_text;
|
||||||
static GLView *_instance = NULL;
|
static GodotView *_instance = NULL;
|
||||||
|
|
||||||
static bool video_found_error = false;
|
static bool video_found_error = false;
|
||||||
static bool video_playing = false;
|
static bool video_playing = false;
|
||||||
|
@ -203,7 +203,7 @@ CGFloat _points_to_pixels(CGFloat points) {
|
||||||
return (points / pointsPerInch * pixelPerInch);
|
return (points / pointsPerInch * pixelPerInch);
|
||||||
}
|
}
|
||||||
|
|
||||||
@implementation GLView
|
@implementation GodotView
|
||||||
|
|
||||||
@synthesize animationInterval;
|
@synthesize animationInterval;
|
||||||
|
|
||||||
|
@ -325,16 +325,16 @@ static void clear_touches() {
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)initGestureRecognizer {
|
- (void)initGestureRecognizer {
|
||||||
delayGestureRecognizer = [[GLViewGestureRecognizer alloc] init];
|
delayGestureRecognizer = [[GodotViewGestureRecognizer alloc] init];
|
||||||
[self addGestureRecognizer:delayGestureRecognizer];
|
[self addGestureRecognizer:delayGestureRecognizer];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (id<GLViewDelegate>)delegate {
|
- (id<GodotViewDelegate>)delegate {
|
||||||
return delegate;
|
return delegate;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Update the delegate, and if it needs a -setupView: call, set our internal flag so that it will be called.
|
// Update the delegate, and if it needs a -setupView: call, set our internal flag so that it will be called.
|
||||||
- (void)setDelegate:(id<GLViewDelegate>)d {
|
- (void)setDelegate:(id<GodotViewDelegate>)d {
|
||||||
delegate = d;
|
delegate = d;
|
||||||
delegateSetup = ![delegate respondsToSelector:@selector(setupView:)];
|
delegateSetup = ![delegate respondsToSelector:@selector(setupView:)];
|
||||||
}
|
}
|
||||||
|
@ -418,10 +418,10 @@ static void clear_touches() {
|
||||||
|
|
||||||
// Approximate frame rate
|
// Approximate frame rate
|
||||||
// assumes device refreshes at 60 fps
|
// assumes device refreshes at 60 fps
|
||||||
int frameInterval = (int)floor(animationInterval * 60.0f);
|
int displayFPS = (NSInteger)(1.0 / animationInterval);
|
||||||
|
|
||||||
displayLink = [CADisplayLink displayLinkWithTarget:self selector:@selector(drawView)];
|
displayLink = [CADisplayLink displayLinkWithTarget:self selector:@selector(drawView)];
|
||||||
[displayLink setFrameInterval:frameInterval];
|
displayLink.preferredFramesPerSecond = displayFPS;
|
||||||
|
|
||||||
// Setup DisplayLink in main thread
|
// Setup DisplayLink in main thread
|
||||||
[displayLink addToRunLoop:[NSRunLoop currentRunLoop] forMode:NSRunLoopCommonModes];
|
[displayLink addToRunLoop:[NSRunLoop currentRunLoop] forMode:NSRunLoopCommonModes];
|
|
@ -1,5 +1,5 @@
|
||||||
/*************************************************************************/
|
/*************************************************************************/
|
||||||
/* gl_view_gesture_recognizer.h */
|
/* godot_view_gesture_recognizer.h */
|
||||||
/*************************************************************************/
|
/*************************************************************************/
|
||||||
/* This file is part of: */
|
/* This file is part of: */
|
||||||
/* GODOT ENGINE */
|
/* GODOT ENGINE */
|
||||||
|
@ -28,7 +28,7 @@
|
||||||
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||||
/*************************************************************************/
|
/*************************************************************************/
|
||||||
|
|
||||||
// GLViewGestureRecognizer allows iOS gestures to work currectly by
|
// GodotViewGestureRecognizer allows iOS gestures to work currectly by
|
||||||
// emulating UIScrollView's UIScrollViewDelayedTouchesBeganGestureRecognizer.
|
// emulating UIScrollView's UIScrollViewDelayedTouchesBeganGestureRecognizer.
|
||||||
// It catches all gestures incoming to UIView and delays them for 150ms
|
// It catches all gestures incoming to UIView and delays them for 150ms
|
||||||
// (the same value used by UIScrollViewDelayedTouchesBeganGestureRecognizer)
|
// (the same value used by UIScrollViewDelayedTouchesBeganGestureRecognizer)
|
||||||
|
@ -37,7 +37,7 @@
|
||||||
|
|
||||||
#import <UIKit/UIKit.h>
|
#import <UIKit/UIKit.h>
|
||||||
|
|
||||||
@interface GLViewGestureRecognizer : UIGestureRecognizer {
|
@interface GodotViewGestureRecognizer : UIGestureRecognizer {
|
||||||
@private
|
@private
|
||||||
|
|
||||||
// Timer used to delay begin touch message.
|
// Timer used to delay begin touch message.
|
|
@ -1,5 +1,5 @@
|
||||||
/*************************************************************************/
|
/*************************************************************************/
|
||||||
/* gl_view_gesture_recognizer.mm */
|
/* godot_view_gesture_recognizer.mm */
|
||||||
/*************************************************************************/
|
/*************************************************************************/
|
||||||
/* This file is part of: */
|
/* This file is part of: */
|
||||||
/* GODOT ENGINE */
|
/* GODOT ENGINE */
|
||||||
|
@ -28,7 +28,7 @@
|
||||||
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||||
/*************************************************************************/
|
/*************************************************************************/
|
||||||
|
|
||||||
#import "gl_view_gesture_recognizer.h"
|
#import "godot_view_gesture_recognizer.h"
|
||||||
|
|
||||||
#include "core/project_settings.h"
|
#include "core/project_settings.h"
|
||||||
|
|
||||||
|
@ -38,13 +38,13 @@
|
||||||
// but big enough to allow click to work.
|
// but big enough to allow click to work.
|
||||||
const CGFloat kGLGestureMovementDistance = 0.5;
|
const CGFloat kGLGestureMovementDistance = 0.5;
|
||||||
|
|
||||||
@interface GLViewGestureRecognizer ()
|
@interface GodotViewGestureRecognizer ()
|
||||||
|
|
||||||
@property(nonatomic, readwrite, assign) NSTimeInterval delayTimeInterval;
|
@property(nonatomic, readwrite, assign) NSTimeInterval delayTimeInterval;
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
||||||
@implementation GLViewGestureRecognizer
|
@implementation GodotViewGestureRecognizer
|
||||||
|
|
||||||
- (instancetype)init {
|
- (instancetype)init {
|
||||||
self = [super init];
|
self = [super init];
|
|
@ -161,7 +161,7 @@ NSObject *variant_to_nsobject(Variant v) {
|
||||||
NSMutableDictionary *result = [[[NSMutableDictionary alloc] init] autorelease];
|
NSMutableDictionary *result = [[[NSMutableDictionary alloc] init] autorelease];
|
||||||
Dictionary dic = v;
|
Dictionary dic = v;
|
||||||
Array keys = dic.keys();
|
Array keys = dic.keys();
|
||||||
for (unsigned int i = 0; i < keys.size(); ++i) {
|
for (int i = 0; i < keys.size(); ++i) {
|
||||||
NSString *key = [[[NSString alloc] initWithUTF8String:((String)(keys[i])).utf8().get_data()] autorelease];
|
NSString *key = [[[NSString alloc] initWithUTF8String:((String)(keys[i])).utf8().get_data()] autorelease];
|
||||||
NSObject *value = variant_to_nsobject(dic[keys[i]]);
|
NSObject *value = variant_to_nsobject(dic[keys[i]]);
|
||||||
|
|
||||||
|
@ -175,7 +175,7 @@ NSObject *variant_to_nsobject(Variant v) {
|
||||||
} else if (v.get_type() == Variant::ARRAY) {
|
} else if (v.get_type() == Variant::ARRAY) {
|
||||||
NSMutableArray *result = [[[NSMutableArray alloc] init] autorelease];
|
NSMutableArray *result = [[[NSMutableArray alloc] init] autorelease];
|
||||||
Array arr = v;
|
Array arr = v;
|
||||||
for (unsigned int i = 0; i < arr.size(); ++i) {
|
for (int i = 0; i < arr.size(); ++i) {
|
||||||
NSObject *value = variant_to_nsobject(arr[i]);
|
NSObject *value = variant_to_nsobject(arr[i]);
|
||||||
if (value == NULL) {
|
if (value == NULL) {
|
||||||
//trying to add something unsupported to the array. cancel the whole array
|
//trying to add something unsupported to the array. cancel the whole array
|
||||||
|
@ -215,7 +215,7 @@ Variant ICloud::set_key_values(Variant p_params) {
|
||||||
|
|
||||||
Array error_keys;
|
Array error_keys;
|
||||||
|
|
||||||
for (unsigned int i = 0; i < keys.size(); ++i) {
|
for (int i = 0; i < keys.size(); ++i) {
|
||||||
String variant_key = keys[i];
|
String variant_key = keys[i];
|
||||||
Variant variant_value = params[variant_key];
|
Variant variant_value = params[variant_key];
|
||||||
|
|
||||||
|
|
|
@ -39,6 +39,7 @@ extern "C" {
|
||||||
|
|
||||||
bool auto_finish_transactions = true;
|
bool auto_finish_transactions = true;
|
||||||
NSMutableDictionary *pending_transactions = [NSMutableDictionary dictionary];
|
NSMutableDictionary *pending_transactions = [NSMutableDictionary dictionary];
|
||||||
|
static NSArray *latestProducts;
|
||||||
|
|
||||||
@interface SKProduct (LocalizedPrice)
|
@interface SKProduct (LocalizedPrice)
|
||||||
@property(nonatomic, readonly) NSString *localizedPrice;
|
@property(nonatomic, readonly) NSString *localizedPrice;
|
||||||
|
@ -82,6 +83,8 @@ void InAppStore::_bind_methods() {
|
||||||
- (void)productsRequest:(SKProductsRequest *)request didReceiveResponse:(SKProductsResponse *)response {
|
- (void)productsRequest:(SKProductsRequest *)request didReceiveResponse:(SKProductsResponse *)response {
|
||||||
|
|
||||||
NSArray *products = response.products;
|
NSArray *products = response.products;
|
||||||
|
latestProducts = products;
|
||||||
|
|
||||||
Dictionary ret;
|
Dictionary ret;
|
||||||
ret["type"] = "product_info";
|
ret["type"] = "product_info";
|
||||||
ret["result"] = "ok";
|
ret["result"] = "ok";
|
||||||
|
@ -189,11 +192,9 @@ Error InAppStore::restore_purchases() {
|
||||||
int sdk_version = 6;
|
int sdk_version = 6;
|
||||||
|
|
||||||
if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 7.0) {
|
if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 7.0) {
|
||||||
|
|
||||||
NSURL *receiptFileURL = nil;
|
NSURL *receiptFileURL = nil;
|
||||||
NSBundle *bundle = [NSBundle mainBundle];
|
NSBundle *bundle = [NSBundle mainBundle];
|
||||||
if ([bundle respondsToSelector:@selector(appStoreReceiptURL)]) {
|
if ([bundle respondsToSelector:@selector(appStoreReceiptURL)]) {
|
||||||
|
|
||||||
// Get the transaction receipt file path location in the app bundle.
|
// Get the transaction receipt file path location in the app bundle.
|
||||||
receiptFileURL = [bundle appStoreReceiptURL];
|
receiptFileURL = [bundle appStoreReceiptURL];
|
||||||
|
|
||||||
|
@ -206,11 +207,11 @@ Error InAppStore::restore_purchases() {
|
||||||
// which is still available in iOS 7.
|
// which is still available in iOS 7.
|
||||||
|
|
||||||
// Use SKPaymentTransaction's transactionReceipt.
|
// Use SKPaymentTransaction's transactionReceipt.
|
||||||
receipt = transaction.transactionReceipt;
|
receipt = [NSData dataWithContentsOfURL:[[NSBundle mainBundle] appStoreReceiptURL]];
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
receipt = transaction.transactionReceipt;
|
receipt = [NSData dataWithContentsOfURL:[[NSBundle mainBundle] appStoreReceiptURL]];
|
||||||
}
|
}
|
||||||
|
|
||||||
NSString *receipt_to_send = nil;
|
NSString *receipt_to_send = nil;
|
||||||
|
@ -273,7 +274,23 @@ Error InAppStore::purchase(Variant p_params) {
|
||||||
ERR_FAIL_COND_V(!params.has("product_id"), ERR_INVALID_PARAMETER);
|
ERR_FAIL_COND_V(!params.has("product_id"), ERR_INVALID_PARAMETER);
|
||||||
|
|
||||||
NSString *pid = [[[NSString alloc] initWithUTF8String:String(params["product_id"]).utf8().get_data()] autorelease];
|
NSString *pid = [[[NSString alloc] initWithUTF8String:String(params["product_id"]).utf8().get_data()] autorelease];
|
||||||
SKPayment *payment = [SKPayment paymentWithProductIdentifier:pid];
|
|
||||||
|
SKProduct *product = nil;
|
||||||
|
|
||||||
|
if (latestProducts) {
|
||||||
|
for (SKProduct *storedProduct in latestProducts) {
|
||||||
|
if ([storedProduct.productIdentifier isEqualToString:pid]) {
|
||||||
|
product = storedProduct;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!product) {
|
||||||
|
return ERR_INVALID_PARAMETER;
|
||||||
|
}
|
||||||
|
|
||||||
|
SKPayment *payment = [SKPayment paymentWithProduct:product];
|
||||||
SKPaymentQueue *defq = [SKPaymentQueue defaultQueue];
|
SKPaymentQueue *defq = [SKPaymentQueue defaultQueue];
|
||||||
[defq addPayment:payment];
|
[defq addPayment:payment];
|
||||||
printf("purchase sent!\n");
|
printf("purchase sent!\n");
|
||||||
|
|
|
@ -29,9 +29,11 @@
|
||||||
/*************************************************************************/
|
/*************************************************************************/
|
||||||
|
|
||||||
#include "ios.h"
|
#include "ios.h"
|
||||||
#include <sys/sysctl.h>
|
|
||||||
|
#import "app_delegate.h"
|
||||||
|
|
||||||
#import <UIKit/UIKit.h>
|
#import <UIKit/UIKit.h>
|
||||||
|
#include <sys/sysctl.h>
|
||||||
|
|
||||||
void iOS::_bind_methods() {
|
void iOS::_bind_methods() {
|
||||||
|
|
||||||
|
@ -39,8 +41,18 @@ void iOS::_bind_methods() {
|
||||||
};
|
};
|
||||||
|
|
||||||
void iOS::alert(const char *p_alert, const char *p_title) {
|
void iOS::alert(const char *p_alert, const char *p_title) {
|
||||||
UIAlertView *alert = [[[UIAlertView alloc] initWithTitle:[NSString stringWithUTF8String:p_title] message:[NSString stringWithUTF8String:p_alert] delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil, nil] autorelease];
|
NSString *title = [NSString stringWithUTF8String:p_title];
|
||||||
[alert show];
|
NSString *message = [NSString stringWithUTF8String:p_alert];
|
||||||
|
|
||||||
|
UIAlertController *alert = [UIAlertController alertControllerWithTitle:title message:message preferredStyle:UIAlertControllerStyleAlert];
|
||||||
|
UIAlertAction *button = [UIAlertAction actionWithTitle:@"OK"
|
||||||
|
style:UIAlertActionStyleCancel
|
||||||
|
handler:^(id){
|
||||||
|
}];
|
||||||
|
|
||||||
|
[alert addAction:button];
|
||||||
|
|
||||||
|
[AppDelegate.viewController presentViewController:alert animated:YES completion:nil];
|
||||||
}
|
}
|
||||||
|
|
||||||
String iOS::get_model() const {
|
String iOS::get_model() const {
|
||||||
|
|
|
@ -41,11 +41,10 @@ int main(int argc, char *argv[]) {
|
||||||
gargc = argc;
|
gargc = argc;
|
||||||
gargv = argv;
|
gargv = argv;
|
||||||
|
|
||||||
NSAutoreleasePool *pool = [NSAutoreleasePool new];
|
|
||||||
AppDelegate *app = [AppDelegate alloc];
|
|
||||||
printf("running app main\n");
|
printf("running app main\n");
|
||||||
UIApplicationMain(argc, argv, nil, @"AppDelegate");
|
@autoreleasepool {
|
||||||
printf("main done, pool release\n");
|
UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class]));
|
||||||
[pool release];
|
}
|
||||||
|
printf("main done\n");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,6 +30,11 @@
|
||||||
|
|
||||||
#ifdef IPHONE_ENABLED
|
#ifdef IPHONE_ENABLED
|
||||||
|
|
||||||
|
// System headers are at top
|
||||||
|
// to workaround `ambiguous expansion` warning/error
|
||||||
|
#import <UIKit/UIKit.h>
|
||||||
|
#include <dlfcn.h>
|
||||||
|
|
||||||
#include "os_iphone.h"
|
#include "os_iphone.h"
|
||||||
|
|
||||||
#include "drivers/gles2/rasterizer_gles2.h"
|
#include "drivers/gles2/rasterizer_gles2.h"
|
||||||
|
@ -47,9 +52,6 @@
|
||||||
|
|
||||||
#include "semaphore_iphone.h"
|
#include "semaphore_iphone.h"
|
||||||
|
|
||||||
#import <UIKit/UIKit.h>
|
|
||||||
#include <dlfcn.h>
|
|
||||||
|
|
||||||
int OSIPhone::get_video_driver_count() const {
|
int OSIPhone::get_video_driver_count() const {
|
||||||
|
|
||||||
return 2;
|
return 2;
|
||||||
|
|
|
@ -31,17 +31,11 @@
|
||||||
#import <GameKit/GameKit.h>
|
#import <GameKit/GameKit.h>
|
||||||
#import <UIKit/UIKit.h>
|
#import <UIKit/UIKit.h>
|
||||||
|
|
||||||
|
@class GodotView;
|
||||||
|
|
||||||
@interface ViewController : UIViewController <GKGameCenterControllerDelegate> {
|
@interface ViewController : UIViewController <GKGameCenterControllerDelegate> {
|
||||||
};
|
};
|
||||||
|
|
||||||
- (void)didReceiveMemoryWarning;
|
- (GodotView *)godotView;
|
||||||
|
|
||||||
- (void)viewDidLoad;
|
|
||||||
|
|
||||||
- (UIRectEdge)preferredScreenEdgesDeferringSystemGestures;
|
|
||||||
|
|
||||||
- (BOOL)prefersStatusBarHidden;
|
|
||||||
|
|
||||||
- (BOOL)prefersHomeIndicatorAutoHidden;
|
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
|
@ -30,6 +30,7 @@
|
||||||
|
|
||||||
#import "view_controller.h"
|
#import "view_controller.h"
|
||||||
|
|
||||||
|
#import "godot_view.h"
|
||||||
#include "os_iphone.h"
|
#include "os_iphone.h"
|
||||||
|
|
||||||
#include "core/project_settings.h"
|
#include "core/project_settings.h"
|
||||||
|
@ -56,16 +57,17 @@ int add_path(int p_argc, char **p_args) {
|
||||||
int add_cmdline(int p_argc, char **p_args) {
|
int add_cmdline(int p_argc, char **p_args) {
|
||||||
|
|
||||||
NSArray *arr = [[[NSBundle mainBundle] infoDictionary] objectForKey:@"godot_cmdline"];
|
NSArray *arr = [[[NSBundle mainBundle] infoDictionary] objectForKey:@"godot_cmdline"];
|
||||||
if (!arr)
|
if (!arr) {
|
||||||
return p_argc;
|
return p_argc;
|
||||||
|
}
|
||||||
|
|
||||||
for (int i = 0; i < [arr count]; i++) {
|
for (NSUInteger i = 0; i < [arr count]; i++) {
|
||||||
NSString *str = [arr objectAtIndex:i];
|
NSString *str = [arr objectAtIndex:i];
|
||||||
if (!str) {
|
if (!str) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
p_args[p_argc++] = (char *)[str cStringUsingEncoding:NSUTF8StringEncoding];
|
p_args[p_argc++] = (char *)[str cStringUsingEncoding:NSUTF8StringEncoding];
|
||||||
};
|
}
|
||||||
|
|
||||||
p_args[p_argc] = NULL;
|
p_args[p_argc] = NULL;
|
||||||
|
|
||||||
|
@ -79,6 +81,10 @@ int add_cmdline(int p_argc, char **p_args) {
|
||||||
|
|
||||||
@implementation ViewController
|
@implementation ViewController
|
||||||
|
|
||||||
|
- (GodotView *)godotView {
|
||||||
|
return (GodotView *)self.view;
|
||||||
|
}
|
||||||
|
|
||||||
- (void)didReceiveMemoryWarning {
|
- (void)didReceiveMemoryWarning {
|
||||||
[super didReceiveMemoryWarning];
|
[super didReceiveMemoryWarning];
|
||||||
printf("*********** did receive memory warning!\n");
|
printf("*********** did receive memory warning!\n");
|
||||||
|
|
Loading…
Reference in New Issue