iOS触摸事件通知(专用API)
在后台使用CTTelephoncEnterAddObserver和CFNotificationCenterAddObserver时,您可以接收各种系统范围的通知,例如:iOS触摸事件通知(专用API),ios,jailbreak,iphone-privateapi,Ios,Jailbreak,Iphone Privateapi,在后台使用CTTelephoncEnterAddObserver和CFNotificationCenterAddObserver时,您可以接收各种系统范围的通知,例如: 不过,我还没有找到一种在后台获得联系通知的方法。是否存在可与CFNotificationCenterAddObserver一起使用的“触摸事件”、可使用的不同通知中心或完全不同的方法 我会很高兴与低层次的触摸信息(如x,y坐标和触摸类型),但更高层次的信息(如按键按下,返回按钮按下等)将更好 您可以使用IOKit中的IO
我会很高兴与低层次的触摸信息(如x,y坐标和触摸类型),但更高层次的信息(如按键按下,返回按钮按下等)将更好 您可以使用IOKit中的IOHID工具来获取x,y坐标
#include <IOHIDEventSystem.h>
寄存器回调:
IOHIDEventSystemClientScheduleWithRunLoop(ioHIDEventSystem, CFRunLoopGetCurrent(), kCFRunLoopDefaultMode);
IOHIDEventSystemClientRegisterEventCallback(ioHIDEventSystem, handle_event, NULL, NULL);
IOHIDEventSystemClientUnregisterEventCallback(ioHIDEventSystem, handle_event, NULL, NULL);
IOHIDEventSystemClientUnscheduleWithRunLoop(ioHIDEventSystem, CFRunLoopGetCurrent(), kCFRunLoopDefaultMode);
取消注册回调:
IOHIDEventSystemClientScheduleWithRunLoop(ioHIDEventSystem, CFRunLoopGetCurrent(), kCFRunLoopDefaultMode);
IOHIDEventSystemClientRegisterEventCallback(ioHIDEventSystem, handle_event, NULL, NULL);
IOHIDEventSystemClientUnregisterEventCallback(ioHIDEventSystem, handle_event, NULL, NULL);
IOHIDEventSystemClientUnscheduleWithRunLoop(ioHIDEventSystem, CFRunLoopGetCurrent(), kCFRunLoopDefaultMode);
回拨:
IOHIDEventSystemClientScheduleWithRunLoop(ioHIDEventSystem, CFRunLoopGetCurrent(), kCFRunLoopDefaultMode);
IOHIDEventSystemClientRegisterEventCallback(ioHIDEventSystem, handle_event, NULL, NULL);
IOHIDEventSystemClientUnregisterEventCallback(ioHIDEventSystem, handle_event, NULL, NULL);
IOHIDEventSystemClientUnscheduleWithRunLoop(ioHIDEventSystem, CFRunLoopGetCurrent(), kCFRunLoopDefaultMode);
void handle_event (void* target, void* refcon, IOHIDServiceRef service, IOHIDEventRef event) {
if (IOHIDEventGetType(event)==kIOHIDEventTypeDigitizer){
IOHIDFloat x=IOHIDEventGetFloatValue(event, (IOHIDEventField)kIOHIDEventFieldDigitizerX);
IOHIDFloat y=IOHIDEventGetFloatValue(event, (IOHIDEventField)kIOHIDEventFieldDigitizerY);
int width = [[UIScreen mainScreen] bounds].size.width;
int height = [[UIScreen mainScreen] bounds].size.height;
NSLog(@"click : %f, %f", x*width, y*height) ;
}
}
此外,您还可以查看以下内容:
.
希望这有帮助
编辑:请查看日志中的结果。在iPhone4和5上测试
void handle_event (void* target, void* refcon, IOHIDServiceRef service, IOHIDEventRef event) {
NSLog(@"handle_event : %d", IOHIDEventGetType(event));
if (IOHIDEventGetType(event)==kIOHIDEventTypeDigitizer){
IOHIDFloat x=IOHIDEventGetFloatValue(event, (IOHIDEventField)kIOHIDEventFieldDigitizerX);
IOHIDFloat y=IOHIDEventGetFloatValue(event, (IOHIDEventField)kIOHIDEventFieldDigitizerY);
NSLog(@" x %f : y %f", x, y);
//2013-03-28 10:02:52.169 MyIOKit[143:907] handle_event : 11
//2013-03-28 10:02:52.182 MyIOKit[143:907] x 0.766754 : y 0.555023
}
}
也许这对你有帮助。还可以搜索
GSEvents
Awesome!我得到了事件,但是我的x,y值是巨大的,例如:1050201600.000000,1052667392.000000。有什么提示吗?你在乘法之前检查过x和y吗?我现在不在我的Mac电脑前,但据我记忆所及,我从%得到了x和y。如果你触摸右上角,x=0.9,y=0.1。是的,巨大的数字是x,y,不相乘。好的。当我有mac电脑时,我会给你回复。在iOS6上,我仍然看到巨大的值,例如:x 1064502784.000000:y 1034551296.000000:(