kbd = qkbd_state_init(dcl.con);
}
+
+ CGEventMask mask = CGEventMaskBit(kCGEventKeyDown) |
CGEventMaskBit(kCGEventKeyUp) | CGEventMaskBit(kCGEventFlagsChanged);
+ eventsTap = CGEventTapCreate(kCGHIDEventTap, kCGHeadInsertEventTap,
kCGEventTapOptionDefault,
+ mask, handleTapEvent, self);
+ if (!eventsTap) {
+ warn_report("Could not create event tap, system key combos will not be
captured.\n");
+ return self;
+ } else {
+ COCOA_DEBUG("Global events tap created! Will capture system key
combos.\n");
+ }
+
+ CFRunLoopRef runLoop = CFRunLoopGetCurrent();
+ if (!runLoop) {
+ warn_report("Could not obtain current CF RunLoop, system key combos will
not be captured.\n");
+ return self;
+ }
+
+ CFRunLoopSourceRef tapEventsSrc =
CFMachPortCreateRunLoopSource(kCFAllocatorDefault, eventsTap, 0);
+ if (!tapEventsSrc ) {
+ warn_report("Could not obtain current CF RunLoop, system key combos will
not be captured.\n");
+ return self;
+ }
+
+ CFRunLoopAddSource(runLoop, tapEventsSrc, kCFRunLoopDefaultMode);
+ CFRelease(tapEventsSrc);
+
return self;
}