352
352
eventPlaybackBusy = NO;
355
- (NSDictionary*) rescaleTouches: (NSDictionary*) event
366
presumably touches at offsets +24 per touch
370
long type = [[event objectForKey: @"Type"] integerValue];
372
if (type == 3001) // touch event
374
NSMutableDictionary* mdict = [event mutableCopy];
376
CGRect targetScreen = [[UIScreen mainScreen] bounds];
377
CGRect sourceScreen = CGRectFromString([mdict objectForKey: @"UIScreen bounds"]);
379
float xoff0 = sourceScreen.origin.x;
380
float xoff1 = targetScreen.origin.x;
381
float yoff0 = sourceScreen.origin.y;
382
float yoff1 = targetScreen.origin.y;
383
float xs0 = sourceScreen.size.width;
384
float xs1 = targetScreen.size.width;
385
float ys0 = sourceScreen.size.height;
386
float ys1 = targetScreen.size.height;
388
CGPoint wloc = CGPointMake([[[mdict objectForKey: @"WindowLocation"] objectForKey: @"X"] floatValue], [[[mdict objectForKey: @"WindowLocation"] objectForKey: @"Y"] floatValue]);
389
CGPoint loc = CGPointMake([[[mdict objectForKey: @"Location"] objectForKey: @"X"] floatValue], [[[mdict objectForKey: @"Location"] objectForKey: @"Y"] floatValue]);
391
wloc.x = (wloc.x - xoff0)*(xs1/xs0) + xoff1;
392
wloc.y = (wloc.y - yoff0)*(ys1/ys0) + yoff1;
393
loc.x = (loc.x - xoff0)*(xs1/xs0) + xoff1;
394
loc.y = (loc.y - yoff0)*(ys1/ys0) + yoff1;
396
[mdict setObject: [NSDictionary dictionaryWithObjectsAndKeys: [NSNumber numberWithFloat: wloc.x], @"X", [NSNumber numberWithFloat: wloc.y], @"Y", nil] forKey: @"WindowLocation"];
397
[mdict setObject: [NSDictionary dictionaryWithObjectsAndKeys: [NSNumber numberWithFloat: loc.x], @"X", [NSNumber numberWithFloat: loc.y], @"Y", nil] forKey: @"Location"];
399
NSMutableData* data = [[event objectForKey: @"Data"] mutableCopy];
400
void* bytes = [data mutableBytes];
402
uint8_t ntouches = ((uint8_t*)bytes)[33];
404
for (size_t i = 0; i < ntouches; ++i)
406
size_t ii = 48 + i*24;
407
float x = *((float*)(bytes + ii));
408
float y = *((float*)(bytes + ii+4));
410
x = (x - xoff0)*(xs1/xs0) + xoff1;
411
y = (y - yoff0)*(ys1/ys0) + yoff1;
413
*((float*)(bytes + ii)) = x;
414
*((float*)(bytes + ii+4)) = y;
418
[mdict setObject: data forKey: @"Data"];
420
[mdict removeObjectForKey: @"UIScreen bounds"];
355
428
- (void) dataReceived: (NSDictionary*) dataDict
357
430
uint32_t messageId = [[dataDict objectForKey: SocketMessageIdKey] intValue];