X-Git-Url: https://git.yukkurigames.com/?p=enjoyable.git;a=blobdiff_plain;f=TargetMouseMove.m;h=b1d52a01c1d881814a713831cc2cd243a779b8f8;hp=9deabccdc9a55c1217b83396bb027546687412cf;hb=e2a4d830dd9817f6a515a3b1b6aa152d3bb98c2b;hpb=681ca0346ecb3f3da2c45a1a470601f15aad22cf diff --git a/TargetMouseMove.m b/TargetMouseMove.m index 9deabcc..b1d52a0 100644 --- a/TargetMouseMove.m +++ b/TargetMouseMove.m @@ -7,7 +7,7 @@ #import "TargetMouseMove.h" -#import "JoystickController.h" +#import "NJInputController.h" @implementation TargetMouseMove { int sign; @@ -26,19 +26,19 @@ } + (Target *)targetDeserialize:(NSDictionary *)serialization - withConfigs:(NSArray *)configs { + withMappings:(NSArray *)mappings { TargetMouseMove *target = [[TargetMouseMove alloc] init]; target.axis = [serialization[@"axis"] intValue]; return target; } -- (BOOL)update:(JoystickController *)jc { +- (BOOL)update:(NJInputController *)jc { if (fabsf(self.magnitude) < 0.01) { sign = 0; return NO; // dead zone } - // If the action crossed over High/Low, this target is done. + // If the input crossed over High/Low, this target is done. if (!sign) sign = self.magnitude < 0 ? -1 : 1; else if (sign / self.magnitude < 0) { @@ -46,12 +46,11 @@ return NO; } - NSRect screenRect = [[NSScreen mainScreen] frame]; - CGFloat height = screenRect.size.height; + CGFloat height = NSScreen.mainScreen.frame.size.height; // TODO float speed = 4.f; - if ([jc frontWindowOnly]) + if (jc.frontWindowOnly) speed = 12.f; float dx = 0.f, dy = 0.f; if (_axis == 0) @@ -70,7 +69,7 @@ CGEventSetIntegerValueField(move, kCGMouseEventDeltaX, (int)dx); CGEventSetIntegerValueField(move, kCGMouseEventDeltaY, (int)dy); - if ([jc frontWindowOnly]) { + if (jc.frontWindowOnly) { ProcessSerialNumber psn; GetFrontProcess(&psn); CGEventPostToPSN(&psn, move);