1*bf47c682SAndroid Build Coastguard Worker/* 2*bf47c682SAndroid Build Coastguard Worker * Copyright (C) 2016 The Android Open Source Project 3*bf47c682SAndroid Build Coastguard Worker * 4*bf47c682SAndroid Build Coastguard Worker * Licensed under the Apache License, Version 2.0 (the "License"); 5*bf47c682SAndroid Build Coastguard Worker * you may not use this file except in compliance with the License. 6*bf47c682SAndroid Build Coastguard Worker * You may obtain a copy of the License at 7*bf47c682SAndroid Build Coastguard Worker * 8*bf47c682SAndroid Build Coastguard Worker * http://www.apache.org/licenses/LICENSE-2.0 9*bf47c682SAndroid Build Coastguard Worker * 10*bf47c682SAndroid Build Coastguard Worker * Unless required by applicable law or agreed to in writing, software 11*bf47c682SAndroid Build Coastguard Worker * distributed under the License is distributed on an "AS IS" BASIS, 12*bf47c682SAndroid Build Coastguard Worker * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13*bf47c682SAndroid Build Coastguard Worker * See the License for the specific language governing permissions and 14*bf47c682SAndroid Build Coastguard Worker * limitations under the License. 15*bf47c682SAndroid Build Coastguard Worker */ 16*bf47c682SAndroid Build Coastguard Worker 17*bf47c682SAndroid Build Coastguard Worker#import "WALTTouch.h" 18*bf47c682SAndroid Build Coastguard Worker 19*bf47c682SAndroid Build Coastguard Worker@implementation WALTTouch 20*bf47c682SAndroid Build Coastguard Worker- (instancetype)initWithEvent:(UIEvent *)event { 21*bf47c682SAndroid Build Coastguard Worker if ((self = [super init])) { 22*bf47c682SAndroid Build Coastguard Worker if ([event allTouches].count > 1) { 23*bf47c682SAndroid Build Coastguard Worker NSLog(@"Multiple touches in event; taking any."); 24*bf47c682SAndroid Build Coastguard Worker } 25*bf47c682SAndroid Build Coastguard Worker self.kernelTime = event.timestamp; 26*bf47c682SAndroid Build Coastguard Worker 27*bf47c682SAndroid Build Coastguard Worker UITouch *touch = [[event allTouches] anyObject]; 28*bf47c682SAndroid Build Coastguard Worker self.phase = touch.phase; 29*bf47c682SAndroid Build Coastguard Worker if ([touch respondsToSelector:@selector(preciseLocationInView:)]) { // iOS 9.1+ 30*bf47c682SAndroid Build Coastguard Worker self.location = [touch preciseLocationInView:nil]; 31*bf47c682SAndroid Build Coastguard Worker } else { 32*bf47c682SAndroid Build Coastguard Worker self.location = [touch locationInView:nil]; 33*bf47c682SAndroid Build Coastguard Worker } 34*bf47c682SAndroid Build Coastguard Worker } 35*bf47c682SAndroid Build Coastguard Worker return self; 36*bf47c682SAndroid Build Coastguard Worker} 37*bf47c682SAndroid Build Coastguard Worker@end 38