I want to receive x, y coordinates of a touch. I've tried this solution, but it doesn't seem to work for IOS 7. I get the following error:
Tweak.xm:96:2: error: no matching function for call to 'IOHIDEventSystemClientScheduleWithRunLoop' IOHIDEventSystemClientScheduleWithRunLoop(ioHIDEventSystem, CFRu... ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /home/agiera/theosprojects/phoneit/theos/include/IOKit/hid/IOHIDEventSystemClient.h:72:7: note: candidate function not viable: cannot convert argument of incomplete type 'void *' to 'IOHIDEventSystemClientRef' (aka '__IOHIDEventSystemClient *') void IOHIDEventSystemClientScheduleWithRunLoop(IOHIDEventSystemC... ^ Tweak.xm:97:2: error: no matching function for call to 'IOHIDEventSystemClientRegisterEventCallback' IOHIDEventSystemClientRegisterEventCallback(ioHIDEventSystem, ha... ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /home/agiera/theosprojects/phoneit/theos/include/IOKit/hid/IOHIDEventSystemClient.h:68:7: note: candidate function not viable: cannot convert argument of incomplete type 'void *' to 'IOHIDEventSystemClientRef' (aka '__IOHIDEventSystemClient *') void IOHIDEventSystemClientRegisterEventCallback(IOHIDEventSyste... ^ 2 errors generated.
Is there an updated implementation or another means to get this functionality for IOS 7?
edit:
code:
#include <IOKit/hid/IOHIDEventSystem.h>
#include <IOKit/hid/IOHIDEventSystemClient.h>
#include <stdio.h>
//Touch Events
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);
}
}
static void initTouchEventHandling() {
void *ioHIDEventSystem = IOHIDEventSystemClientCreate(kCFAllocatorDefault);
IOHIDEventSystemClientScheduleWithRunLoop(ioHIDEventSystem, CFRunLoopGetCurrent(), kCFRunLoopDefaultMode);
IOHIDEventSystemClientRegisterEventCallback(ioHIDEventSystem, handle_event, NULL, NULL);
IOHIDEventSystemClientUnregisterEventCallback(ioHIDEventSystem, handle_event, NULL, NULL);
IOHIDEventSystemClientUnscheduleWithRunLoop(ioHIDEventSystem, CFRunLoopGetCurrent(), kCFRunLoopDefaultMode);
}
initTouchEventHandling is called in my constructor. I added IOKit to my private frame works and implemented this fix.
edit2:
I think there is something wrong with the way I am adding the IOKit framework. I tried swapping it for an older version and got the same errors. Then I tried deleting it altogether and got the same errors. Maybe someone can correct something in my makefile:
ARCHS = armv7 arm64
TARGET = iphone:clang:latest:7.0
export THEOS_DEVICE_IP = 192.168.1.104
include theos/makefiles/common.mk
TWEAK_NAME = phoneit
phoneit_FILES = Tweak.xm
phoneit_FRAMEWORKS = UIKit QuartzCore
phoneit_PRIVATE_FRAMEWORKS = IOKit
include $(THEOS_MAKE_PATH)/tweak.mk
after-install::
install.exec "killall -9 SpringBoard"
SUBPROJECTS += prefs
include $(THEOS_MAKE_PATH)/aggregate.mk