diff options
| -rw-r--r-- | Low Battery Yup d.xcodeproj/project.pbxproj | 7 | ||||
| -rw-r--r-- | Low Battery Yup d/AppDelegate.m | 4 | ||||
| -rw-r--r-- | Low Battery Yup d/Mouse.h | 19 | ||||
| -rw-r--r-- | Low Battery Yup d/Mouse.m | 44 | 
4 files changed, 73 insertions, 1 deletions
| diff --git a/Low Battery Yup d.xcodeproj/project.pbxproj b/Low Battery Yup d.xcodeproj/project.pbxproj index 2b3e708..a123364 100644 --- a/Low Battery Yup d.xcodeproj/project.pbxproj +++ b/Low Battery Yup d.xcodeproj/project.pbxproj @@ -13,6 +13,7 @@  		D18C94B31DDC33CF00E03F87 /* Credits.rtf in Resources */ = {isa = PBXBuildFile; fileRef = D18C94B11DDC33CF00E03F87 /* Credits.rtf */; };  		D18C94B61DDC33CF00E03F87 /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = D18C94B51DDC33CF00E03F87 /* AppDelegate.m */; };  		D18C94B91DDC33CF00E03F87 /* MainMenu.xib in Resources */ = {isa = PBXBuildFile; fileRef = D18C94B71DDC33CF00E03F87 /* MainMenu.xib */; }; +		D18C94C51DDC355400E03F87 /* Mouse.m in Sources */ = {isa = PBXBuildFile; fileRef = D18C94C41DDC355400E03F87 /* Mouse.m */; };  /* End PBXBuildFile section */  /* Begin PBXFileReference section */ @@ -29,6 +30,8 @@  		D18C94B41DDC33CF00E03F87 /* AppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = "<group>"; };  		D18C94B51DDC33CF00E03F87 /* AppDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = "<group>"; };  		D18C94B81DDC33CF00E03F87 /* en */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = en; path = en.lproj/MainMenu.xib; sourceTree = "<group>"; }; +		D18C94C31DDC355400E03F87 /* Mouse.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Mouse.h; sourceTree = "<group>"; }; +		D18C94C41DDC355400E03F87 /* Mouse.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = Mouse.m; sourceTree = "<group>"; };  /* End PBXFileReference section */  /* Begin PBXFrameworksBuildPhase section */ @@ -84,6 +87,8 @@  			children = (  				D18C94B41DDC33CF00E03F87 /* AppDelegate.h */,  				D18C94B51DDC33CF00E03F87 /* AppDelegate.m */, +				D18C94C31DDC355400E03F87 /* Mouse.h */, +				D18C94C41DDC355400E03F87 /* Mouse.m */,  				D18C94B71DDC33CF00E03F87 /* MainMenu.xib */,  				D18C94A91DDC33CF00E03F87 /* Supporting Files */,  			); @@ -168,6 +173,7 @@  			files = (  				D18C94AF1DDC33CF00E03F87 /* main.m in Sources */,  				D18C94B61DDC33CF00E03F87 /* AppDelegate.m in Sources */, +				D18C94C51DDC355400E03F87 /* Mouse.m in Sources */,  			);  			runOnlyForDeploymentPostprocessing = 0;  		}; @@ -295,6 +301,7 @@  				D18C94BE1DDC33CF00E03F87 /* Release */,  			);  			defaultConfigurationIsVisible = 0; +			defaultConfigurationName = Release;  		};  /* End XCConfigurationList section */  	}; diff --git a/Low Battery Yup d/AppDelegate.m b/Low Battery Yup d/AppDelegate.m index 37178d4..d599f8a 100644 --- a/Low Battery Yup d/AppDelegate.m +++ b/Low Battery Yup d/AppDelegate.m @@ -7,6 +7,7 @@  //  #import "AppDelegate.h" +#import "Mouse.h"  @implementation AppDelegate @@ -17,7 +18,8 @@  - (void)applicationDidFinishLaunching:(NSNotification *)aNotification  { -	// Insert code here to initialize your application +	Mouse *m = [[Mouse alloc] init]; +	[m moveToCenter];  }  @end diff --git a/Low Battery Yup d/Mouse.h b/Low Battery Yup d/Mouse.h new file mode 100644 index 0000000..950f9c1 --- /dev/null +++ b/Low Battery Yup d/Mouse.h @@ -0,0 +1,19 @@ +// +//  Mouse.h +//  Low Battery Yup d +// +//  Created by TW on 11/16/16. +//  Copyright (c) 2016 TW. All rights reserved. +// + +#import <Foundation/Foundation.h> + +@interface Mouse : NSObject { +	CGDirectDisplayID _current_display; +} + +- (void)moveToPoint:(CGPoint)point; +- (void)moveToCenter; +- (void)click; + +@end diff --git a/Low Battery Yup d/Mouse.m b/Low Battery Yup d/Mouse.m new file mode 100644 index 0000000..ead9010 --- /dev/null +++ b/Low Battery Yup d/Mouse.m @@ -0,0 +1,44 @@ +// +//  Mouse.m +//  Low Battery Yup d +// +//  Created by TW on 11/16/16. +//  Copyright (c) 2016 TW. All rights reserved. +// + +#import "Mouse.h" + +@implementation Mouse + +- (id)init +{ +    self = [super init]; +    if (self) { +        _current_display = CGMainDisplayID(); +    } +    return self; +} + +- (void)moveToPoint:(CGPoint)point +{ +	CGDisplayMoveCursorToPoint(_current_display, point); +} + +- (void)moveToCenter +{ +	CGPoint point; + +	size_t width = CGDisplayPixelsWide(_current_display); +	size_t height = CGDisplayPixelsHigh(_current_display); + +	point.x = width / 2; +	point.y = height / 2; + +	[self moveToPoint:point]; +} + +- (void)click +{ +} + +@end | 
