bzr branch
/browse/iphone/tappity
| Line | Revision | Contents |
| 1 | 46 | // |
| 2 | // Tappity.m |
|
| 3 | // tappity |
|
| 4 | // |
|
| 5 | // Created by döme on 25.10.2009. |
|
| 6 | // |
|
| 7 | ||
| 8 | 54 | /* |
| 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 | 47 | |
| 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 | 46 | #import "Tappity.h" |
| 45 | ||
| 46 | 49 | //#import "GraphicsServices.h" |
| 47 | 46 | |
| 48 | NSString* TapIdKey = @"tapId"; |
|
| 49 | 50 | NSString* TapDataKey = @"tapData"; |
| 50 | 46 | NSString* TapTouchesKey = @"tapTouches"; |
| 51 | NSString* TapGSEventKey = @"tapGSEvent"; |
|
| 52 | NSString* TapTouchPhaseKey = @"tapTouchPhase"; |
|
| 53 | NSString* TapRecordedEventKey = @"tapRecordedEvent"; |
|
| 54 | 48 | NSString* TapAccelerationKey = @"tapAcceleration"; |
| 55 | NSString* TapCompassKey = @"tapCompass"; |
|
| 56 | NSString* TapLocationKey = @"tapLocation"; |
|
| 57 | 61 | NSString* TapImageDataKey = @"tapImageData"; |
| 58 | NSString* TapReferenceRectKey = @"tapReferenceRect"; |
|
| 59 | NSString* TapImageRectKey = @"tapImageRect"; |
|
| 60 | 48 | |
| 61 | ||
| 62 | 46 | @implementation Tappity |
| 63 | ||
| 64 | 52 | - (id) init |
| 65 | { |
|
| 66 | if (!(self = [super init])) |
|
| 67 | return nil; |
|
| 68 | ||
| 69 | ||
| 70 | ||
| 71 | return self; |
|
| 72 | } |
|
| 73 | ||
| 74 | 47 | |
| 75 | 46 | @end |
| 76 | ||
| 77 | @implementation UITouch (Synthesize) |
|
| 78 | ||
| 79 | - (id)initInView:(UIView *)view |
|
| 80 | { |
|
| 81 | self = [super init]; |
|
| 82 | if (self != nil) |
|
| 83 | { |
|
| 84 | CGRect frameInWindow; |
|
| 85 | if ([view isKindOfClass:[UIWindow class]]) |
|
| 86 | { |
|
| 87 | frameInWindow = view.frame; |
|
| 88 | } |
|
| 89 | else |
|
| 90 | { |
|
| 91 | frameInWindow = |
|
| 92 | [view.window convertRect:view.frame fromView:view.superview]; |
|
| 93 | } |
|
| 94 | |
|
| 95 | _tapCount = 1; |
|
| 96 | _locationInWindow = |
|
| 97 | CGPointMake( |
|
| 98 | frameInWindow.origin.x + 0.5 * frameInWindow.size.width, |
|
| 99 | frameInWindow.origin.y + 0.5 * frameInWindow.size.height); |
|
| 100 | _previousLocationInWindow = _locationInWindow; |
|
| 101 | ||
| 102 | UIView *target = [view.window hitTest:_locationInWindow withEvent:nil]; |
|
| 103 | _view = [target retain]; |
|
| 104 | _window = [view.window retain]; |
|
| 105 | _phase = UITouchPhaseBegan; |
|
| 106 | _touchFlags._firstTouchForView = 1; |
|
| 107 | _touchFlags._isTap = 1; |
|
| 108 | _timestamp = [NSDate timeIntervalSinceReferenceDate]; |
|
| 109 | } |
|
| 110 | return self; |
|
| 111 | } |
|
| 112 | ||
| 113 | - (void)changeToPhase:(UITouchPhase)phase |
|
| 114 | { |
|
| 115 | _phase = phase; |
|
| 116 | _timestamp = [NSDate timeIntervalSinceReferenceDate]; |
|
| 117 | } |
|
| 118 | ||
| 119 | @end |
|
| 120 | ||
| 121 | 49 | |
| 122 | /* |
|
| 123 | 46 | void _printGSPathPoint(GSTouchPointRef p) |
| 124 | { |
|
| 125 | // 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); |
|
| 126 | printf("P: 0x%08X %7G %7G (%G, %G)\n", p->unk0, p->unk1, p->touchSize, p->x, p->y); |
|
| 127 | } |
|
| 128 | ||
| 129 | void _printGSEvent(UIEvent* event) |
|
| 130 | { |
|
| 131 | GSEvent* e = [event _gsEvent]; |
|
| 132 | // printf("%p, %p\n", event, e); |
|
| 133 | // printf("0x%08X 0x%08X 0x%08X\n", e->unk1, e->unk2, e->unk3); |
|
| 134 | ||
| 135 | // printf("type0 0x%08X type1 0x%08X r3 0x%08X\n", e->type0, e->type1, e->r3); |
|
| 136 | // printf("type10 0x%08X r11 0x%08X type12 0x%08X\n", e->type10, e->r11, e->type12); |
|
| 137 | // printf("gesture12 0x%08X gesture14 0x%08X\n", e->gesture13, e->gesture14); |
|
| 138 | ||
| 139 | // printf("avg0 (%5G, %5G), avg1 (%5G, %5G)\n", e->avgX0, e->avgY0, e->avgX1, e->avgY1); |
|
| 140 | // printf("(%d) %d\n", e->numInitialTouches, e->numCurrentTouches); |
|
| 141 | // printf("unk16 0x%08X unk17 0x%08X unk18 0x%08X unk19 0x%08X\n", e->unk16, e->unk17, e->unk18, e->unk19); |
|
| 142 | // printf("r20 0x%08X r21 0x%08X\n", e->r20, e->r21); |
|
| 143 | printf("points %d\n", e->numPoints); |
|
| 144 | ||
| 145 | // printf("unk9 0x%08X unk10 0x%08X unk11 0x%08X unk12 0x%08X\n", e->unk9, e->unk10, e->unk11, e->unk12); |
|
| 146 | // printf("%u.%u\n", e->timestamp_s, e->timestamp_ns); |
|
| 147 | // printf("%G\n", (double)e->timestamp*1e-9); |
|
| 148 | // printf("unk12 0x%08X unk13 0x%08X unk14 0x%08X unk15 0x%08X\n", e->unk12, e->unk13, e->unk14, e->unk15); |
|
| 149 | for(size_t i = 0; i < e->numPoints; ++i) |
|
| 150 | _printGSPathPoint(e->points+i); |
|
| 151 | printf("\n"); |
|
| 152 | } |
|
| 153 | ||
| 154 | @implementation GSEvent |
|
| 155 | @end |
|
| 156 | 49 | */ |
| 157 | 46 |
Loggerhead 1.17 is a web-based interface for Bazaar branches