Created
April 15, 2015 09:01
-
-
Save jontelang/3d82421ae74e452c885a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void KTouchPointerWindowInstall(); | |
void KTouchPointerWindowUninstall(); | |
static BOOL installed; | |
void KTouchPointerWindowInstall() | |
{ | |
if (!installed) { | |
installed = YES; | |
Class _class = [UIWindow class]; | |
Method orig = class_getInstanceMethod(_class, sel_registerName("sendEvent:")); | |
Method my = class_getInstanceMethod(_class, sel_registerName("k_sendEvent:")); | |
method_exchangeImplementations(orig, my); | |
} | |
} | |
void KTouchPointerWindowUninstall() | |
{ | |
if (installed) { | |
installed = NO; | |
Class _class = [UIWindow class]; | |
Method orig = class_getInstanceMethod(_class, sel_registerName("sendEvent:")); | |
Method my = class_getInstanceMethod(_class, sel_registerName("k_sendEvent:")); | |
method_exchangeImplementations(orig, my); | |
NSArray *windows = [[UIApplication sharedApplication] windows]; | |
[windows makeObjectsPerformSelector:@selector(setNeedsDisplay)]; | |
} | |
} | |
@interface UIWindow (KTouchPointerWindow) | |
@end | |
@implementation UIWindow (KTouchPointerWindow) | |
-(void) k_sendEvent:(UIEvent *)event | |
{ | |
NSMutableSet *began = nil; | |
NSMutableSet *moved = nil; | |
NSMutableSet *ended = nil; | |
NSMutableSet *cancelled = nil; | |
for (UITouch *touch in [event allTouches]) { | |
switch (touch.phase) { | |
case UITouchPhaseBegan: | |
if (!began) { | |
began = [NSMutableSet set]; | |
} | |
[began addObject:touch]; | |
break; | |
case UITouchPhaseEn.... | |
... | |
... | |
} | |
} | |
NSLog(@"event"); | |
[self k_sendEvent:event]; | |
} | |
@end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment