5
// Created by döme on 25.10.2009.
6
// Copyright 2009 __MyCompanyName__. All rights reserved.
11
#import "GraphicsServices.h"
13
NSString* TapIdKey = @"tapId";
14
NSString* TapTouchesKey = @"tapTouches";
15
NSString* TapGSEventKey = @"tapGSEvent";
16
NSString* TapTouchPhaseKey = @"tapTouchPhase";
17
NSString* TapRecordedEventKey = @"tapRecordedEvent";
19
@implementation Tappity
23
@implementation UITouch (Synthesize)
25
- (id)initInView:(UIView *)view
31
if ([view isKindOfClass:[UIWindow class]])
33
frameInWindow = view.frame;
38
[view.window convertRect:view.frame fromView:view.superview];
44
frameInWindow.origin.x + 0.5 * frameInWindow.size.width,
45
frameInWindow.origin.y + 0.5 * frameInWindow.size.height);
46
_previousLocationInWindow = _locationInWindow;
48
UIView *target = [view.window hitTest:_locationInWindow withEvent:nil];
49
_view = [target retain];
50
_window = [view.window retain];
51
_phase = UITouchPhaseBegan;
52
_touchFlags._firstTouchForView = 1;
53
_touchFlags._isTap = 1;
54
_timestamp = [NSDate timeIntervalSinceReferenceDate];
59
- (void)changeToPhase:(UITouchPhase)phase
62
_timestamp = [NSDate timeIntervalSinceReferenceDate];
67
@interface GSEventProxy : NSObject
72
unsigned int ignored1;
77
unsigned int ignored2[10];
78
unsigned int ignored3[7];
83
unsigned int ignored4[3];
86
@implementation GSEventProxy
89
@implementation UIEvent (Synthesize)
91
- (id)initWithTouches:(NSSet *) touches
93
UITouch* touch = [touches anyObject];
94
CGPoint location = [touch locationInView: touch.window];
95
GSEventProxy *gsEventProxy = [[GSEventProxy alloc] init];
96
gsEventProxy->x1 = location.x;
97
gsEventProxy->y1 = location.y;
98
gsEventProxy->x2 = location.x;
99
gsEventProxy->y2 = location.y;
100
gsEventProxy->x3 = location.x;
101
gsEventProxy->y3 = location.y;
102
gsEventProxy->sizeX = 1.0;
103
gsEventProxy->sizeY = 1.0;
104
gsEventProxy->flags = ([touch phase] == UITouchPhaseEnded) ? 0x1010180 : 0x3010180;
105
gsEventProxy->type = 3001;
108
// On SDK versions 3.0 and greater, we need to reallocate as a
111
Class touchesEventClass = objc_getClass("UITouchesEvent");
112
if (touchesEventClass && ![[self class] isEqual: touchesEventClass])
115
self = [touchesEventClass alloc];
118
self = [self _initWithEvent:gsEventProxy touches:touches];
125
void _printGSPathPoint(GSTouchPointRef p)
127
// printf("P: 0x%08X 0x%08X 0x%08X 0x%08X (%G, %G)\n", p->unk0, p->unk1, p->unk2, p->unk5, p->x, p->y);
128
printf("P: 0x%08X %7G %7G (%G, %G)\n", p->unk0, p->unk1, p->touchSize, p->x, p->y);
131
void _printGSEvent(UIEvent* event)
133
GSEvent* e = [event _gsEvent];
134
// printf("%p, %p\n", event, e);
135
// printf("0x%08X 0x%08X 0x%08X\n", e->unk1, e->unk2, e->unk3);
137
// printf("type0 0x%08X type1 0x%08X r3 0x%08X\n", e->type0, e->type1, e->r3);
138
// printf("type10 0x%08X r11 0x%08X type12 0x%08X\n", e->type10, e->r11, e->type12);
139
// printf("gesture12 0x%08X gesture14 0x%08X\n", e->gesture13, e->gesture14);
141
// printf("avg0 (%5G, %5G), avg1 (%5G, %5G)\n", e->avgX0, e->avgY0, e->avgX1, e->avgY1);
142
// printf("(%d) %d\n", e->numInitialTouches, e->numCurrentTouches);
143
// printf("unk16 0x%08X unk17 0x%08X unk18 0x%08X unk19 0x%08X\n", e->unk16, e->unk17, e->unk18, e->unk19);
144
// printf("r20 0x%08X r21 0x%08X\n", e->r20, e->r21);
145
printf("points %d\n", e->numPoints);
147
// printf("unk9 0x%08X unk10 0x%08X unk11 0x%08X unk12 0x%08X\n", e->unk9, e->unk10, e->unk11, e->unk12);
148
// printf("%u.%u\n", e->timestamp_s, e->timestamp_ns);
149
// printf("%G\n", (double)e->timestamp*1e-9);
150
// printf("unk12 0x%08X unk13 0x%08X unk14 0x%08X unk15 0x%08X\n", e->unk12, e->unk13, e->unk14, e->unk15);
151
for(size_t i = 0; i < e->numPoints; ++i)
152
_printGSPathPoint(e->points+i);
158
@implementation GSEvent