Skip to content

Commit

Permalink
first
Browse files Browse the repository at this point in the history
  • Loading branch information
= committed Aug 15, 2016
0 parents commit 2a10535
Show file tree
Hide file tree
Showing 56 changed files with 5,119 additions and 0 deletions.
1 change: 1 addition & 0 deletions IOKit.framework/IOKit.tbd
852 changes: 852 additions & 0 deletions IOKit.framework/Versions/A/IOKit.tbd

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions IOKit.framework/Versions/Current
489 changes: 489 additions & 0 deletions PTFakeTouch.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file not shown.
@@ -0,0 +1,99 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0710"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
buildImplicitDependencies = "YES">
<BuildActionEntries>
<BuildActionEntry
buildForTesting = "YES"
buildForRunning = "YES"
buildForProfiling = "YES"
buildForArchiving = "YES"
buildForAnalyzing = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "15BBDEF81D61AD5B0098330F"
BuildableName = "PTFakeTouch.framework"
BlueprintName = "PTFakeTouch"
ReferencedContainer = "container:PTFakeTouch.xcodeproj">
</BuildableReference>
</BuildActionEntry>
</BuildActionEntries>
</BuildAction>
<TestAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
shouldUseLaunchSchemeArgsEnv = "YES">
<Testables>
<TestableReference
skipped = "NO">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "15BBDF021D61AD5B0098330F"
BuildableName = "PTFakeTouchTests.xctest"
BlueprintName = "PTFakeTouchTests"
ReferencedContainer = "container:PTFakeTouch.xcodeproj">
</BuildableReference>
</TestableReference>
</Testables>
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "15BBDEF81D61AD5B0098330F"
BuildableName = "PTFakeTouch.framework"
BlueprintName = "PTFakeTouch"
ReferencedContainer = "container:PTFakeTouch.xcodeproj">
</BuildableReference>
</MacroExpansion>
<AdditionalOptions>
</AdditionalOptions>
</TestAction>
<LaunchAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
launchStyle = "0"
useCustomWorkingDirectory = "NO"
ignoresPersistentStateOnLaunch = "NO"
debugDocumentVersioning = "YES"
debugServiceExtension = "internal"
allowLocationSimulation = "YES">
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "15BBDEF81D61AD5B0098330F"
BuildableName = "PTFakeTouch.framework"
BlueprintName = "PTFakeTouch"
ReferencedContainer = "container:PTFakeTouch.xcodeproj">
</BuildableReference>
</MacroExpansion>
<AdditionalOptions>
</AdditionalOptions>
</LaunchAction>
<ProfileAction
buildConfiguration = "Release"
shouldUseLaunchSchemeArgsEnv = "YES"
savedToolIdentifier = ""
useCustomWorkingDirectory = "NO"
debugDocumentVersioning = "YES">
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "15BBDEF81D61AD5B0098330F"
BuildableName = "PTFakeTouch.framework"
BlueprintName = "PTFakeTouch"
ReferencedContainer = "container:PTFakeTouch.xcodeproj">
</BuildableReference>
</MacroExpansion>
</ProfileAction>
<AnalyzeAction
buildConfiguration = "Debug">
</AnalyzeAction>
<ArchiveAction
buildConfiguration = "Release"
revealArchiveInOrganizer = "YES">
</ArchiveAction>
</Scheme>
@@ -0,0 +1,27 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>SchemeUserState</key>
<dict>
<key>PTFakeTouch.xcscheme</key>
<dict>
<key>orderHint</key>
<integer>0</integer>
</dict>
</dict>
<key>SuppressBuildableAutocreation</key>
<dict>
<key>15BBDEF81D61AD5B0098330F</key>
<dict>
<key>primary</key>
<true/>
</dict>
<key>15BBDF021D61AD5B0098330F</key>
<dict>
<key>primary</key>
<true/>
</dict>
</dict>
</dict>
</plist>
33 changes: 33 additions & 0 deletions PTFakeTouch/FixCategoryBug.h
@@ -0,0 +1,33 @@
//
// FixCategoryBug.h
// FakeTouch
//
// Created by 唐炫 on 16/4/7.
// Copyright © 2016年 唐炫. All rights reserved.
//

#ifndef MainLib_FixCategoryBug_h
#define MainLib_FixCategoryBug_h

#define __kw_to_string_1(x) #x
#define __kw_to_string(x) __kw_to_string_1(x)

// 需要在有category的头文件中调用,例如 KW_FIX_CATEGORY_BUG_H(NSString_Extented)
#define KW_FIX_CATEGORY_BUG_H(name) \
@interface KW_FIX_CATEGORY_BUG_##name : NSObject \
+(void)print; \
@end

// 需要在有category的源文件中调用,例如 KW_FIX_CATEGORY_BUG_M(NSString_Extented)
#define KW_FIX_CATEGORY_BUG_M(name) \
@implementation KW_FIX_CATEGORY_BUG_##name \
+ (void)print { \
NSLog(@"[Enable]"); \
} \
@end \


// 在target中启用这个宏,其实就是调用下category中定义的类的print方法。
#define KW_ENABLE_CATEGORY(name) [KW_FIX_CATEGORY_BUG_##name print]

#endif
26 changes: 26 additions & 0 deletions PTFakeTouch/Info.plist
@@ -0,0 +1,26 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>en</string>
<key>CFBundleExecutable</key>
<string>$(EXECUTABLE_NAME)</string>
<key>CFBundleIdentifier</key>
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>$(PRODUCT_NAME)</string>
<key>CFBundlePackageType</key>
<string>FMWK</string>
<key>CFBundleShortVersionString</key>
<string>1.0</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>$(CURRENT_PROJECT_VERSION)</string>
<key>NSPrincipalClass</key>
<string></string>
</dict>
</plist>
30 changes: 30 additions & 0 deletions PTFakeTouch/PTFakeMetaTouch.h
@@ -0,0 +1,30 @@
//
// HJFakeMetaTouch.h
// HJFakeTouch
//
// Created by 唐炫 on 16/4/20.
// Copyright © 2016年 唐炫. All rights reserved.
//

#import <Foundation/Foundation.h>
#import <UIKit/UIKit.h>

@interface HJFakeMetaTouch : NSObject
/**
* 构造一个触屏基础操作
*
* @param pointId 触屏操作的序列号
* @param point 操作的目的位置
* @param phase 操作的类别
*
* @return 返回操作的序列号
*/
+ (NSInteger)fakeTouchId:(NSInteger)pointId AtPoint:(CGPoint)point withTouchPhase:(UITouchPhase)phase;
/**
* 获取一个没有使用过的触屏序列号
*
* @return 返回序列号
*/
+ (NSInteger)getAvailablePointId;

@end
87 changes: 87 additions & 0 deletions PTFakeTouch/PTFakeMetaTouch.m
@@ -0,0 +1,87 @@
//
// HJFakeMetaTouch.m
// HJFakeTouch
//
// Created by 唐炫 on 16/4/20.
// Copyright © 2016年 唐炫. All rights reserved.
//

#import "PTFakeMetaTouch.h"
#import "UITouch-KIFAdditions.h"
#import "UIApplication-KIFAdditions.h"
#import "UIEvent+KIFAdditions.h"
static NSMutableArray *touchAry;
@implementation HJFakeMetaTouch

+ (void)load{
KW_ENABLE_CATEGORY(UITouch_KIFAdditions);
KW_ENABLE_CATEGORY(UIEvent_KIFAdditions);
touchAry = [[NSMutableArray alloc] init];
for (NSInteger i = 0; i<100; i++) {
UITouch *touch = [[UITouch alloc] initTouch];
[touch setPhaseAndUpdateTimestamp:UITouchPhaseEnded];
[touchAry addObject:touch];
}
}

//构造触屏操作
+ (NSInteger)fakeTouchId:(NSInteger)pointId AtPoint:(CGPoint)point withTouchPhase:(UITouchPhase)phase{
//DLog(@"4. fakeTouchId , phase : %ld ",(long)phase);
if (pointId==0) {
//随机一个没有使用的pointId
pointId = [self getAvailablePointId];
if (pointId==0) {
DLog(@"FakeTouch---pointId 耗尽");
return 0;
}
}
pointId = pointId - 1;
UITouch *touch = [touchAry objectAtIndex:pointId];
if (phase == UITouchPhaseBegan) {
touch = nil;
touch = [[UITouch alloc] initAtPoint:point inWindow:[UIApplication sharedApplication].keyWindow];
[touchAry replaceObjectAtIndex:pointId withObject:touch];
[touch setLocationInWindow:point];
}else{
[touch setLocationInWindow:point];
[touch setPhaseAndUpdateTimestamp:phase];
}



UIEvent *event = [self eventWithTouches:touchAry];
[[UIApplication sharedApplication] sendEvent:event];
if ((touch.phase==UITouchPhaseBegan)||touch.phase==UITouchPhaseMoved) {
[touch setPhaseAndUpdateTimestamp:UITouchPhaseStationary];
}
return (pointId+1);
}


+ (UIEvent *)eventWithTouches:(NSArray *)touches
{
// _touchesEvent is a private selector, interface is exposed in UIApplication(KIFAdditionsPrivate)
UIEvent *event = [[UIApplication sharedApplication] _touchesEvent];
[event _clearTouches];
[event kif_setEventWithTouches:touches];

for (UITouch *aTouch in touches) {
[event _addTouch:aTouch forDelayedDelivery:NO];
}

return event;
}

+ (NSInteger)getAvailablePointId{
NSInteger availablePointId=0;
NSMutableArray *availableIds = [[NSMutableArray alloc]init];
for (NSInteger i=0; i<touchAry.count-50; i++) {
UITouch *touch = [touchAry objectAtIndex:i];
if (touch.phase==UITouchPhaseEnded||touch.phase==UITouchPhaseStationary) {
[availableIds addObject:@(i+1)];
}
}
availablePointId = availableIds.count==0 ? 0 : [[availableIds objectAtIndex:(arc4random() % availableIds.count)] integerValue];
return availablePointId;
}
@end
27 changes: 27 additions & 0 deletions PTFakeTouch/PTFakeTouch.h
@@ -0,0 +1,27 @@
//
// FakeTouch.h
// FakeTouch
//
// Created by 唐炫 on 16/4/7.
// Copyright © 2016年 唐炫. All rights reserved.
//

#import <UIKit/UIKit.h>


//! Project version number for HJGameController.
FOUNDATION_EXPORT double HJGameControllerVersionNumber;

//! Project version string for HJGameController.
FOUNDATION_EXPORT const unsigned char HJGameControllerVersionString[];

// In this header, you should import all the public headers of your framework using statements like #import <HJGameController/PublicHeader.h>
#import <PTFakeTouch/PTFakeMetaTouch.h>

#ifdef DEBUG
#define RLog(fmt, ...)
#define DLog(fmt, ...) NSLog((@"HJhelper " fmt), ##__VA_ARGS__);
#else
#define DLog(fmt, ...)
#define RLog(fmt, ...) NSLog((@"HJhelper " fmt), ##__VA_ARGS__);
#endif
31 changes: 31 additions & 0 deletions PTFakeTouch/addition/CALayer-KIFAdditions.h
@@ -0,0 +1,31 @@
//
// CALayer-KIFAdditions.h
// Pods
//
// Created by Radu Ciobanu on 28/01/2016.
// Licensed to Square, Inc. under one or more contributor license agreements.
// See the LICENSE file distributed with this work for the terms under
// which Square, Inc. licenses this file to you.
//

#import <QuartzCore/QuartzCore.h>

@interface CALayer (KIFAdditions)

/**
* @method hasAnimations
* @abstract Traverses self's hierarchy of layers and checks whether any
* visible sublayers or self have ongoing anymations.
* @return YES if an animated layer has been found, NO otherwise.
*/
- (BOOL)hasAnimations;

/*!
@method performBlockOnDescendentLayers:
@abstract Calls a block on the layer itself and on all its descendent layers.
@param block The block that will be called on the layers. Stop the traversation
of the layers by assigning YES to the stop-parameter of the block.
*/
- (void)performBlockOnDescendentLayers:(void (^)(CALayer *layer, BOOL *stop))block;

@end

0 comments on commit 2a10535

Please sign in to comment.