Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Updated the drawing and ABL code to handle a variable number of touch…

…es (touch tracking is still hardcoded to report just 2)
  • Loading branch information...
commit d2723df67050125d7706ae1a21adfc20272dbc7e 1 parent 0021a01
Matt Rubin mattrubin authored
2  ABL
@@ -1 +1 @@
-Subproject commit 4c0aa607561aa824678d610be9d975dd34bad594
+Subproject commit 2780dad290599dd8bea34abaab9127f1c4a4d17d
28 Ablaze/ABLWrapper.mm
View
@@ -17,14 +17,26 @@ @implementation ABLWrapper
-bool updateX(float* buffer){
- bool a = [ts getXs:buffer];
- printf("X: %f, %f\n", buffer[0], buffer[1]);
+bool updateX(float* buffer, unsigned int *count){
+ bool a = [ts getXs:buffer withCount:count];
+
+ printf("X: ");
+ for (int i=0; i<*count; i++) {
+ printf("%.0f,", buffer[i]);
+ }
+ printf("\n");
+
return a;
}
-bool updateY(float* buffer){
- bool a = [ts getYs:buffer];
- printf("Y: %f, %f\n", buffer[0], buffer[1]);
+bool updateY(float* buffer, unsigned int *count){
+ bool a = [ts getYs:buffer withCount:count];
+
+ printf("Y: ");
+ for (int i=0; i<*count; i++) {
+ printf("%.0f,", buffer[i]);
+ }
+ printf("\n");
+
return a;
}
@@ -38,8 +50,8 @@ -(id)init {
transform = ABTransform(true);
ABSymbol *pos[2] = {
- new ABSymPull("touchXs", 2, updateX),
- new ABSymPull("touchYs", 2, updateY),
+ new ABSymVarPull("touchXs", 11, updateX),
+ new ABSymVarPull("touchYs", 11, updateY),
};
ABSymbol *mean[2] = {
10 Ablaze/FlatView.m
View
@@ -30,10 +30,12 @@ - (id)initWithFrame:(CGRect)frame
- (void)drawRect:(CGRect)rect
{
CGContextRef context = UIGraphicsGetCurrentContext();
- UIColor *redColor = [UIColor colorWithRed:1.0 green:0.0 blue:0.0 alpha:1.0];
- CGContextSetFillColorWithColor(context, redColor.CGColor);
-
- CGContextFillEllipseInRect(context, CGRectMake(middlePoint.x-TOUCH_RADIUS, middlePoint.y-TOUCH_RADIUS, 2*TOUCH_RADIUS, 2*TOUCH_RADIUS));
+ if([points count]>0) {
+ UIColor *redColor = [UIColor colorWithRed:1.0 green:0.0 blue:0.0 alpha:1.0];
+ CGContextSetFillColorWithColor(context, redColor.CGColor);
+
+ CGContextFillEllipseInRect(context, CGRectMake(middlePoint.x-TOUCH_RADIUS, middlePoint.y-TOUCH_RADIUS, 2*TOUCH_RADIUS, 2*TOUCH_RADIUS));
+ }
UIColor *blueColor = [UIColor colorWithRed:0.0 green:0.0 blue:1.0 alpha:1.0];
CGContextSetFillColorWithColor(context, blueColor.CGColor);
4 Ablaze/TouchState.h
View
@@ -18,7 +18,7 @@
-(void)handleTouches:(NSSet*)changedTouches;
-(void)print;
--(BOOL)getXs:(float*)buffer;
--(BOOL)getYs:(float*)buffer;
+-(BOOL)getXs:(float*)buffer withCount:(unsigned int *)count;
+-(BOOL)getYs:(float*)buffer withCount:(unsigned int *)count;
@end
45 Ablaze/TouchState.m
View
@@ -94,7 +94,7 @@ -(void)print {
}
--(BOOL)getXs:(float*)buffer {
+-(BOOL)getXs:(float*)buffer withCount:(unsigned int *)count {
NSString* touchKey;
BOOL success = YES;
@synchronized(touchOrder){
@@ -102,22 +102,30 @@ -(BOOL)getXs:(float*)buffer {
if(success)
touchKey = [touchOrder objectAtIndex:0];
}
- if(!success) return NO;
+ if(!success) {
+ *count = 0;
+ return NO;
+ }
@synchronized(touches){
TouchStateTouch* tst = [touches valueForKey:touchKey];
success = (tst!=nil);
if(success){
buffer[0] = tst.location.x;
- buffer[1] = tst.location.x;
}
}
- if(!success) return NO;
+ if(!success) {
+ *count = 0;
+ return NO;
+ }
@synchronized(touchOrder){
success = ([touchOrder count]>1);
if(success)
touchKey = [touchOrder objectAtIndex:1];
}
- if(!success) return YES;
+ if(!success) {
+ *count = 1;
+ return YES;
+ }
@synchronized(touches){
TouchStateTouch* tst = [touches valueForKey:touchKey];
success = (tst!=nil);
@@ -125,10 +133,15 @@ -(BOOL)getXs:(float*)buffer {
buffer[1] = tst.location.x;
}
}
+ if(!success) {
+ *count = 1;
+ } else {
+ *count = 2;
+ }
return YES;
}
--(BOOL)getYs:(float*)buffer {
+-(BOOL)getYs:(float*)buffer withCount:(unsigned int *)count {
NSString* touchKey;
BOOL success = YES;
@synchronized(touchOrder){
@@ -136,7 +149,10 @@ -(BOOL)getYs:(float*)buffer {
if(success)
touchKey = [touchOrder objectAtIndex:0];
}
- if(!success) return NO;
+ if(!success) {
+ *count = 0;
+ return NO;
+ }
@synchronized(touches){
TouchStateTouch* tst = [touches valueForKey:touchKey];
success = (tst!=nil);
@@ -145,13 +161,19 @@ -(BOOL)getYs:(float*)buffer {
buffer[1] = tst.location.y;
}
}
- if(!success) return NO;
+ if(!success) {
+ *count = 0;
+ return NO;
+ }
@synchronized(touchOrder){
success = ([touchOrder count]>1);
if(success)
touchKey = [touchOrder objectAtIndex:1];
}
- if(!success) return YES;
+ if(!success) {
+ *count = 1;
+ return YES;
+ }
@synchronized(touches){
TouchStateTouch* tst = [touches valueForKey:touchKey];
success = (tst!=nil);
@@ -159,6 +181,11 @@ -(BOOL)getYs:(float*)buffer {
buffer[1] = tst.location.y;
}
}
+ if(!success) {
+ *count = 1;
+ } else {
+ *count = 2;
+ }
return YES;
}
Please sign in to comment.
Something went wrong with that request. Please try again.