X-Git-Url: https://git.yukkurigames.com/?p=enjoyable.git;a=blobdiff_plain;f=NJOutputMouseButton.m;fp=NJOutputMouseButton.m;h=0000000000000000000000000000000000000000;hp=d5b1f16e940baade744c9dddcaed2699decf49a3;hb=0064c1fbff36795885a9724081af2a17d83c20a3;hpb=56d825ba259066d847a9fc3f9c8c0c0a362a1507 diff --git a/NJOutputMouseButton.m b/NJOutputMouseButton.m deleted file mode 100644 index d5b1f16..0000000 --- a/NJOutputMouseButton.m +++ /dev/null @@ -1,51 +0,0 @@ -// -// NJOutputMouseButton.m -// Enjoy -// -// Created by Yifeng Huang on 7/27/12. -// - -#import "NJOutputMouseButton.h" - -@implementation NJOutputMouseButton - -+ (NSString *)serializationCode { - return @"mouse button"; -} - -- (NSDictionary *)serialize { - return @{ @"type": self.class.serializationCode, @"button": @(_button) }; -} - -+ (NJOutput *)outputDeserialize:(NSDictionary *)serialization - withMappings:(NSArray *)mappings { - NJOutputMouseButton *output = [[NJOutputMouseButton alloc] init]; - output.button = [serialization[@"button"] intValue]; - return output; -} - -- (void)trigger { - CGFloat height = NSScreen.mainScreen.frame.size.height; - NSPoint mouseLoc = NSEvent.mouseLocation; - CGEventType eventType = (_button == kCGMouseButtonLeft) ? kCGEventLeftMouseDown : kCGEventRightMouseDown; - CGEventRef click = CGEventCreateMouseEvent(NULL, - eventType, - CGPointMake(mouseLoc.x, height - mouseLoc.y), - _button); - CGEventPost(kCGHIDEventTap, click); - CFRelease(click); -} - -- (void)untrigger { - CGFloat height = NSScreen.mainScreen.frame.size.height; - NSPoint mouseLoc = NSEvent.mouseLocation; - CGEventType eventType = (_button == kCGMouseButtonLeft) ? kCGEventLeftMouseUp : kCGEventRightMouseUp; - CGEventRef click = CGEventCreateMouseEvent(NULL, - eventType, - CGPointMake(mouseLoc.x, height - mouseLoc.y), - _button); - CGEventPost(kCGHIDEventTap, click); - CFRelease(click); -} - -@end