Skip to content
Browse files

osx 10.6 api, delay before restart, triple click and drag support

  • Loading branch information...
1 parent 08c1ca5 commit bdb2acce542dcbed85d062d5d2e6ff2dbf229c52 @cl3m cl3m committed Jan 21, 2010
Showing with 25 additions and 5 deletions.
  1. +22 −5 Controller.m
  2. +2 −0 WakeObserver.m
  3. +1 −0 main.m
View
27 Controller.m
@@ -73,15 +73,27 @@ int callback(int device, Finger *data, int nFingers, double timestamp, int frame
{
if(!pressed)
{
- CGPostKeyboardEvent( (CGCharCode)0, (CGKeyCode)55, true );
+ NSLog(@"Pressed");
+ #if __MAC_OS_X_VERSION_MIN_REQUIRED >= 1060
+ CGEventCreateKeyboardEvent(NULL, (CGKeyCode)55, true);
+ #else
+ CGPostKeyboardEvent( (CGCharCode)0, (CGKeyCode)55, true );
+ #endif
pressed = YES;
}
}
- else {
+
+ if(nFingers == 0) {
if(pressed)
{
- CGPostKeyboardEvent( (CGCharCode)0, (CGKeyCode)55, false );
+ NSLog(@"Released");
+ #if __MAC_OS_X_VERSION_MIN_REQUIRED >= 1060
+ CGEventCreateKeyboardEvent(NULL, (CGKeyCode)55, false);
+ #else
+ CGPostKeyboardEvent( (CGCharCode)0, (CGKeyCode)55, false );
+ #endif
+
pressed = NO;
}
}
@@ -108,8 +120,13 @@ int callback(int device, Finger *data, int nFingers, double timestamp, int frame
*/
// Real middle click
- CGPostMouseEvent( ourLoc, 1, 3, 0, 0, 1);
- CGPostMouseEvent( ourLoc, 1, 3, 0, 0, 0);
+ #if __MAC_OS_X_VERSION_MIN_REQUIRED >= 1060
+ CGEventPost (kCGHIDEventTap, CGEventCreateMouseEvent (NULL,kCGEventOtherMouseDown,ourLoc,kCGMouseButtonCenter));
+ CGEventPost (kCGHIDEventTap, CGEventCreateMouseEvent (NULL,kCGEventOtherMouseUp,ourLoc,kCGMouseButtonCenter));
+ #else
+ CGPostMouseEvent( ourLoc, 1, 3, 0, 0, 1);
+ CGPostMouseEvent( ourLoc, 1, 3, 0, 0, 0);
+ #endif
}
}
View
2 WakeObserver.m
@@ -11,6 +11,8 @@ @implementation WakeObserver
- (void) receiveWakeNote: (NSNotification*) note
{
+ [NSThread sleepForTimeInterval:10.0]; //wait 10 sec before restarting to be sure everthing is up
+
NSString *relaunch = [[[NSBundle mainBundle] resourcePath] stringByAppendingPathComponent:@"relaunch"];
int procid = [[NSProcessInfo processInfo] processIdentifier];
[NSTask launchedTaskWithLaunchPath:relaunch arguments:[NSArray arrayWithObjects:[[NSBundle mainBundle] bundlePath], [NSString stringWithFormat:@"%d",procid], nil]];
View
1 main.m
@@ -11,6 +11,7 @@
Controller *con;
int main(int argc, char *argv[]) {
+
con = [[Controller alloc] init];
[con start];

0 comments on commit bdb2acc

Please sign in to comment.
Something went wrong with that request. Please try again.