TestsTested | ✗ |
LangLanguage | Obj-CObjective C |
License | MIT |
ReleasedLast Release | May 2015 |
Maintained by Mathew Huusko V.
Easily and (thread/memory) safely consume global OS X multitouch (trackpad, Magic Mouse) events.
Note: Requires ARC, and Mac OS 10.8+
M5MultitouchSupport/M5MultitouchSupport.xcodeproj
project, and build the default target.Products/M5MultitouchSupport.framework
to your project.M5MultitouchSupport/M5MultitouchSupport
folder into your project.Using M5MultitouchSupport
in your app or framework is as simple as...
#import <M5MultitouchSupport.h>
[M5MultitouchManager.sharedManager addListenerWithCallback:^(M5MultitouchEvent *event) {
NSLog(event.description);
/*
Touches: (
"ID: 3, State: 4 (Touching), Position: [0.251363, 0.475246], Velocity: [0.009912, -0.003619], Minor Axis: 8.160000, Major Axis: 9.920000, Angle: 1.911052, Size: 0.750000",
"ID: 6, State: 4 (Touching), Position: [0.618595, 0.839751], Velocity: [-0.007434, -0.014476], Minor Axis: 8.230000, Major Axis: 9.220000, Angle: 1.570796, Size: 0.625000",
"ID: 8, State: 4 (Touching), Position: [0.410051, 0.792415], Velocity: [0.008673, 0.018095], Minor Axis: 7.660000, Major Axis: 8.890000, Angle: 1.570796, Size: 0.628906"
), Device ID: 25381376, Frame ID: 1435, Timestamp: 3827.383000
*/
}];
Note: Multitouch event processing happens on a separate thread, but your listener will be passed events on the thread it was created (or the main thread if the original thread ever stops).
[M5MultitouchManager.sharedManager addListenerWithTarget:self
selector:@selector(handleMultitouchEvent:)];
- (void)handleMultitouchEvent:(M5MultitouchEvent *)event {
NSLog(event.description);
}
Note: Only a weak reference is held to the target, and M5MultitouchManager
will safely remove the listener if that reference zeroes out.
M5MultitouchListener *listener = [M5MultitouchManager.sharedManager addListenerWith...
listener.listening = NO;
//Listener will stop receiving events until set to YES
[M5MultitouchManager.sharedManager removeListener:listener];
//Will stop/remove the listener altogether
If you have feature requests or bug reports, feel free to help out by sending pull requests or by creating new issues.
M5MultitouchSupport
is brought to you by Mathew Huusko V and contributors to the project. If you're using M5MultitouchSupport
in your project, attribution would be very appreciated.