X-Git-Url: https://git.yukkurigames.com/?p=enjoyable.git;a=blobdiff_plain;f=TargetMouseScroll.m;h=d840ba1069bfe2539a50cbd44d79e8d7bda40dd2;hp=a1cca9c94d926816c95e8106f5c25cc7345f0bd7;hb=681ca0346ecb3f3da2c45a1a470601f15aad22cf;hpb=61f8cdec21ab083b29c22aa11fda54d6005666ca diff --git a/TargetMouseScroll.m b/TargetMouseScroll.m index a1cca9c..d840ba1 100644 --- a/TargetMouseScroll.m +++ b/TargetMouseScroll.m @@ -3,31 +3,31 @@ // Enjoy // // Created by Yifeng Huang on 7/28/12. -// Copyright (c) 2012 __MyCompanyName__. All rights reserved. // #import "TargetMouseScroll.h" @implementation TargetMouseScroll -@synthesize howMuch; ++ (NSString *)serializationCode { + return @"mscroll"; +} --(NSString*) stringify { - return [[NSString alloc] initWithFormat: @"mscroll~%d", howMuch]; +- (NSDictionary *)serialize { + return @{ @"type": @"mscroll", @"amount": @(_amount) }; } -+(TargetMouseScroll*) unstringifyImpl: (NSArray*) comps { - NSParameterAssert([comps count] == 2); - TargetMouseScroll* target = [[TargetMouseScroll alloc] init]; - [target setHowMuch: [[comps objectAtIndex:1] integerValue]]; ++ (Target *)targetDeserialize:(NSDictionary *)serialization + withConfigs:(NSArray *)configs { + TargetMouseScroll *target = [[TargetMouseScroll alloc] init]; + target.amount = [serialization[@"amount"] intValue]; return target; } - --(void) trigger: (JoystickController *)jc { +-(void) trigger { CGEventRef scroll = CGEventCreateScrollWheelEvent(NULL, kCGScrollEventUnitLine, 1, - [self howMuch]); + _amount); CGEventPost(kCGHIDEventTap, scroll); CFRelease(scroll); }