Clean up a bunch of properties; remove unused ones, use automatic ones where possible...
[enjoyable.git] / TargetMouseScroll.m
1 //
2 // TargetMouseScroll.m
3 // Enjoy
4 //
5 // Created by Yifeng Huang on 7/28/12.
6 // Copyright (c) 2012 __MyCompanyName__. All rights reserved.
7 //
8
9 #import "TargetMouseScroll.h"
10
11 @implementation TargetMouseScroll
12
13 + (NSString *)serializationCode {
14 return @"mscroll";
15 }
16
17 - (NSDictionary *)serialize {
18 return @{ @"type": @"mscroll", @"amount": @(_amount) };
19 }
20
21 + (Target *)targetDeserialize:(NSDictionary *)serialization
22 withConfigs:(NSArray *)configs {
23 TargetMouseScroll *target = [[TargetMouseScroll alloc] init];
24 target.amount = [serialization[@"amount"] intValue];
25 return target;
26 }
27 -(void) trigger {
28 CGEventRef scroll = CGEventCreateScrollWheelEvent(NULL,
29 kCGScrollEventUnitLine,
30 1,
31 _amount);
32 CGEventPost(kCGHIDEventTap, scroll);
33 CFRelease(scroll);
34 }
35
36 @end