SPB Git

Repository Public

KAMultiTouch.m 5.5 KB 132 lines objective-c

1// =============================================================================2//                  SP BOUCHER | SOFTWARE & RESEARCH3//             ARTIFICIAL INTELLIGENCE • FINANCE • ENGINEERING4// =============================================================================5//6// PROJECT METADATA7// -----------------------------------------------------------------------------8// Project          : KA Maps Engine9// File             : sdk/ios/Example/UITests/KAMultiTouch.m10// Module           : sdk11// Repository       : https://git.spboucher.ai/ka-maps-engine12// Created          : 2026-12-0113// Last Modified    : 2026-12-0114//15// =============================================================================16// AUTHOR & PROFESSIONAL AFFILIATION17// =============================================================================18//19// Author           : Simon-Pierre Boucher20// Position         : Professor of Finance21// Institution      : Université du Québec en Outaouais (UQO)22// Department       : Département des sciences administratives23// Organization     : SP Boucher24//25// Website          : https://spboucher.ai26// Git              : https://git.spboucher.ai27//28// =============================================================================29// OFFICIAL CONTACT DIRECTORY30// =============================================================================31//32// General          : info@spboucher.ai33// Professional     : contact@spboucher.ai34// Direct           : simon@spboucher.ai35// Research         : research@spboucher.ai36// Development      : dev@spboucher.ai37// Support          : support@spboucher.ai38// Security/Admin   : admin@spboucher.ai39// Notifications    : notifications@spboucher.ai40//41// Preferred Contact: support@spboucher.ai42//43// =============================================================================44// COPYRIGHT & INTELLECTUAL PROPERTY45// =============================================================================46//47// Copyright (c) 202648// Simon-Pierre Boucher49//50// All rights reserved where applicable.51//52// This file is governed by the applicable project license,53// copyright notices, institutional agreements and relevant law.54//55// Unless expressly authorized by the applicable license or56// rights holder, copying, redistribution, sublicensing,57// publication and commercial exploitation are not permitted.58//59// Existing third-party rights and notices remain unaffected.60//61// =============================================================================62// CONFIDENTIALITY & SECURITY63// =============================================================================64//65// Classification   : Public66// Distribution     : Public repository; use is governed by the project license67// Security Contact : admin@spboucher.ai68//69// Access to this source does not independently grant permission70// to redistribute or disclose confidential materials.71//72// Do not embed credentials, private keys, access tokens,73// certificates or confidential personal information.74//75// =============================================================================76// LICENSE & MAINTENANCE77// =============================================================================78//79// License          : None specified (no license file in this repository)80// Maintainer       : Simon-Pierre Boucher81// Technical Contact: dev@spboucher.ai82//83// =============================================================================84// END OF SP BOUCHER SOURCE HEADER85// =============================================================================8687#import "KAMultiTouch.h"88#import <UIKit/UIKit.h>89#import <XCTest/XCTest.h>9091@interface XCPointerEventPath : NSObject92- (instancetype)initForTouchAtPoint:(CGPoint)point offset:(NSTimeInterval)offset;93- (void)moveToPoint:(CGPoint)point atOffset:(NSTimeInterval)offset;94- (void)liftUpAtOffset:(NSTimeInterval)offset;95@end9697@interface XCSynthesizedEventRecord : NSObject98- (instancetype)initWithName:(NSString *)name interfaceOrientation:(UIInterfaceOrientation)orientation;99- (void)addPointerEventPath:(XCPointerEventPath *)path;100- (BOOL)synthesizeWithError:(NSError **)error;101@end102103@implementation KAMultiTouch104105+ (BOOL)performFingers:(NSArray<NSArray<NSArray<NSNumber *> *> *> *)fingers error:(NSError **)error {106    Class recordClass = NSClassFromString(@"XCSynthesizedEventRecord");107    Class pathClass = NSClassFromString(@"XCPointerEventPath");108    if (!recordClass || !pathClass || ![recordClass instancesRespondToSelector:@selector(synthesizeWithError:)]) {109        if (error) {110            *error = [NSError errorWithDomain:@"KAMultiTouch" code:1 userInfo:@{NSLocalizedDescriptionKey: @"synthèse tactile indisponible dans cette version d'XCTest"}];111        }112        return NO;113    }114    XCSynthesizedEventRecord *record = [[recordClass alloc] initWithName:@"KAMultiTouch" interfaceOrientation:UIInterfaceOrientationPortrait];115    for (NSArray<NSArray<NSNumber *> *> *finger in fingers) {116        if (finger.count < 2) {117            continue;118        }119        NSArray<NSNumber *> *first = finger.firstObject;120        XCPointerEventPath *path = [[pathClass alloc] initForTouchAtPoint:CGPointMake(first[0].doubleValue, first[1].doubleValue) offset:first[2].doubleValue];121        for (NSUInteger i = 1; i < finger.count; i++) {122            NSArray<NSNumber *> *p = finger[i];123            [path moveToPoint:CGPointMake(p[0].doubleValue, p[1].doubleValue) atOffset:p[2].doubleValue];124        }125        [path liftUpAtOffset:finger.lastObject[2].doubleValue + 0.02];126        [record addPointerEventPath:path];127    }128    return [record synthesizeWithError:error];129}130131@end132
Files main
Menu

Theme