X-Git-Url: https://git.yukkurigames.com/?p=enjoyable.git;a=blobdiff_plain;f=TargetMouseScroll.m;h=6986004b4b7bac8c6f4e43c4cb2bca48a1f56452;hp=be64f7a2986c4e9824a0534ccd4d7dea6dec744f;hb=794561a4606fa9e31e3b2b077891f5b1e6084698;hpb=51ca12b552a9c17c4d4029b0340e193b273044a8 diff --git a/TargetMouseScroll.m b/TargetMouseScroll.m index be64f7a..6986004 100644 --- a/TargetMouseScroll.m +++ b/TargetMouseScroll.m @@ -10,24 +10,25 @@ @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[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); }