RSS

(root)/iphone/common : 60 : tappity/source/Tappity.m

To get this branch, use:
bzr branch /browse/iphone/common

« back to all changes in this revision

Viewing changes to tappity/source/Tappity.m

Dömötör Gulyás
2010-01-18 09:02:59
Revision ID: dognotdog@gmail.com-20100118080259-1633mzyepdhdacy0
made tappity a nested tree

Show diffs side-by-side

added added

removed removed

1
 
//
2
 
//  Tappity.m
3
 
//  tappity
4
 
//
5
 
//  Created by döme on 25.10.2009.
6
 
//
7
 
 
8
 
/*
9
 
 * Copyright (c) 2009 Doemoetoer Gulyas.
10
 
 * All rights reserved.
11
 
 *
12
 
 * Redistribution and use in source and binary forms, with or without
13
 
 * modification, are permitted provided that the following conditions
14
 
 * are met:
15
 
 * 1. Redistributions of source code must retain the above copyright
16
 
 *    notice, this list of conditions and the following disclaimer.
17
 
 * 2. Redistributions in binary form must reproduce the above copyright
18
 
 *    notice, this list of conditions and the following disclaimer in the
19
 
 *    documentation and/or other materials provided with the distribution.
20
 
 * 3. The name of the author may not be used to endorse or promote products
21
 
 *    derived from this software without specific prior written permission.
22
 
 *
23
 
 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
24
 
 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
25
 
 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
26
 
 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
27
 
 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
28
 
 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
29
 
 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
30
 
 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
31
 
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
32
 
 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33
 
 */
34
 
 
35
 
 
36
 
#include <stdint.h>
37
 
#include <sys/socket.h>
38
 
#include <fcntl.h>
39
 
#include <termios.h>
40
 
#include <netinet/in.h>
41
 
#include <arpa/inet.h>
42
 
 
43
 
 
44
 
#import "Tappity.h"
45
 
 
46
 
//#import "GraphicsServices.h"
47
 
 
48
 
NSString* TapIdKey              = @"tapId";
49
 
NSString* TapDataKey    = @"tapData";
50
 
NSString* TapTouchesKey = @"tapTouches";
51
 
NSString* TapGSEventKey = @"tapGSEvent";
52
 
NSString* TapTouchPhaseKey = @"tapTouchPhase";
53
 
NSString* TapRecordedEventKey = @"tapRecordedEvent";
54
 
NSString* TapAccelerationKey = @"tapAcceleration";
55
 
NSString* TapCompassKey = @"tapCompass";
56
 
NSString* TapLocationKey = @"tapLocation";
57
 
 
58
 
 
59
 
@implementation Tappity
60
 
 
61
 
- (id) init
62
 
{
63
 
        if (!(self = [super init]))
64
 
                return nil;
65
 
 
66
 
 
67
 
 
68
 
        return self;
69
 
}
70
 
 
71
 
 
72
 
@end
73
 
 
74
 
@implementation UITouch (Synthesize)
75
 
 
76
 
- (id)initInView:(UIView *)view
77
 
{
78
 
    self = [super init];
79
 
    if (self != nil)
80
 
    {
81
 
        CGRect frameInWindow;
82
 
        if ([view isKindOfClass:[UIWindow class]])
83
 
        {
84
 
            frameInWindow = view.frame;
85
 
        }
86
 
        else
87
 
        {
88
 
            frameInWindow =
89
 
                [view.window convertRect:view.frame fromView:view.superview];
90
 
        }
91
 
         
92
 
        _tapCount = 1;
93
 
        _locationInWindow =
94
 
            CGPointMake(
95
 
                frameInWindow.origin.x + 0.5 * frameInWindow.size.width,
96
 
                frameInWindow.origin.y + 0.5 * frameInWindow.size.height);
97
 
        _previousLocationInWindow = _locationInWindow;
98
 
 
99
 
        UIView *target = [view.window hitTest:_locationInWindow withEvent:nil];
100
 
        _view = [target retain];
101
 
        _window = [view.window retain];
102
 
        _phase = UITouchPhaseBegan;
103
 
        _touchFlags._firstTouchForView = 1;
104
 
        _touchFlags._isTap = 1;
105
 
        _timestamp = [NSDate timeIntervalSinceReferenceDate];
106
 
    }
107
 
    return self;
108
 
}
109
 
 
110
 
- (void)changeToPhase:(UITouchPhase)phase
111
 
{
112
 
    _phase = phase;
113
 
    _timestamp = [NSDate timeIntervalSinceReferenceDate];
114
 
}
115
 
 
116
 
@end
117
 
 
118
 
 
119
 
/*
120
 
void _printGSPathPoint(GSTouchPointRef p)
121
 
{
122
 
//      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);
123
 
        printf("P: 0x%08X %7G %7G (%G, %G)\n", p->unk0, p->unk1, p->touchSize, p->x, p->y);
124
 
}
125
 
 
126
 
void _printGSEvent(UIEvent* event)
127
 
{
128
 
        GSEvent* e = [event _gsEvent];
129
 
//      printf("%p, %p\n", event, e);
130
 
//      printf("0x%08X  0x%08X  0x%08X\n", e->unk1, e->unk2, e->unk3);
131
 
 
132
 
//      printf("type0 0x%08X  type1 0x%08X  r3 0x%08X\n", e->type0, e->type1, e->r3);
133
 
//      printf("type10 0x%08X  r11 0x%08X  type12 0x%08X\n", e->type10, e->r11, e->type12);
134
 
//      printf("gesture12 0x%08X  gesture14 0x%08X\n", e->gesture13, e->gesture14);
135
 
 
136
 
//      printf("avg0 (%5G, %5G),  avg1 (%5G, %5G)\n", e->avgX0, e->avgY0, e->avgX1, e->avgY1);
137
 
//      printf("(%d) %d\n", e->numInitialTouches, e->numCurrentTouches);
138
 
//      printf("unk16 0x%08X  unk17 0x%08X  unk18 0x%08X  unk19 0x%08X\n", e->unk16, e->unk17, e->unk18, e->unk19);
139
 
//      printf("r20 0x%08X  r21 0x%08X\n", e->r20, e->r21);
140
 
        printf("points %d\n", e->numPoints);
141
 
 
142
 
//      printf("unk9 0x%08X  unk10 0x%08X unk11 0x%08X unk12 0x%08X\n", e->unk9, e->unk10, e->unk11, e->unk12);
143
 
//      printf("%u.%u\n", e->timestamp_s, e->timestamp_ns);
144
 
//      printf("%G\n", (double)e->timestamp*1e-9);
145
 
//      printf("unk12 0x%08X  unk13 0x%08X  unk14 0x%08X  unk15 0x%08X\n", e->unk12, e->unk13, e->unk14, e->unk15);
146
 
        for(size_t i = 0; i < e->numPoints; ++i)
147
 
                _printGSPathPoint(e->points+i);
148
 
        printf("\n");
149
 
}
150
 
 
151
 
@implementation GSEvent
152
 
@end
153
 
*/
154
 
 

Loggerhead 1.17 is a web-based interface for Bazaar branches