What I want to achieve:
The target is to make a Mac OS X library - dylib/bundle/framework, that intercepts all mouse and keyboard events of the application that loaded the library. I just want to log these events, not change them. The library needs to have a C API that exposes the logged events' details.
What I have currently made:
I've implemented two ways for detecting the application's mouse and keyboard events from within the library that the application loads:
1) Installing an event handler using Carbon. For some reason using InstallApplicationEventHandler or InstallEventHandler( GetApplicationEventTarget(), ... ) didn't do the trick. It was only possible to catch all non-application events (all events except for those delivered to the target application that loads my library).
2) CGEventTaps: mouse (http://osxbook.com/book/bonus/chapter2/altermouse/) and keyboard (http://osxbook.com/book/bonus/chapter2/alterkeys/) ones. These work, but are system-wide. I want my library to catch only the events delivered to the application that has loaded it.
Does anyone know how to create application-wide keyboard and mouse hooks/taps, not system-wide ones?