From f9aac9739b4d6dedf81a97e2298d38f0981c1265 Mon Sep 17 00:00:00 2001 From: XProger Date: Tue, 18 Apr 2017 01:59:50 +0300 Subject: [PATCH] #15 fix multi-touch support --- src/platform/ios/ViewController.mm | 19 +++++++++++-------- .../ios/openlara.xcodeproj/project.pbxproj | 12 ++++++++++++ 2 files changed, 23 insertions(+), 8 deletions(-) diff --git a/src/platform/ios/ViewController.mm b/src/platform/ios/ViewController.mm index 881de50..efecf07 100644 --- a/src/platform/ios/ViewController.mm +++ b/src/platform/ios/ViewController.mm @@ -31,7 +31,7 @@ int getTime() { return (int)((mach_absolute_time() * info.numer) / (kOneMillion * info.denom)); } -#define SND_BUF_SIZE 4096 +#define SND_BUF_SIZE 8192 static AudioQueueRef audioQueue; @@ -92,14 +92,15 @@ void soundInit() { return; } - GLKView *view = (GLKView *)self.view; - view.context = self.context; - self.preferredFramesPerSecond = 60; + self.preferredFramesPerSecond = 60; + + GLKView *view = (GLKView *)self.view; + view.multipleTouchEnabled = YES; + view.context = self.context; view.drawableDepthFormat = GLKViewDrawableDepthFormat16; view.drawableColorFormat = GLKViewDrawableColorFormatRGBA8888; [EAGLContext setCurrentContext:self.context]; - self.view.multipleTouchEnabled = YES; Stream::contentDir[0] = Stream::cacheDir[0] = 0; @@ -147,13 +148,14 @@ void soundInit() { Game::render(); } -enum { TOUCH_DOWN, TOUCH_UP, TOUCH_MOVE }; - - (void) doTouch:(UIEvent*)event { float scale = [[UIScreen mainScreen] scale]; NSSet* touchSet = [event allTouches]; for (UITouch *touch in touchSet) { + if (touch.phase == UITouchPhaseStationary) + continue; + CGPoint pos = [touch locationInView:self.view]; NSUInteger id = int(touch); @@ -161,8 +163,9 @@ enum { TOUCH_DOWN, TOUCH_UP, TOUCH_MOVE }; if (key == ikNone) return; Input::setPos(key, vec2(pos.x, pos.y) * scale); - if (touch.phase != UITouchPhaseMoved) + if (touch.phase != UITouchPhaseMoved) { Input::setDown(key, touch.phase == UITouchPhaseBegan); + } } } diff --git a/src/platform/ios/openlara.xcodeproj/project.pbxproj b/src/platform/ios/openlara.xcodeproj/project.pbxproj index 1161d03..cf09653 100644 --- a/src/platform/ios/openlara.xcodeproj/project.pbxproj +++ b/src/platform/ios/openlara.xcodeproj/project.pbxproj @@ -209,6 +209,12 @@ isa = PBXProject; attributes = { LastUpgradeCheck = 0430; + TargetAttributes = { + 996585A7160A31450097B128 = { + DevelopmentTeam = L49L654K86; + ProvisioningStyle = Automatic; + }; + }; }; buildConfigurationList = 996585A2160A31450097B128 /* Build configuration list for PBXProject "openlara" */; compatibilityVersion = "Xcode 3.2"; @@ -324,9 +330,12 @@ isa = XCBuildConfiguration; buildSettings = { CODE_SIGN_IDENTITY = ""; + "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; + DEVELOPMENT_TEAM = L49L654K86; GCC_PRECOMPILE_PREFIX_HEADER = YES; GCC_PREFIX_HEADER = "openlara-Prefix.pch"; INFOPLIST_FILE = "openlara-Info.plist"; + IPHONEOS_DEPLOYMENT_TARGET = 10.0; PRODUCT_NAME = "${TARGET_NAME}"; PROVISIONING_PROFILE = ""; WRAPPER_EXTENSION = app; @@ -337,9 +346,12 @@ isa = XCBuildConfiguration; buildSettings = { CODE_SIGN_IDENTITY = ""; + "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; + DEVELOPMENT_TEAM = L49L654K86; GCC_PRECOMPILE_PREFIX_HEADER = YES; GCC_PREFIX_HEADER = "openlara-Prefix.pch"; INFOPLIST_FILE = "openlara-Info.plist"; + IPHONEOS_DEPLOYMENT_TARGET = 10.0; PRODUCT_NAME = "${TARGET_NAME}"; PROVISIONING_PROFILE = ""; WRAPPER_EXTENSION = app;