X-Git-Url: https://git.yukkurigames.com/?p=enjoyable.git;a=blobdiff_plain;f=TargetMouseScroll.m;fp=TargetMouseScroll.m;h=a1cca9c94d926816c95e8106f5c25cc7345f0bd7;hp=0000000000000000000000000000000000000000;hb=61f8cdec21ab083b29c22aa11fda54d6005666ca;hpb=ac4ed3987b6aaefc836294f89ff1f569fad6ac6b diff --git a/TargetMouseScroll.m b/TargetMouseScroll.m new file mode 100644 index 0000000..a1cca9c --- /dev/null +++ b/TargetMouseScroll.m @@ -0,0 +1,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