-
Notifications
You must be signed in to change notification settings - Fork 55
/
TargetMouseScroll.m
35 lines (28 loc) · 954 Bytes
/
TargetMouseScroll.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
//
// TargetMouseScroll.m
// Enjoy
//
// Created by Yifeng Huang on 7/28/12.
// Copyright (c) 2012 __MyCompanyName__. All rights reserved.
//
#import "TargetMouseScroll.h"
@implementation TargetMouseScroll
@synthesize howMuch;
-(NSString*) stringify {
return [[NSString alloc] initWithFormat: @"mscroll~%d", howMuch];
}
+(TargetMouseScroll*) unstringifyImpl: (NSArray*) comps {
NSParameterAssert([comps count] == 2);
TargetMouseScroll* target = [[TargetMouseScroll alloc] init];
[target setHowMuch: [[comps objectAtIndex:1] integerValue]];
return target;
}
-(void) trigger: (JoystickController *)jc {
CGEventRef scroll = CGEventCreateScrollWheelEvent(NULL,
kCGScrollEventUnitLine,
1,
[self howMuch]);
CGEventPost(kCGHIDEventTap, scroll);
CFRelease(scroll);
}
@end