1
0
mirror of https://github.com/XProger/OpenLara.git synced 2025-08-09 14:47:02 +02:00

#15 fix multi-touch support

This commit is contained in:
XProger
2017-04-18 01:59:50 +03:00
parent 1c4acb9ff6
commit f9aac9739b
2 changed files with 23 additions and 8 deletions

View File

@@ -31,7 +31,7 @@ int getTime() {
return (int)((mach_absolute_time() * info.numer) / (kOneMillion * info.denom)); return (int)((mach_absolute_time() * info.numer) / (kOneMillion * info.denom));
} }
#define SND_BUF_SIZE 4096 #define SND_BUF_SIZE 8192
static AudioQueueRef audioQueue; static AudioQueueRef audioQueue;
@@ -92,14 +92,15 @@ void soundInit() {
return; return;
} }
GLKView *view = (GLKView *)self.view; self.preferredFramesPerSecond = 60;
view.context = self.context;
self.preferredFramesPerSecond = 60; GLKView *view = (GLKView *)self.view;
view.multipleTouchEnabled = YES;
view.context = self.context;
view.drawableDepthFormat = GLKViewDrawableDepthFormat16; view.drawableDepthFormat = GLKViewDrawableDepthFormat16;
view.drawableColorFormat = GLKViewDrawableColorFormatRGBA8888; view.drawableColorFormat = GLKViewDrawableColorFormatRGBA8888;
[EAGLContext setCurrentContext:self.context]; [EAGLContext setCurrentContext:self.context];
self.view.multipleTouchEnabled = YES;
Stream::contentDir[0] = Stream::cacheDir[0] = 0; Stream::contentDir[0] = Stream::cacheDir[0] = 0;
@@ -147,13 +148,14 @@ void soundInit() {
Game::render(); Game::render();
} }
enum { TOUCH_DOWN, TOUCH_UP, TOUCH_MOVE };
- (void) doTouch:(UIEvent*)event { - (void) doTouch:(UIEvent*)event {
float scale = [[UIScreen mainScreen] scale]; float scale = [[UIScreen mainScreen] scale];
NSSet* touchSet = [event allTouches]; NSSet* touchSet = [event allTouches];
for (UITouch *touch in touchSet) { for (UITouch *touch in touchSet) {
if (touch.phase == UITouchPhaseStationary)
continue;
CGPoint pos = [touch locationInView:self.view]; CGPoint pos = [touch locationInView:self.view];
NSUInteger id = int(touch); NSUInteger id = int(touch);
@@ -161,8 +163,9 @@ enum { TOUCH_DOWN, TOUCH_UP, TOUCH_MOVE };
if (key == ikNone) return; if (key == ikNone) return;
Input::setPos(key, vec2(pos.x, pos.y) * scale); Input::setPos(key, vec2(pos.x, pos.y) * scale);
if (touch.phase != UITouchPhaseMoved) if (touch.phase != UITouchPhaseMoved) {
Input::setDown(key, touch.phase == UITouchPhaseBegan); Input::setDown(key, touch.phase == UITouchPhaseBegan);
}
} }
} }

View File

@@ -209,6 +209,12 @@
isa = PBXProject; isa = PBXProject;
attributes = { attributes = {
LastUpgradeCheck = 0430; LastUpgradeCheck = 0430;
TargetAttributes = {
996585A7160A31450097B128 = {
DevelopmentTeam = L49L654K86;
ProvisioningStyle = Automatic;
};
};
}; };
buildConfigurationList = 996585A2160A31450097B128 /* Build configuration list for PBXProject "openlara" */; buildConfigurationList = 996585A2160A31450097B128 /* Build configuration list for PBXProject "openlara" */;
compatibilityVersion = "Xcode 3.2"; compatibilityVersion = "Xcode 3.2";
@@ -324,9 +330,12 @@
isa = XCBuildConfiguration; isa = XCBuildConfiguration;
buildSettings = { buildSettings = {
CODE_SIGN_IDENTITY = ""; CODE_SIGN_IDENTITY = "";
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
DEVELOPMENT_TEAM = L49L654K86;
GCC_PRECOMPILE_PREFIX_HEADER = YES; GCC_PRECOMPILE_PREFIX_HEADER = YES;
GCC_PREFIX_HEADER = "openlara-Prefix.pch"; GCC_PREFIX_HEADER = "openlara-Prefix.pch";
INFOPLIST_FILE = "openlara-Info.plist"; INFOPLIST_FILE = "openlara-Info.plist";
IPHONEOS_DEPLOYMENT_TARGET = 10.0;
PRODUCT_NAME = "${TARGET_NAME}"; PRODUCT_NAME = "${TARGET_NAME}";
PROVISIONING_PROFILE = ""; PROVISIONING_PROFILE = "";
WRAPPER_EXTENSION = app; WRAPPER_EXTENSION = app;
@@ -337,9 +346,12 @@
isa = XCBuildConfiguration; isa = XCBuildConfiguration;
buildSettings = { buildSettings = {
CODE_SIGN_IDENTITY = ""; CODE_SIGN_IDENTITY = "";
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
DEVELOPMENT_TEAM = L49L654K86;
GCC_PRECOMPILE_PREFIX_HEADER = YES; GCC_PRECOMPILE_PREFIX_HEADER = YES;
GCC_PREFIX_HEADER = "openlara-Prefix.pch"; GCC_PREFIX_HEADER = "openlara-Prefix.pch";
INFOPLIST_FILE = "openlara-Info.plist"; INFOPLIST_FILE = "openlara-Info.plist";
IPHONEOS_DEPLOYMENT_TARGET = 10.0;
PRODUCT_NAME = "${TARGET_NAME}"; PRODUCT_NAME = "${TARGET_NAME}";
PROVISIONING_PROFILE = ""; PROVISIONING_PROFILE = "";
WRAPPER_EXTENSION = app; WRAPPER_EXTENSION = app;