|
@@ -38,7 +38,6 @@
|
|
#import <QuartzCore/QuartzCore.h>
|
|
#import <QuartzCore/QuartzCore.h>
|
|
|
|
|
|
#import "display_layer.h"
|
|
#import "display_layer.h"
|
|
-#import "godot_view_gesture_recognizer.h"
|
|
|
|
#import "godot_view_renderer.h"
|
|
#import "godot_view_renderer.h"
|
|
|
|
|
|
#import <CoreMotion/CoreMotion.h>
|
|
#import <CoreMotion/CoreMotion.h>
|
|
@@ -62,8 +61,6 @@ static const int max_touches = 8;
|
|
|
|
|
|
@property(strong, nonatomic) CMMotionManager *motionManager;
|
|
@property(strong, nonatomic) CMMotionManager *motionManager;
|
|
|
|
|
|
-@property(strong, nonatomic) GodotViewGestureRecognizer *delayGestureRecognizer;
|
|
|
|
-
|
|
|
|
@end
|
|
@end
|
|
|
|
|
|
@implementation GodotView
|
|
@implementation GodotView
|
|
@@ -134,10 +131,6 @@ static const int max_touches = 8;
|
|
[self.animationTimer invalidate];
|
|
[self.animationTimer invalidate];
|
|
self.animationTimer = nil;
|
|
self.animationTimer = nil;
|
|
}
|
|
}
|
|
-
|
|
|
|
- if (self.delayGestureRecognizer) {
|
|
|
|
- self.delayGestureRecognizer = nil;
|
|
|
|
- }
|
|
|
|
}
|
|
}
|
|
|
|
|
|
- (void)godot_commonInit {
|
|
- (void)godot_commonInit {
|
|
@@ -157,11 +150,6 @@ static const int max_touches = 8;
|
|
self.motionManager = nil;
|
|
self.motionManager = nil;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
-
|
|
|
|
- // Initialize delay gesture recognizer
|
|
|
|
- GodotViewGestureRecognizer *gestureRecognizer = [[GodotViewGestureRecognizer alloc] init];
|
|
|
|
- self.delayGestureRecognizer = gestureRecognizer;
|
|
|
|
- [self addGestureRecognizer:self.delayGestureRecognizer];
|
|
|
|
}
|
|
}
|
|
|
|
|
|
- (void)startRendering {
|
|
- (void)startRendering {
|
|
@@ -333,75 +321,61 @@ static const int max_touches = 8;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
-- (void)godotTouchesBegan:(NSSet *)touchesSet withEvent:(UIEvent *)event {
|
|
|
|
- NSArray *tlist = [event.allTouches allObjects];
|
|
|
|
- for (unsigned int i = 0; i < [tlist count]; i++) {
|
|
|
|
- if ([touchesSet containsObject:[tlist objectAtIndex:i]]) {
|
|
|
|
- UITouch *touch = [tlist objectAtIndex:i];
|
|
|
|
- int tid = [self getTouchIDForTouch:touch];
|
|
|
|
- ERR_FAIL_COND(tid == -1);
|
|
|
|
- CGPoint touchPoint = [touch locationInView:self];
|
|
|
|
-
|
|
|
|
- if (touch.type == UITouchTypeStylus) {
|
|
|
|
- OSIPhone::get_singleton()->pencil_press(tid, touchPoint.x * self.contentScaleFactor, touchPoint.y * self.contentScaleFactor, true, touch.tapCount > 1);
|
|
|
|
- } else {
|
|
|
|
- OSIPhone::get_singleton()->touch_press(tid, touchPoint.x * self.contentScaleFactor, touchPoint.y * self.contentScaleFactor, true, touch.tapCount > 1);
|
|
|
|
- }
|
|
|
|
|
|
+- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
|
|
|
|
+ for (UITouch *touch in touches) {
|
|
|
|
+ int tid = [self getTouchIDForTouch:touch];
|
|
|
|
+ ERR_FAIL_COND(tid == -1);
|
|
|
|
+ CGPoint touchPoint = [touch locationInView:self];
|
|
|
|
+
|
|
|
|
+ if (touch.type == UITouchTypeStylus) {
|
|
|
|
+ OSIPhone::get_singleton()->pencil_press(tid, touchPoint.x * self.contentScaleFactor, touchPoint.y * self.contentScaleFactor, true, touch.tapCount > 1);
|
|
|
|
+ } else {
|
|
|
|
+ OSIPhone::get_singleton()->touch_press(tid, touchPoint.x * self.contentScaleFactor, touchPoint.y * self.contentScaleFactor, true, touch.tapCount > 1);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
-- (void)godotTouchesMoved:(NSSet *)touches withEvent:(UIEvent *)event {
|
|
|
|
- NSArray *tlist = [event.allTouches allObjects];
|
|
|
|
- for (unsigned int i = 0; i < [tlist count]; i++) {
|
|
|
|
- if ([touches containsObject:[tlist objectAtIndex:i]]) {
|
|
|
|
- UITouch *touch = [tlist objectAtIndex:i];
|
|
|
|
- int tid = [self getTouchIDForTouch:touch];
|
|
|
|
- ERR_FAIL_COND(tid == -1);
|
|
|
|
- CGPoint touchPoint = [touch locationInView:self];
|
|
|
|
- CGPoint prev_point = [touch previousLocationInView:self];
|
|
|
|
- CGFloat force = touch.force;
|
|
|
|
- // Vector2 tilt = touch.azimuthUnitVector;
|
|
|
|
-
|
|
|
|
- if (touch.type == UITouchTypeStylus) {
|
|
|
|
- OSIPhone::get_singleton()->pencil_drag(tid, prev_point.x * self.contentScaleFactor, prev_point.y * self.contentScaleFactor, touchPoint.x * self.contentScaleFactor, touchPoint.y * self.contentScaleFactor, force);
|
|
|
|
- } else {
|
|
|
|
- OSIPhone::get_singleton()->touch_drag(tid, prev_point.x * self.contentScaleFactor, prev_point.y * self.contentScaleFactor, touchPoint.x * self.contentScaleFactor, touchPoint.y * self.contentScaleFactor);
|
|
|
|
- }
|
|
|
|
|
|
+- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event {
|
|
|
|
+ for (UITouch *touch in touches) {
|
|
|
|
+ int tid = [self getTouchIDForTouch:touch];
|
|
|
|
+ ERR_FAIL_COND(tid == -1);
|
|
|
|
+ CGPoint touchPoint = [touch locationInView:self];
|
|
|
|
+ CGPoint prev_point = [touch previousLocationInView:self];
|
|
|
|
+ CGFloat force = touch.force;
|
|
|
|
+
|
|
|
|
+ if (touch.type == UITouchTypeStylus) {
|
|
|
|
+ OSIPhone::get_singleton()->pencil_drag(tid, prev_point.x * self.contentScaleFactor, prev_point.y * self.contentScaleFactor, touchPoint.x * self.contentScaleFactor, touchPoint.y * self.contentScaleFactor, force);
|
|
|
|
+ } else {
|
|
|
|
+ OSIPhone::get_singleton()->touch_drag(tid, prev_point.x * self.contentScaleFactor, prev_point.y * self.contentScaleFactor, touchPoint.x * self.contentScaleFactor, touchPoint.y * self.contentScaleFactor);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
-- (void)godotTouchesEnded:(NSSet *)touches withEvent:(UIEvent *)event {
|
|
|
|
- NSArray *tlist = [event.allTouches allObjects];
|
|
|
|
- for (unsigned int i = 0; i < [tlist count]; i++) {
|
|
|
|
- if ([touches containsObject:[tlist objectAtIndex:i]]) {
|
|
|
|
- UITouch *touch = [tlist objectAtIndex:i];
|
|
|
|
- int tid = [self getTouchIDForTouch:touch];
|
|
|
|
- ERR_FAIL_COND(tid == -1);
|
|
|
|
- [self removeTouch:touch];
|
|
|
|
- CGPoint touchPoint = [touch locationInView:self];
|
|
|
|
- if (touch.type == UITouchTypeStylus) {
|
|
|
|
- OSIPhone::get_singleton()->pencil_press(tid, touchPoint.x * self.contentScaleFactor, touchPoint.y * self.contentScaleFactor, false, false);
|
|
|
|
- } else {
|
|
|
|
- OSIPhone::get_singleton()->touch_press(tid, touchPoint.x * self.contentScaleFactor, touchPoint.y * self.contentScaleFactor, false, false);
|
|
|
|
- }
|
|
|
|
|
|
+- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event {
|
|
|
|
+ for (UITouch *touch in touches) {
|
|
|
|
+ int tid = [self getTouchIDForTouch:touch];
|
|
|
|
+ ERR_FAIL_COND(tid == -1);
|
|
|
|
+ [self removeTouch:touch];
|
|
|
|
+
|
|
|
|
+ CGPoint touchPoint = [touch locationInView:self];
|
|
|
|
+
|
|
|
|
+ if (touch.type == UITouchTypeStylus) {
|
|
|
|
+ OSIPhone::get_singleton()->pencil_press(tid, touchPoint.x * self.contentScaleFactor, touchPoint.y * self.contentScaleFactor, false, false);
|
|
|
|
+ } else {
|
|
|
|
+ OSIPhone::get_singleton()->touch_press(tid, touchPoint.x * self.contentScaleFactor, touchPoint.y * self.contentScaleFactor, false, false);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
-- (void)godotTouchesCancelled:(NSSet *)touches withEvent:(UIEvent *)event {
|
|
|
|
- NSArray *tlist = [event.allTouches allObjects];
|
|
|
|
- for (unsigned int i = 0; i < [tlist count]; i++) {
|
|
|
|
- if ([touches containsObject:[tlist objectAtIndex:i]]) {
|
|
|
|
- UITouch *touch = [tlist objectAtIndex:i];
|
|
|
|
- int tid = [self getTouchIDForTouch:touch];
|
|
|
|
- ERR_FAIL_COND(tid == -1);
|
|
|
|
- if (touch.type == UITouchTypeStylus) {
|
|
|
|
- OSIPhone::get_singleton()->pencil_cancelled(tid);
|
|
|
|
- } else {
|
|
|
|
- OSIPhone::get_singleton()->touches_cancelled(tid);
|
|
|
|
- }
|
|
|
|
|
|
+- (void)touchesCancelled:(NSSet *)touches withEvent:(UIEvent *)event {
|
|
|
|
+ for (UITouch *touch in touches) {
|
|
|
|
+ int tid = [self getTouchIDForTouch:touch];
|
|
|
|
+ ERR_FAIL_COND(tid == -1);
|
|
|
|
+
|
|
|
|
+ if (touch.type == UITouchTypeStylus) {
|
|
|
|
+ OSIPhone::get_singleton()->pencil_cancelled(tid);
|
|
|
|
+ } else {
|
|
|
|
+ OSIPhone::get_singleton()->touches_cancelled(tid);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
[self clearTouches];
|
|
[self clearTouches];
|