diff options
| -rw-r--r-- | .gitignore | 1 | ||||
| -rw-r--r-- | Invert.h | 7 | ||||
| -rw-r--r-- | Invert.m | 10 | ||||
| -rw-r--r-- | Makefile | 44 | ||||
| -rw-r--r-- | main.m | 30 | 
5 files changed, 88 insertions, 4 deletions
| diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..84c048a --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +/build/ diff --git a/Invert.h b/Invert.h new file mode 100644 index 0000000..c84685e --- /dev/null +++ b/Invert.h @@ -0,0 +1,7 @@ +#import <Cocoa/Cocoa.h> + +@interface Invert : NSObject + +- (void)toggleInvertColors:(NSEvent *)event; + +@end diff --git a/Invert.m b/Invert.m new file mode 100644 index 0000000..a41eb46 --- /dev/null +++ b/Invert.m @@ -0,0 +1,10 @@ +#import "Invert.h" + +@implementation Invert + +- (void)toggleInvertColors:(NSEvent *)event +{ +    NSLog(@"Toggling"); +} + +@end @@ -1,2 +1,42 @@ -all: -	clang -x objective-c -framework CoreGraphics -o invert-catalina-invert main.m +# SOURCES := $(shell find . -not -path './lib/*' -and \( -name '*.h' -or -name '*.m' \)) +SOURCES := $(shell ls *.{h,m}) + +DDHOTKEY_OBJ := $(patsubst %.m,%.o,$(wildcard lib/DDHotKey/*.m)) + + +all: $(SOURCES) build/libddhotkey.a build/include/*.h +	clang -x objective-c \ +		-framework Carbon \ +		-framework Cocoa \ +		-framework CoreGraphics \ +		-framework Foundation \ +		-fno-objc-arc \ +		-I./build/include \ +		-L./build \ +		-lddhotkey \ +		-o invert-catalina-invert \ +		$(SOURCES) + +build/include/*.h: lib/DDHotKey/*.h +	cp $^ build/include/ + +# build/libddhotkey.o: lib/DDHotKey/*.h lib/DDHotKey/*.m +lib/DDHotKey/%.o: lib/DDHotKey/%.m +	clang -x objective-c \ +		-w \ +		-framework Carbon \ +		-framework Cocoa \ +		-framework Foundation \ +		-fobjc-arc \ +		-c \ +		$^ + +	mv *.o lib/DDHotKey/ + +lib/DDHotKey/*.o: lib/DDHotKey/*.m + +build/libddhotkey.a: $(DDHOTKEY_OBJ) +# build/libddhotkey.a: lib/DDHotKey/*.o +	libtool -static \ +		-o $@ \ +		$^ @@ -1,8 +1,28 @@ +#import <Carbon/Carbon.h>  #import <CoreGraphics/CoreGraphics.h> +#import "Invert.h" +#import "DDHotKeyCenter.h" +  #define MAX_DISPLAYS 8  int main(int argc, const char * argv[]) { +    [NSApplication sharedApplication]; + +    Invert *invert = [[Invert alloc] init]; + +    DDHotKeyCenter *c = [DDHotKeyCenter sharedHotKeyCenter]; +    if ( +        ![c registerHotKeyWithKeyCode:kVK_ANSI_8 +            modifierFlags: +                (NSEventModifierFlagControl | NSEventModifierFlagOption | NSEventModifierFlagCommand) +            target:invert +            action:@selector(toggleInvertColors:) +            object:nil] +    ) { +        NSLog(@"Error registering hotkey"); +    } +      const CGGammaValue inverted_gamma[2] = {1, 0};      CGDirectDisplayID active_displays[MAX_DISPLAYS]; @@ -30,9 +50,15 @@ int main(int argc, const char * argv[]) {          }      } -    sleep(4); +    // for (;;) {} +    // sleep(4); +    // +    // CGDisplayRestoreColorSyncSettings(); + +    // TODO: trap? +    // [invert release]; -    CGDisplayRestoreColorSyncSettings(); +    [NSApp run];      return 0;  } | 
