Hi,
I am currently writing an application which simulates key press events in Mac OSX to control ioquake3. My current approach is to create the key press events with the Quartz Event Services. This works fine with e.g. TextEdit but not with ioquake3.
CGKeyCode keyCode = 126; // 126 is the "up" key
CGEventRef event1 = CGEventCreateKeyboardEvent (NULL, keyCode, true);
CGEventPost(kCGSessionEventTap, event1);
// CGEventPost(kCGHIDEventTap, event1);
// CGEventPost(kCGAnnotatedSessionEventTap, event1);
CFRelease(event1);
CGEventRef event2 = CGEventCreateKeyboardEvent (NULL, keyCode, false);
CGEventPost(kCGSessionEventTap, event2);
// CGEventPost(kCGHIDEventTap, event2);
// CGEventPost(kCGAnnotatedSessionEventTap, event2);
CFRelease(event2);
I also tried to use the following code to simulate the key presses as mentioned in this post:
CGKeyCode keyCode = 126; // 126 is the "up" key
AXUIElementRef axSystemWideElement = AXUIElementCreateSystemWide();
AXUIElementPostKeyboardEvent(axSystemWideElement, 0, keyCode, true);
AXUIElementPostKeyboardEvent(axSystemWideElement, 0, keyCode, false);
Is there another way to create key press events in Mac OSX which are recognized by ioquake3?