25
27
receiveDataOnMainThread = NO;
29
enableFeedbackVideoDisplay = YES;
30
- (void) runThreadWithSelector: (SEL) selector
35
activeThreads = [[NSMutableDictionary alloc] init];
36
id number = [NSNumber numberWithInt: threadIds++];
38
[activeThreads setObject: [NSNumber numberWithBool: YES] forKey: number];
39
[NSThread detachNewThreadSelector: selector toTarget: self withObject: [number retain]];
44
35
- (void) connectToService: (NSNetService*) service
108
99
[self runThreadWithSelector: @selector(sendingThread:)];
109
100
[self runThreadWithSelector: @selector(receivingThread:)];
112
UIAccelerometer* accm = [UIAccelerometer sharedAccelerometer];
114
//[accm setDelegate: self];
115
//[accm setUpdateInterval: 0.01];
102
[self performSelectorOnMainThread: @selector(enableSensors) withObject: self waitUntilDone: NO];
107
- (void) enableSensors
110
if (enableAccelerometer)
112
UIAccelerometer* accm = [UIAccelerometer sharedAccelerometer];
113
[accm setDelegate: self];
114
[accm setUpdateInterval: 0.02];
118
CLLocationManager* lm = [[CLLocationManager alloc] init];
119
[lm setDelegate: self];
120
[lm setDistanceFilter: kCLDistanceFilterNone];
121
[lm setDesiredAccuracy: kCLLocationAccuracyBest];
122
[lm startUpdatingLocation];
126
CLLocationManager* lm = [[CLLocationManager alloc] init];
127
[lm setDelegate: self];
128
[lm setHeadingFilter: kCLHeadingFilterNone];
129
[lm startUpdatingHeading];
133
- (void)locationManager:(CLLocationManager *)manager
134
didUpdateToLocation:(CLLocation *)newLoc
135
fromLocation:(CLLocation *)oldLocation
137
NSMutableDictionary* touchDict = [NSMutableDictionary dictionaryWithObjectsAndKeys: [NSNumber numberWithInt: kTapLocation], TapIdKey, nil];
140
NSArray* ary = [NSArray arrayWithObjects:
141
[NSNumber numberWithDouble: [newLoc coordinate].longitude],
142
[NSNumber numberWithDouble: [newLoc coordinate].latitude],
143
[NSNumber numberWithDouble: [newLoc altitude]],
144
[NSNumber numberWithDouble: [newLoc horizontalAccuracy]],
145
[NSNumber numberWithDouble: [newLoc verticalAccuracy]],
146
[NSNumber numberWithDouble: [newLoc course]],
147
[NSNumber numberWithDouble: [newLoc speed]],
150
[touchDict setObject: [NSKeyedArchiver archivedDataWithRootObject: newLoc] forKey: TapLocationKey];
152
NSData* data = [NSPropertyListSerialization dataFromPropertyList: touchDict format: NSPropertyListBinaryFormat_v1_0 errorDescription: nil];
155
[self sendData: data];
159
- (void)locationManager:(CLLocationManager *)manager didUpdateHeading:(CLHeading *)heading
161
NSMutableDictionary* touchDict = [NSMutableDictionary dictionaryWithObjectsAndKeys: [NSNumber numberWithInt: kTapCompass], TapIdKey, nil];
164
NSArray* ary = [NSArray arrayWithObjects: [NSNumber numberWithDouble: [heading x]], [NSNumber numberWithDouble: [heading y]], [NSNumber numberWithDouble: [heading z]], [NSNumber numberWithDouble: [heading magneticHeading]], [NSNumber numberWithDouble: [heading trueHeading]], [NSNumber numberWithDouble: [heading headingAccuracy]], nil];
166
[touchDict setObject: ary forKey: TapCompassKey];
168
[touchDict setObject: [NSKeyedArchiver archivedDataWithRootObject: heading] forKey: TapCompassKey];
170
NSData* data = [NSPropertyListSerialization dataFromPropertyList: touchDict format: NSPropertyListBinaryFormat_v1_0 errorDescription: nil];
173
[self sendData: data];
119
176
- (void) accelerometer: (UIAccelerometer *) accelerometer didAccelerate: (UIAcceleration*) acceleration