Skip to content

Commit

Permalink
[1.7-14] occur event timer, fix crash when screen is off
Browse files Browse the repository at this point in the history
  • Loading branch information
iolate committed Feb 8, 2014
1 parent 16640e6 commit f953cae
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
15 changes: 14 additions & 1 deletion SimulateTouch.mm
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,10 @@ - (unsigned int)taskPortOfContextId:(unsigned int)arg1; //New!

@interface BKUserEventTimer
+ (id)sharedInstance;
- (void)userEventOccurred;
- (void)userEventOccurred; //iOS6
- (void)userEventOccurredOnDisplay:(id)arg1; //iOS7

-(BOOL)respondsToSelector:(SEL)selector;
@end

@interface BKHIDSystemInterface
Expand Down Expand Up @@ -250,9 +253,19 @@ static void SendTouchesEvent(mach_port_t port) {
IOHIDEventSetIntegerValueWithOptions(handEvent, kIOHIDEventFieldDigitizerTouch, handEventTouch, -268435456);
//IOHIDEventSetIntegerValueWithOptions(handEvent, kIOHIDEventFieldDigitizerIndex, (1<<22) + (int)pow(2.0, (double)(touchingCount+1)) - 2, -268435456);

BKUserEventTimer* etimer = [NSClassFromString(@"BKUserEventTimer") sharedInstance];

if ([etimer respondsToSelector:@selector(userEventOccurred)]) {
[etimer userEventOccurred];
}else if ([etimer respondsToSelector:@selector(userEventOccurredOnDisplay:)]) {
[etimer userEventOccurredOnDisplay:nil];
}

if (iOS7) {
id manager = [objc_getClass("BKAccessibility") _eventRoutingClientConnectionManager];
IOHIDEventSystemConnectionRef systemConnection = [manager clientForTaskPort:port];
if (systemConnection == nil) return;

_IOHIDEventSystemConnectionDispatchEvent(systemConnection, handEvent);
}else {
original_callback(NULL, NULL, NULL, handEvent);
Expand Down
2 changes: 1 addition & 1 deletion private-headers

0 comments on commit f953cae

Please sign in to comment.