Big rename part 3: 'target' to 'output'.
authorJoe Wreschnig <joe.wreschnig@gmail.com>
Sun, 3 Mar 2013 21:37:54 +0000 (22:37 +0100)
committerJoe Wreschnig <joe.wreschnig@gmail.com>
Sun, 3 Mar 2013 21:37:54 +0000 (22:37 +0100)
42 files changed:
ApplicationController.h
ApplicationController.m
English.lproj/MainMenu.xib
Enjoyable.xcodeproj/project.pbxproj
NJInputController.h
NJInputController.m
NJMapping.h
NJMapping.m
NJMappingsController.h
NJMappingsController.m
NJOutput.h [new file with mode: 0644]
NJOutput.m [new file with mode: 0644]
NJOutputController.h [new file with mode: 0644]
NJOutputController.m [new file with mode: 0644]
NJOutputKeyPress.h [new file with mode: 0644]
NJOutputKeyPress.m [new file with mode: 0644]
NJOutputMapping.h [new file with mode: 0644]
NJOutputMapping.m [new file with mode: 0644]
NJOutputMouseButton.h [new file with mode: 0644]
NJOutputMouseButton.m [new file with mode: 0644]
NJOutputMouseMove.h [new file with mode: 0644]
NJOutputMouseMove.m [new file with mode: 0644]
NJOutputMouseScroll.h [new file with mode: 0644]
NJOutputMouseScroll.m [new file with mode: 0644]
NJOutputSwitchMouseMode.h [new file with mode: 0644]
NJOutputSwitchMouseMode.m [new file with mode: 0644]
Target.h [deleted file]
Target.m [deleted file]
TargetConfig.h [deleted file]
TargetConfig.m [deleted file]
TargetController.h [deleted file]
TargetController.m [deleted file]
TargetKeyboard.h [deleted file]
TargetKeyboard.m [deleted file]
TargetMouseBtn.h [deleted file]
TargetMouseBtn.m [deleted file]
TargetMouseMove.h [deleted file]
TargetMouseMove.m [deleted file]
TargetMouseScroll.h [deleted file]
TargetMouseScroll.m [deleted file]
TargetToggleMouseScope.h [deleted file]
TargetToggleMouseScope.m [deleted file]

index 88c9d29c72fc7b5c3d5607ba92740ee2713b5b36..a1b87420daec506d980c3dbcdbc7052081905ecb 100644 (file)
@@ -7,7 +7,7 @@
 //
 
 @class NJInputController;
-@class TargetController;
+@class NJOutputController;
 @class NJMappingsController;
 
 @interface ApplicationController : NSObject <NSApplicationDelegate> {
@@ -19,7 +19,7 @@
 }
 
 @property (nonatomic, strong) IBOutlet NJInputController *inputController;
-@property (nonatomic, strong) IBOutlet TargetController *targetController;
+@property (nonatomic, strong) IBOutlet NJOutputController *outputController;
 @property (nonatomic, strong) IBOutlet NJMappingsController *mappingsController;
 
 - (IBAction)toggleActivity:(id)sender;
index 50f9c295393fdf64e03269820b910c064155a431..faad07aa7ef23a2d96d84821d697106691458313 100644 (file)
@@ -10,7 +10,7 @@
 #import "NJMapping.h"
 #import "NJMappingsController.h"
 #import "NJInputController.h"
-#import "TargetController.h"
+#import "NJOutputController.h"
 #import "NJEvents.h"
 
 @implementation ApplicationController {
@@ -24,7 +24,7 @@
 
 - (void)applicationDidFinishLaunching:(NSNotification *)notification {
     [drawer open];
-    self.targetController.enabled = NO;
+    self.outputController.enabled = NO;
     [self.inputController setup];
     [self.mappingsController load];
     [NSNotificationCenter.defaultCenter
@@ -92,7 +92,7 @@
                          keyEquivalent:keyEquiv];
         
     }
-    [_targetController refreshMappings];
+    [_outputController refreshMappings];
 }
 
 - (void)mappingDidChange:(NSNotification *)note {
index c2ebf64845f91c20d37da52ed1cbe2352d88dfe3..8dd62bf725656ce6412702823bab9422b711dab0 100644 (file)
                                <string key="NSClassName">NJInputController</string>
                        </object>
                        <object class="NSCustomObject" id="801536542">
-                               <string key="NSClassName">TargetController</string>
+                               <string key="NSClassName">NJOutputController</string>
                        </object>
                </array>
                <object class="IBObjectContainer" key="IBDocument.Objects">
                                </object>
                                <object class="IBConnectionRecord">
                                        <object class="IBOutletConnection" key="connection">
-                                               <string key="label">targetController</string>
+                                               <string key="label">mappingsController</string>
                                                <reference key="source" ref="1007832501"/>
-                                               <reference key="destination" ref="801536542"/>
+                                               <reference key="destination" ref="468285243"/>
                                        </object>
-                                       <int key="connectionID">695</int>
+                                       <int key="connectionID">822</int>
                                </object>
                                <object class="IBConnectionRecord">
                                        <object class="IBOutletConnection" key="connection">
-                                               <string key="label">mappingsController</string>
+                                               <string key="label">outputController</string>
                                                <reference key="source" ref="1007832501"/>
-                                               <reference key="destination" ref="468285243"/>
+                                               <reference key="destination" ref="801536542"/>
                                        </object>
-                                       <int key="connectionID">822</int>
+                                       <int key="connectionID">826</int>
                                </object>
                                <object class="IBConnectionRecord">
                                        <object class="IBOutletConnection" key="connection">
                                        </object>
                                        <int key="connectionID">611</int>
                                </object>
-                               <object class="IBConnectionRecord">
-                                       <object class="IBOutletConnection" key="connection">
-                                               <string key="label">targetController</string>
-                                               <reference key="source" ref="207406104"/>
-                                               <reference key="destination" ref="801536542"/>
-                                       </object>
-                                       <int key="connectionID">712</int>
-                               </object>
                                <object class="IBConnectionRecord">
                                        <object class="IBOutletConnection" key="connection">
                                                <string key="label">dockMenuBase</string>
                                        </object>
                                        <int key="connectionID">820</int>
                                </object>
+                               <object class="IBConnectionRecord">
+                                       <object class="IBOutletConnection" key="connection">
+                                               <string key="label">outputController</string>
+                                               <reference key="source" ref="207406104"/>
+                                               <reference key="destination" ref="801536542"/>
+                                       </object>
+                                       <int key="connectionID">825</int>
+                               </object>
                                <object class="IBConnectionRecord">
                                        <object class="IBActionConnection" key="connection">
                                                <string key="label">addPressed:</string>
                                        </object>
                                        <int key="connectionID">520</int>
                                </object>
-                               <object class="IBConnectionRecord">
-                                       <object class="IBOutletConnection" key="connection">
-                                               <string key="label">targetController</string>
-                                               <reference key="source" ref="468285243"/>
-                                               <reference key="destination" ref="801536542"/>
-                                       </object>
-                                       <int key="connectionID">697</int>
-                               </object>
                                <object class="IBConnectionRecord">
                                        <object class="IBActionConnection" key="connection">
                                                <string key="label">exportPressed:</string>
                                        </object>
                                        <int key="connectionID">816</int>
                                </object>
+                               <object class="IBConnectionRecord">
+                                       <object class="IBOutletConnection" key="connection">
+                                               <string key="label">outputController</string>
+                                               <reference key="source" ref="468285243"/>
+                                               <reference key="destination" ref="801536542"/>
+                                       </object>
+                                       <int key="connectionID">827</int>
+                               </object>
                                <object class="IBConnectionRecord">
                                        <object class="IBOutletConnection" key="connection">
                                                <string key="label">dataSource</string>
                                        </object>
                                        <int key="connectionID">692</int>
                                </object>
-                               <object class="IBConnectionRecord">
-                                       <object class="IBOutletConnection" key="connection">
-                                               <string key="label">joystickController</string>
-                                               <reference key="source" ref="801536542"/>
-                                               <reference key="destination" ref="1007832501"/>
-                                       </object>
-                                       <int key="connectionID">694</int>
-                               </object>
                                <object class="IBConnectionRecord">
                                        <object class="IBOutletConnection" key="connection">
                                                <string key="label">title</string>
                                        </object>
                                        <int key="connectionID">824</int>
                                </object>
+                               <object class="IBConnectionRecord">
+                                       <object class="IBOutletConnection" key="connection">
+                                               <string key="label">inputController</string>
+                                               <reference key="source" ref="801536542"/>
+                                               <reference key="destination" ref="1007832501"/>
+                                       </object>
+                                       <int key="connectionID">828</int>
+                               </object>
                                <object class="IBConnectionRecord">
                                        <object class="IBOutletConnection" key="connection">
                                                <string key="label">keyDelegate</string>
                        <nil key="activeLocalization"/>
                        <dictionary class="NSMutableDictionary" key="localizations"/>
                        <nil key="sourceID"/>
-                       <int key="maxID">824</int>
+                       <int key="maxID">828</int>
                </object>
                <object class="IBClassDescriber" key="IBDocument.Classes">
                        <array class="NSMutableArray" key="referencedPartialClassDescriptions">
index cbcf390649283d89c9584e8eaf7002eb48e3a2df..c633833e09e67b197ee8a166e8a3c72a7275a04f 100644 (file)
@@ -8,10 +8,10 @@
 
 /* Begin PBXBuildFile section */
                1DDD58160DA1D0A300B32029 /* MainMenu.xib in Resources */ = {isa = PBXBuildFile; fileRef = 1DDD58140DA1D0A300B32029 /* MainMenu.xib */; };
-               8B7E476C15C314A200C588FA /* TargetMouseBtn.m in Sources */ = {isa = PBXBuildFile; fileRef = 8B7E476B15C314A200C588FA /* TargetMouseBtn.m */; };
-               8BD9B54315C230FF00929C5D /* TargetMouseMove.m in Sources */ = {isa = PBXBuildFile; fileRef = 8BD9B54215C230FE00929C5D /* TargetMouseMove.m */; };
-               8BEFAD9C15C46BFF00823AEC /* TargetMouseScroll.m in Sources */ = {isa = PBXBuildFile; fileRef = 8BEFAD9B15C46BFF00823AEC /* TargetMouseScroll.m */; };
-               8BEFADA015C476DC00823AEC /* TargetToggleMouseScope.m in Sources */ = {isa = PBXBuildFile; fileRef = 8BEFAD9F15C476DC00823AEC /* TargetToggleMouseScope.m */; };
+               8B7E476C15C314A200C588FA /* NJOutputMouseButton.m in Sources */ = {isa = PBXBuildFile; fileRef = 8B7E476B15C314A200C588FA /* NJOutputMouseButton.m */; };
+               8BD9B54315C230FF00929C5D /* NJOutputMouseMove.m in Sources */ = {isa = PBXBuildFile; fileRef = 8BD9B54215C230FE00929C5D /* NJOutputMouseMove.m */; };
+               8BEFAD9C15C46BFF00823AEC /* NJOutputMouseScroll.m in Sources */ = {isa = PBXBuildFile; fileRef = 8BEFAD9B15C46BFF00823AEC /* NJOutputMouseScroll.m */; };
+               8BEFADA015C476DC00823AEC /* NJOutputSwitchMouseMode.m in Sources */ = {isa = PBXBuildFile; fileRef = 8BEFAD9F15C476DC00823AEC /* NJOutputSwitchMouseMode.m */; };
                8D11072B0486CEB800E47090 /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = 089C165CFE840E0CC02AAC07 /* InfoPlist.strings */; };
                8D11072D0486CEB800E47090 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 29B97316FDCFA39411CA2CEA /* main.m */; settings = {ATTRIBUTES = (); }; };
                8D11072F0486CEB800E47090 /* Cocoa.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1058C7A1FEA54F0111CA2CBB /* Cocoa.framework */; };
                D5617D1A0FAF568100928B3A /* NJInputButton.m in Sources */ = {isa = PBXBuildFile; fileRef = D5617D190FAF568100928B3A /* NJInputButton.m */; };
                D5617D260FAF579300928B3A /* NJInputHat.m in Sources */ = {isa = PBXBuildFile; fileRef = D5617D250FAF579300928B3A /* NJInputHat.m */; };
                D5617D2B0FAF579A00928B3A /* NJInputAnalog.m in Sources */ = {isa = PBXBuildFile; fileRef = D5617D2A0FAF579A00928B3A /* NJInputAnalog.m */; };
-               D5617FD60FAFD06000928B3A /* Target.m in Sources */ = {isa = PBXBuildFile; fileRef = D5617FD50FAFD06000928B3A /* Target.m */; };
-               D5617FD90FAFD1E600928B3A /* TargetKeyboard.m in Sources */ = {isa = PBXBuildFile; fileRef = D5617FD80FAFD1E600928B3A /* TargetKeyboard.m */; };
-               D5617FE40FAFD7B000928B3A /* TargetController.m in Sources */ = {isa = PBXBuildFile; fileRef = D5617FE30FAFD7B000928B3A /* TargetController.m */; };
+               D5617FD60FAFD06000928B3A /* NJOutput.m in Sources */ = {isa = PBXBuildFile; fileRef = D5617FD50FAFD06000928B3A /* NJOutput.m */; };
+               D5617FD90FAFD1E600928B3A /* NJOutputKeyPress.m in Sources */ = {isa = PBXBuildFile; fileRef = D5617FD80FAFD1E600928B3A /* NJOutputKeyPress.m */; };
+               D5617FE40FAFD7B000928B3A /* NJOutputController.m in Sources */ = {isa = PBXBuildFile; fileRef = D5617FE30FAFD7B000928B3A /* NJOutputController.m */; };
                D5617FE70FAFDB5800928B3A /* NJKeyInputField.m in Sources */ = {isa = PBXBuildFile; fileRef = D5617FE60FAFDB5800928B3A /* NJKeyInputField.m */; };
                D594BE860FAE6219007A85F2 /* NJDevice.m in Sources */ = {isa = PBXBuildFile; fileRef = D594BE850FAE6219007A85F2 /* NJDevice.m */; };
                D594BE8A0FAE64AD007A85F2 /* NJInput.m in Sources */ = {isa = PBXBuildFile; fileRef = D594BE890FAE64AD007A85F2 /* NJInput.m */; };
                D594BEF90FAE6FF2007A85F2 /* NJInputController.m in Sources */ = {isa = PBXBuildFile; fileRef = D594BEF80FAE6FF2007A85F2 /* NJInputController.m */; };
                D594BF000FAE7397007A85F2 /* IOKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = D594BEFF0FAE7397007A85F2 /* IOKit.framework */; };
                D594BF830FAE9661007A85F2 /* ApplicationController.m in Sources */ = {isa = PBXBuildFile; fileRef = D594BF820FAE9661007A85F2 /* ApplicationController.m */; };
-               D5F809710FB093400006A4DE /* TargetConfig.m in Sources */ = {isa = PBXBuildFile; fileRef = D5F809700FB093400006A4DE /* TargetConfig.m */; };
+               D5F809710FB093400006A4DE /* NJOutputMapping.m in Sources */ = {isa = PBXBuildFile; fileRef = D5F809700FB093400006A4DE /* NJOutputMapping.m */; };
                D5F80A9D0FB0A2FF0006A4DE /* icon.icns in Resources */ = {isa = PBXBuildFile; fileRef = D5617A080FAEAF8300928B3A /* icon.icns */; };
                EE1D7C9216E01E7000B000EB /* NSView+FirstResponder.m in Sources */ = {isa = PBXBuildFile; fileRef = EE1D7C9116E01E7000B000EB /* NSView+FirstResponder.m */; };
                EE1D7C9616E0ECCF00B000EB /* NSError+Description.m in Sources */ = {isa = PBXBuildFile; fileRef = EE1D7C9516E0ECCF00B000EB /* NSError+Description.m */; };
                29B97324FDCFA39411CA2CEA /* AppKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AppKit.framework; path = /System/Library/Frameworks/AppKit.framework; sourceTree = "<absolute>"; };
                29B97325FDCFA39411CA2CEA /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = /System/Library/Frameworks/Foundation.framework; sourceTree = "<absolute>"; };
                32CA4F630368D1EE00C91783 /* Enjoyable_Prefix.pch */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Enjoyable_Prefix.pch; sourceTree = "<group>"; };
-               8B7E476A15C314A200C588FA /* TargetMouseBtn.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TargetMouseBtn.h; sourceTree = "<group>"; };
-               8B7E476B15C314A200C588FA /* TargetMouseBtn.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = TargetMouseBtn.m; sourceTree = "<group>"; };
-               8BD9B54115C230FE00929C5D /* TargetMouseMove.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TargetMouseMove.h; sourceTree = "<group>"; };
-               8BD9B54215C230FE00929C5D /* TargetMouseMove.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = TargetMouseMove.m; sourceTree = "<group>"; };
-               8BEFAD9A15C46BFF00823AEC /* TargetMouseScroll.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TargetMouseScroll.h; sourceTree = "<group>"; };
-               8BEFAD9B15C46BFF00823AEC /* TargetMouseScroll.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = TargetMouseScroll.m; sourceTree = "<group>"; };
-               8BEFAD9E15C476DC00823AEC /* TargetToggleMouseScope.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TargetToggleMouseScope.h; sourceTree = "<group>"; };
-               8BEFAD9F15C476DC00823AEC /* TargetToggleMouseScope.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = TargetToggleMouseScope.m; sourceTree = "<group>"; };
+               8B7E476A15C314A200C588FA /* NJOutputMouseButton.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NJOutputMouseButton.h; sourceTree = "<group>"; };
+               8B7E476B15C314A200C588FA /* NJOutputMouseButton.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = NJOutputMouseButton.m; sourceTree = "<group>"; };
+               8BD9B54115C230FE00929C5D /* NJOutputMouseMove.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NJOutputMouseMove.h; sourceTree = "<group>"; };
+               8BD9B54215C230FE00929C5D /* NJOutputMouseMove.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = NJOutputMouseMove.m; sourceTree = "<group>"; };
+               8BEFAD9A15C46BFF00823AEC /* NJOutputMouseScroll.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NJOutputMouseScroll.h; sourceTree = "<group>"; };
+               8BEFAD9B15C46BFF00823AEC /* NJOutputMouseScroll.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = NJOutputMouseScroll.m; sourceTree = "<group>"; };
+               8BEFAD9E15C476DC00823AEC /* NJOutputSwitchMouseMode.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NJOutputSwitchMouseMode.h; sourceTree = "<group>"; };
+               8BEFAD9F15C476DC00823AEC /* NJOutputSwitchMouseMode.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = NJOutputSwitchMouseMode.m; sourceTree = "<group>"; };
                8D1107310486CEB800E47090 /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
                8D1107320486CEB800E47090 /* Enjoyable.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Enjoyable.app; sourceTree = BUILT_PRODUCTS_DIR; };
                D549CA4B0FBB441B00BC8203 /* Credits.rtf */ = {isa = PBXFileReference; lastKnownFileType = text.rtf; path = Credits.rtf; sourceTree = "<group>"; };
                D5617D250FAF579300928B3A /* NJInputHat.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = NJInputHat.m; sourceTree = "<group>"; };
                D5617D290FAF579A00928B3A /* NJInputAnalog.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NJInputAnalog.h; sourceTree = "<group>"; };
                D5617D2A0FAF579A00928B3A /* NJInputAnalog.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = NJInputAnalog.m; sourceTree = "<group>"; };
-               D5617FD40FAFD06000928B3A /* Target.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Target.h; sourceTree = "<group>"; };
-               D5617FD50FAFD06000928B3A /* Target.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = Target.m; sourceTree = "<group>"; };
-               D5617FD70FAFD1E600928B3A /* TargetKeyboard.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TargetKeyboard.h; sourceTree = "<group>"; };
-               D5617FD80FAFD1E600928B3A /* TargetKeyboard.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = TargetKeyboard.m; sourceTree = "<group>"; };
-               D5617FE20FAFD7B000928B3A /* TargetController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TargetController.h; sourceTree = "<group>"; };
-               D5617FE30FAFD7B000928B3A /* TargetController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = TargetController.m; sourceTree = "<group>"; };
+               D5617FD40FAFD06000928B3A /* NJOutput.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NJOutput.h; sourceTree = "<group>"; };
+               D5617FD50FAFD06000928B3A /* NJOutput.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = NJOutput.m; sourceTree = "<group>"; };
+               D5617FD70FAFD1E600928B3A /* NJOutputKeyPress.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NJOutputKeyPress.h; sourceTree = "<group>"; };
+               D5617FD80FAFD1E600928B3A /* NJOutputKeyPress.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = NJOutputKeyPress.m; sourceTree = "<group>"; };
+               D5617FE20FAFD7B000928B3A /* NJOutputController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NJOutputController.h; sourceTree = "<group>"; };
+               D5617FE30FAFD7B000928B3A /* NJOutputController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = NJOutputController.m; sourceTree = "<group>"; };
                D5617FE50FAFDB5800928B3A /* NJKeyInputField.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NJKeyInputField.h; sourceTree = "<group>"; };
                D5617FE60FAFDB5800928B3A /* NJKeyInputField.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = NJKeyInputField.m; sourceTree = "<group>"; };
                D594BE840FAE6219007A85F2 /* NJDevice.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NJDevice.h; sourceTree = "<group>"; };
@@ -83,8 +83,8 @@
                D594BEFF0FAE7397007A85F2 /* IOKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = IOKit.framework; path = /System/Library/Frameworks/IOKit.framework; sourceTree = "<absolute>"; };
                D594BF810FAE9661007A85F2 /* ApplicationController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ApplicationController.h; sourceTree = "<group>"; };
                D594BF820FAE9661007A85F2 /* ApplicationController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ApplicationController.m; sourceTree = "<group>"; };
-               D5F8096F0FB093400006A4DE /* TargetConfig.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TargetConfig.h; sourceTree = "<group>"; };
-               D5F809700FB093400006A4DE /* TargetConfig.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = TargetConfig.m; sourceTree = "<group>"; };
+               D5F8096F0FB093400006A4DE /* NJOutputMapping.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NJOutputMapping.h; sourceTree = "<group>"; };
+               D5F809700FB093400006A4DE /* NJOutputMapping.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = NJOutputMapping.m; sourceTree = "<group>"; };
                EE1D7C9016E01E7000B000EB /* NSView+FirstResponder.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "NSView+FirstResponder.h"; sourceTree = "<group>"; };
                EE1D7C9116E01E7000B000EB /* NSView+FirstResponder.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "NSView+FirstResponder.m"; sourceTree = "<group>"; };
                EE1D7C9416E0ECCF00B000EB /* NSError+Description.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "NSError+Description.h"; sourceTree = "<group>"; };
                                D5617A350FAEB74000928B3A /* NJMappingsController.m */,
                                D5617A370FAEBA1800928B3A /* NJMapping.h */,
                                D5617A380FAEBA1800928B3A /* NJMapping.m */,
-                               D5F8096F0FB093400006A4DE /* TargetConfig.h */,
-                               D5F809700FB093400006A4DE /* TargetConfig.m */,
-                               D5617FD40FAFD06000928B3A /* Target.h */,
-                               D5617FD50FAFD06000928B3A /* Target.m */,
-                               D5617FD70FAFD1E600928B3A /* TargetKeyboard.h */,
-                               D5617FD80FAFD1E600928B3A /* TargetKeyboard.m */,
-                               D5617FE20FAFD7B000928B3A /* TargetController.h */,
-                               D5617FE30FAFD7B000928B3A /* TargetController.m */,
+                               D5F8096F0FB093400006A4DE /* NJOutputMapping.h */,
+                               D5F809700FB093400006A4DE /* NJOutputMapping.m */,
+                               D5617FD40FAFD06000928B3A /* NJOutput.h */,
+                               D5617FD50FAFD06000928B3A /* NJOutput.m */,
+                               D5617FD70FAFD1E600928B3A /* NJOutputKeyPress.h */,
+                               D5617FD80FAFD1E600928B3A /* NJOutputKeyPress.m */,
+                               D5617FE20FAFD7B000928B3A /* NJOutputController.h */,
+                               D5617FE30FAFD7B000928B3A /* NJOutputController.m */,
                                D5617FE50FAFDB5800928B3A /* NJKeyInputField.h */,
                                D5617FE60FAFDB5800928B3A /* NJKeyInputField.m */,
-                               8BD9B54115C230FE00929C5D /* TargetMouseMove.h */,
-                               8BD9B54215C230FE00929C5D /* TargetMouseMove.m */,
-                               8B7E476A15C314A200C588FA /* TargetMouseBtn.h */,
-                               8B7E476B15C314A200C588FA /* TargetMouseBtn.m */,
-                               8BEFAD9A15C46BFF00823AEC /* TargetMouseScroll.h */,
-                               8BEFAD9B15C46BFF00823AEC /* TargetMouseScroll.m */,
-                               8BEFAD9E15C476DC00823AEC /* TargetToggleMouseScope.h */,
-                               8BEFAD9F15C476DC00823AEC /* TargetToggleMouseScope.m */,
+                               8BD9B54115C230FE00929C5D /* NJOutputMouseMove.h */,
+                               8BD9B54215C230FE00929C5D /* NJOutputMouseMove.m */,
+                               8B7E476A15C314A200C588FA /* NJOutputMouseButton.h */,
+                               8B7E476B15C314A200C588FA /* NJOutputMouseButton.m */,
+                               8BEFAD9A15C46BFF00823AEC /* NJOutputMouseScroll.h */,
+                               8BEFAD9B15C46BFF00823AEC /* NJOutputMouseScroll.m */,
+                               8BEFAD9E15C476DC00823AEC /* NJOutputSwitchMouseMode.h */,
+                               8BEFAD9F15C476DC00823AEC /* NJOutputSwitchMouseMode.m */,
                                EEF86B7316E2241000674B87 /* NJInputPathElement.h */,
                                EEF86B7416E298CD00674B87 /* NJEvents.h */,
                        );
                                D5617D1A0FAF568100928B3A /* NJInputButton.m in Sources */,
                                D5617D260FAF579300928B3A /* NJInputHat.m in Sources */,
                                D5617D2B0FAF579A00928B3A /* NJInputAnalog.m in Sources */,
-                               D5617FD60FAFD06000928B3A /* Target.m in Sources */,
-                               D5617FD90FAFD1E600928B3A /* TargetKeyboard.m in Sources */,
-                               D5617FE40FAFD7B000928B3A /* TargetController.m in Sources */,
+                               D5617FD60FAFD06000928B3A /* NJOutput.m in Sources */,
+                               D5617FD90FAFD1E600928B3A /* NJOutputKeyPress.m in Sources */,
+                               D5617FE40FAFD7B000928B3A /* NJOutputController.m in Sources */,
                                D5617FE70FAFDB5800928B3A /* NJKeyInputField.m in Sources */,
-                               D5F809710FB093400006A4DE /* TargetConfig.m in Sources */,
-                               8BD9B54315C230FF00929C5D /* TargetMouseMove.m in Sources */,
-                               8B7E476C15C314A200C588FA /* TargetMouseBtn.m in Sources */,
-                               8BEFAD9C15C46BFF00823AEC /* TargetMouseScroll.m in Sources */,
-                               8BEFADA015C476DC00823AEC /* TargetToggleMouseScope.m in Sources */,
+                               D5F809710FB093400006A4DE /* NJOutputMapping.m in Sources */,
+                               8BD9B54315C230FF00929C5D /* NJOutputMouseMove.m in Sources */,
+                               8B7E476C15C314A200C588FA /* NJOutputMouseButton.m in Sources */,
+                               8BEFAD9C15C46BFF00823AEC /* NJOutputMouseScroll.m in Sources */,
+                               8BEFADA015C476DC00823AEC /* NJOutputSwitchMouseMode.m in Sources */,
                                EE1D7C9216E01E7000B000EB /* NSView+FirstResponder.m in Sources */,
                                EE1D7C9616E0ECCF00B000EB /* NSError+Description.m in Sources */,
                        );
index feea2e26e10d05e60df233d17a4d94fbbddda3a5..fdd053205128442fa2fa266a50587a0b861996a8 100644 (file)
@@ -9,16 +9,16 @@
 @class NJDevice;
 @class NJInput;
 @class NJMappingsController;
-@class TargetController;
+@class NJOutputController;
 
 @interface NJInputController : NSObject <NSOutlineViewDataSource, NSOutlineViewDelegate> {
        IBOutlet NSOutlineView *outlineView;
-       IBOutlet TargetController *targetController;
+       IBOutlet NJOutputController *outputController;
        IBOutlet NJMappingsController *mappingsController;
 }
 
 - (void)setup;
-- (NJDevice *)findJoystickByRef:(IOHIDDeviceRef)device;
+- (NJDevice *)findDeviceByRef:(IOHIDDeviceRef)device;
 
 @property (nonatomic, readonly) NJInput *selectedInput;
 @property (nonatomic, assign) NSPoint mouseLoc;
index a708d82aab8f19bc33b7b87cb0c3e7ee76558ad1..618e99bed78302e483b1f1c509e0acc5adf005bf 100644 (file)
 #import "NJMappingsController.h"
 #import "NJDevice.h"
 #import "NJInput.h"
-#import "Target.h"
-#import "TargetController.h"
+#import "NJOutput.h"
+#import "NJOutputController.h"
 #import "NJEvents.h"
 
 @implementation NJInputController {
     IOHIDManagerRef hidManager;
     NSTimer *continuousTimer;
-    NSMutableArray *runningTargets;
-    NSMutableArray *_joysticks;
+    NSMutableArray *runningOutputs;
+    NSMutableArray *_devices;
 }
 
 - (id)init {
     if ((self = [super init])) {
-        _joysticks = [[NSMutableArray alloc] initWithCapacity:16];
-        runningTargets = [[NSMutableArray alloc] initWithCapacity:32];
+        _devices = [[NSMutableArray alloc] initWithCapacity:16];
+        runningOutputs = [[NSMutableArray alloc] initWithCapacity:32];
     }
     return self;
 }
@@ -43,9 +43,9 @@
     }
 }
 
-- (void)addRunningTarget:(Target *)target {
-    if (![runningTargets containsObject:target]) {
-        [runningTargets addObject:target];
+- (void)addRunningOutput:(NJOutput *)output {
+    if (![runningOutputs containsObject:output]) {
+        [runningOutputs addObject:output];
     }
     if (!continuousTimer) {
         continuousTimer = [NSTimer scheduledTimerWithTimeInterval:1.f/60.f
                                                          selector:@selector(updateContinuousInputs:)
                                                          userInfo:nil
                                                           repeats:YES];
-        NSLog(@"Scheduled continuous target timer.");
+        NSLog(@"Scheduled continuous output timer.");
     }
 }
 
-- (void)runTargetForDevice:(IOHIDDeviceRef)device value:(IOHIDValueRef)value {
-    NJDevice *dev = [self findJoystickByRef:device];
+- (void)runOutputForDevice:(IOHIDDeviceRef)device value:(IOHIDValueRef)value {
+    NJDevice *dev = [self findDeviceByRef:device];
     NJInput *mainInput = [dev inputForEvent:value];
     [mainInput notifyEvent:value];
     NSArray *children = mainInput.children ? mainInput.children : mainInput ? @[mainInput] : @[];
     for (NJInput *subInput in children) {
-        Target *target = mappingsController.currentMapping[subInput];
-        target.magnitude = mainInput.magnitude;
-        target.running = subInput.active;
-        if (target.running && target.isContinuous)
-            [self addRunningTarget:target];
+        NJOutput *output = mappingsController.currentMapping[subInput];
+        output.magnitude = mainInput.magnitude;
+        output.running = subInput.active;
+        if (output.running && output.isContinuous)
+            [self addRunningOutput:output];
     }
 }
 
-- (void)showTargetForDevice:(IOHIDDeviceRef)device value:(IOHIDValueRef)value {
-    NJDevice *dev = [self findJoystickByRef:device];
+- (void)showOutputForDevice:(IOHIDDeviceRef)device value:(IOHIDValueRef)value {
+    NJDevice *dev = [self findDeviceByRef:device];
     NJInput *handler = [dev handlerForEvent:value];
     if (!handler)
         return;
     
     [self expandRecursive:handler];
     [outlineView selectRowIndexes:[NSIndexSet indexSetWithIndex:[outlineView rowForItem:handler]] byExtendingSelection: NO];
-    [targetController focusKey];
+    [outputController focusKey];
 }
 
 static void input_callback(void *ctx, IOReturn inResult, void *inSender, IOHIDValueRef value) {
@@ -87,9 +87,9 @@ static void input_callback(void *ctx, IOReturn inResult, void *inSender, IOHIDVa
     IOHIDDeviceRef device = IOHIDQueueGetDevice(inSender);
     
     if (controller.translatingEvents) {
-        [controller runTargetForDevice:device value:value];
+        [controller runOutputForDevice:device value:value];
     } else if ([NSApplication sharedApplication].mainWindow.isVisible) {
-        [controller showTargetForDevice:device value:value];
+        [controller showOutputForDevice:device value:value];
     }
 }
 
@@ -107,21 +107,21 @@ static int findAvailableIndex(NSArray *list, NJDevice *dev) {
     }
 }
 
-- (void)addJoystickForDevice:(IOHIDDeviceRef)device {
+- (void)addDeviceForDevice:(IOHIDDeviceRef)device {
     IOHIDDeviceRegisterInputValueCallback(device, input_callback, (__bridge void*)self);
     NJDevice *dev = [[NJDevice alloc] initWithDevice:device];
-    dev.index = findAvailableIndex(_joysticks, dev);
-    [_joysticks addObject:dev];
+    dev.index = findAvailableIndex(_devices, dev);
+    [_devices addObject:dev];
     [outlineView reloadData];
 }
 
 static void add_callback(void *ctx, IOReturn inResult, void *inSender, IOHIDDeviceRef device) {
     NJInputController *controller = (__bridge NJInputController *)ctx;
-    [controller addJoystickForDevice:device];
+    [controller addDeviceForDevice:device];
 }
 
-- (NJDevice *)findJoystickByRef:(IOHIDDeviceRef)device {
-    for (NJDevice *dev in _joysticks)
+- (NJDevice *)findDeviceByRef:(IOHIDDeviceRef)device {
+    for (NJDevice *dev in _devices)
         if (dev.device == device)
             return dev;
     return nil;
@@ -129,14 +129,14 @@ static void add_callback(void *ctx, IOReturn inResult, void *inSender, IOHIDDevi
 
 static void remove_callback(void *ctx, IOReturn inResult, void *inSender, IOHIDDeviceRef device) {
     NJInputController *controller = (__bridge NJInputController *)ctx;
-    [controller removeJoystickForDevice:device];
+    [controller removeDeviceForDevice:device];
 }
 
-- (void)removeJoystickForDevice:(IOHIDDeviceRef)device {
-    NJDevice *match = [self findJoystickByRef:device];
+- (void)removeDeviceForDevice:(IOHIDDeviceRef)device {
+    NJDevice *match = [self findDeviceByRef:device];
     IOHIDDeviceRegisterInputValueCallback(device, NULL, NULL);
     if (match) {
-        [_joysticks removeObject:match];
+        [_devices removeObject:match];
         [outlineView reloadData];
     }
     
@@ -144,15 +144,15 @@ static void remove_callback(void *ctx, IOReturn inResult, void *inSender, IOHIDD
 
 - (void)updateContinuousInputs:(NSTimer *)timer {
     self.mouseLoc = [NSEvent mouseLocation];
-    for (Target *target in [runningTargets copy]) {
-        if (![target update:self]) {
-            [runningTargets removeObject:target];
+    for (NJOutput *output in [runningOutputs copy]) {
+        if (![output update:self]) {
+            [runningOutputs removeObject:output];
         }
     }
-    if (!runningTargets.count) {
+    if (!runningOutputs.count) {
         [continuousTimer invalidate];
         continuousTimer = nil;
-        NSLog(@"Unscheduled continuous target timer.");
+        NSLog(@"Unscheduled continuous output timer.");
     }
 }
 
@@ -196,7 +196,7 @@ static void remove_callback(void *ctx, IOReturn inResult, void *inSender, IOHIDD
 
 - (NSInteger)outlineView:(NSOutlineView *)outlineView
   numberOfChildrenOfItem:(id <NJInputPathElement>)item {
-    return item ? item.children.count : _joysticks.count;
+    return item ? item.children.count : _devices.count;
 }
 
 - (BOOL)outlineView:(NSOutlineView *)outlineView
@@ -207,7 +207,7 @@ static void remove_callback(void *ctx, IOReturn inResult, void *inSender, IOHIDD
 - (id)outlineView:(NSOutlineView *)outlineView
             child:(NSInteger)index
            ofItem:(id <NJInputPathElement>)item {
-    return item ? item.children[index] : _joysticks[index];
+    return item ? item.children[index] : _devices[index];
 }
 
 - (id)outlineView:(NSOutlineView *)outlineView
@@ -218,7 +218,7 @@ objectValueForTableColumn:(NSTableColumn *)tableColumn
 
 - (void)outlineViewSelectionDidChange:(NSNotification *)notification {
     
-    [targetController loadCurrent];
+    [outputController loadCurrent];
 }
 
 - (void)setTranslatingEvents:(BOOL)translatingEvents {
index a4068ffe6fcfbc47aa4bb29e677e5d88c0146fce..f997fa8f6e84d8b87bc4929d376b8ed39cca8d77 100644 (file)
@@ -6,7 +6,7 @@
 //  Copyright 2009 University of Otago. All rights reserved.
 //
 
-@class Target;
+@class NJOutput;
 @class NJInput;
 
 @interface NJMapping : NSObject
@@ -15,8 +15,8 @@
 @property (nonatomic, readonly) NSMutableDictionary *entries;
 
 - (id)initWithName:(NSString *)name;
-- (Target *)objectForKeyedSubscript:(NJInput *)input;
-- (void)setObject:(Target *)target forKeyedSubscript:(NJInput *)input;
+- (NJOutput *)objectForKeyedSubscript:(NJInput *)input;
+- (void)setObject:(NJOutput *)output forKeyedSubscript:(NJInput *)input;
 - (NSDictionary *)serialize;
 
 @end
index a5f810ccd57b2ad20050f095056f5f7b6b3a04d9..4e7c4b2a41cdd30bf580e3f11c4aad7fc49feff4 100644 (file)
     return self;
 }
 
-- (Target *)objectForKeyedSubscript:(NJInput *)input {
+- (NJOutput *)objectForKeyedSubscript:(NJInput *)input {
     return input ? _entries[input.uid] : nil;
 }
 
-- (void)setObject:(Target *)target forKeyedSubscript:(NJInput *)input {
+- (void)setObject:(NJOutput *)output forKeyedSubscript:(NJInput *)input {
     if (input) {
-        if (target)
-            _entries[input.uid] = target;
+        if (output)
+            _entries[input.uid] = output;
         else
             [_entries removeObjectForKey:input.uid];
     }
index cda477fee0b63e6b3e12b8cfd85242af334a4492..d793714cfa31913783f3028f0163daa104a91b57 100644 (file)
@@ -7,14 +7,14 @@
 //
 
 @class NJMapping;
-@class TargetController;
+@class NJOutputController;
 
 @interface NJMappingsController : NSObject <NSTableViewDataSource,
                                             NSTableViewDelegate,
                                             NSOpenSavePanelDelegate> {
     IBOutlet NSButton *removeButton;
     IBOutlet NSTableView *tableView;
-    IBOutlet TargetController *targetController;
+    IBOutlet NJOutputController *outputController;
 }
 
 @property (nonatomic, readonly) NJMapping *currentMapping;
index e5b2b7d55d51cf3b34aa255c3dc03e27920413ec..e01cb911db5c4ed6ab8656c0496df386eee6abe6 100644 (file)
@@ -10,8 +10,8 @@
 #import "ApplicationController.h"
 #import "NJMapping.h"
 #import "NJMappingsController.h"
-#import "Target.h"
-#import "TargetController.h"
+#import "NJOutput.h"
+#import "NJOutputController.h"
 #import "NJEvents.h"
 
 @implementation NJMappingsController {
@@ -53,7 +53,7 @@
     manualMapping = mapping;
     _currentMapping = mapping;
     [removeButton setEnabled:_mappings[0] != mapping];
-    [targetController loadCurrent];
+    [outputController loadCurrent];
     [NSNotificationCenter.defaultCenter postNotificationName:NJEventMappingChanged
                                                       object:_currentMapping];
     [tableView selectRowIndexes:[NSIndexSet indexSetWithIndex:[_mappings indexOfObject:mapping]] byExtendingSelection:NO];
     NSArray *storedMappings = envelope[@"mappings"];
     NSMutableArray* newMappings = [[NSMutableArray alloc] initWithCapacity:storedMappings.count];
 
-    // have to do two passes in case mapping1 refers to mapping2 via a TargetMapping
+    // have to do two passes in case mapping1 refers to mapping2 via a NJOutputMapping
     for (NSDictionary *storedMapping in storedMappings) {
         NJMapping *mapping = [[NJMapping alloc] initWithName:storedMapping[@"name"]];
         [newMappings addObject:mapping];
         NSDictionary *entries = storedMappings[i][@"entries"];
         NJMapping *mapping = newMappings[i];
         for (id key in entries) {
-            Target *target = [Target targetDeserialize:entries[key]
-                                            withMappings:newMappings];
-            if (target)
-                mapping.entries[key] = target;
+            NJOutput *output = [NJOutput outputDeserialize:entries[key]
+                                              withMappings:newMappings];
+            if (output)
+                mapping.entries[key] = output;
         }
     }
     
     for (id key in entries) {
         NSDictionary *value = entries[key];
         if ([key isKindOfClass:NSString.class]) {
-            Target *target = [Target targetDeserialize:value
-                                           withMappings:_mappings];
-            if (target)
-                mapping.entries[key] = target;
+            NJOutput *output = [NJOutput outputDeserialize:value
+                                              withMappings:_mappings];
+            if (output)
+                mapping.entries[key] = output;
         }
     }
     return mapping;
                           [self save];
                           [(ApplicationController *)NSApplication.sharedApplication.delegate mappingsChanged];
                           [self activateMapping:mapping];
-                          [targetController loadCurrent];
+                          [outputController loadCurrent];
                           
                           if (conflict && !mergeInto) {
                               [tableView selectRowIndexes:[NSIndexSet indexSetWithIndex:_mappings.count - 1] byExtendingSelection:NO];
diff --git a/NJOutput.h b/NJOutput.h
new file mode 100644 (file)
index 0000000..2bfc167
--- /dev/null
@@ -0,0 +1,26 @@
+//
+//  NJOutput.h
+//  Enjoy
+//
+//  Created by Sam McCall on 5/05/09.
+//  Copyright 2009 University of Otago. All rights reserved.
+//
+
+@class NJInputController;
+
+@interface NJOutput : NSObject
+
+@property (nonatomic, assign) float magnitude;
+@property (nonatomic, assign) BOOL running;
+@property (nonatomic, readonly) BOOL isContinuous;
+
+- (void)trigger;
+- (void)untrigger;
+- (BOOL)update:(NJInputController *)jc;
+
+- (NSDictionary *)serialize;
++ (NJOutput *)outputDeserialize:(NSDictionary *)serialization
+                   withMappings:(NSArray *)mappings;
++ (NSString *)serializationCode;
+
+@end
diff --git a/NJOutput.m b/NJOutput.m
new file mode 100644 (file)
index 0000000..dd751e1
--- /dev/null
@@ -0,0 +1,89 @@
+//
+//  NJOutput.m
+//  Enjoy
+//
+//  Created by Sam McCall on 5/05/09.
+//
+
+#import "NJOutput.h"
+
+#import "NJOutputKeyPress.h"
+#import "NJOutputMapping.h"
+#import "NJOutputMouseMove.h"
+#import "NJOutputMouseButton.h"
+#import "NJOutputMouseScroll.h"
+#import "NJOutputSwitchMouseMode.h"
+
+@implementation NJOutput {
+    BOOL running;
+}
+
++ (NSString *)serializationCode {
+    [self doesNotRecognizeSelector:_cmd];
+    return nil;
+}
+
+- (NSDictionary *)serialize {
+    [self doesNotRecognizeSelector:_cmd];
+    return nil;    
+}
+
+- (BOOL)isEqual:(id)object {
+    return [object isKindOfClass:NJOutput.class]
+        && [[self serialize] isEqual:[object serialize]];
+}
+
+- (NSUInteger)hash {
+    return [[self serialize] hash];
+}
+
++ (NJOutput *)outputDeserialize:(NSDictionary *)serialization
+                  withMappings:(NSArray *)mappings {
+    // Don't crash loading old/bad mappings (but don't load them either).
+    if (![serialization isKindOfClass:NSDictionary.class])
+        return nil;
+    NSString *type = serialization[@"type"];
+    for (Class cls in @[NJOutputKeyPress.class,
+                        NJOutputMapping.class,
+                        NJOutputMouseMove.class,
+                        NJOutputMouseButton.class,
+                        NJOutputMouseScroll.class,
+                        NJOutputSwitchMouseMode.class
+         ]) {
+        if ([type isEqualToString:cls.serializationCode])
+            return [cls outputDeserialize:serialization withMappings:mappings];
+    }
+    
+    return nil;
+}
+
+- (void)trigger {
+}
+
+- (void)untrigger {
+}
+
+- (BOOL)update:(NJInputController *)jc {
+    return NO;
+}
+
+- (BOOL)isContinuous {
+    return NO;
+}
+
+- (BOOL)running {
+    return running;
+}
+
+- (void)setRunning:(BOOL)newRunning {
+    if (running != newRunning) {
+        running = newRunning;
+        if (running)
+            [self trigger];
+        else
+            [self untrigger];
+    }
+}
+
+
+@end
diff --git a/NJOutputController.h b/NJOutputController.h
new file mode 100644 (file)
index 0000000..bf590a6
--- /dev/null
@@ -0,0 +1,38 @@
+//
+//  NJOutputController.h
+//  Enjoy
+//
+//  Created by Sam McCall on 5/05/09.
+//  Copyright 2009 University of Otago. All rights reserved.
+//
+
+#import "NJKeyInputField.h"
+
+@class NJMappingsController;
+@class NJInputController;
+@class NJOutput;
+@class NJOutputMouseMove;
+
+@interface NJOutputController : NSObject <NJKeyInputFieldDelegate> {
+    IBOutlet NJKeyInputField *keyInput;
+    IBOutlet NSMatrix *radioButtons;
+    IBOutlet NSSegmentedControl *mouseDirSelect;
+    IBOutlet NSSegmentedControl *mouseBtnSelect;
+    IBOutlet NSSegmentedControl *scrollDirSelect;
+    IBOutlet NSTextField *title;
+    IBOutlet NSPopUpButton *mappingPopup;
+    IBOutlet NJMappingsController *mappingsController;
+    IBOutlet NJInputController *inputController;
+}
+
+@property (assign) BOOL enabled;
+
+- (void)loadCurrent;
+- (void)refreshMappings;
+- (IBAction)radioChanged:(id)sender;
+- (IBAction)mdirChanged:(id)sender;
+- (IBAction)mbtnChanged:(id)sender;
+- (IBAction)sdirChanged:(id)sender;
+- (void)focusKey;
+
+@end
diff --git a/NJOutputController.m b/NJOutputController.m
new file mode 100644 (file)
index 0000000..f05c615
--- /dev/null
@@ -0,0 +1,235 @@
+//
+//  NJOutputController.m
+//  Enjoy
+//
+//  Created by Sam McCall on 5/05/09.
+//
+
+#import "NJOutputController.h"
+
+#import "NJMappingsController.h"
+#import "NJMapping.h"
+#import "NJInput.h"
+#import "NJInputController.h"
+#import "NJKeyInputField.h"
+#import "NJOutputMapping.h"
+#import "NJOutputController.h"
+#import "NJOutputKeyPress.h"
+#import "NJOutputMouseButton.h"
+#import "NJOutputMouseMove.h"
+#import "NJOutputMouseScroll.h"
+#import "NJOutputSwitchMouseMode.h"
+
+@implementation NJOutputController
+
+- (void)cleanUpInterface {
+    NSInteger row = radioButtons.selectedRow;
+    
+    if (row != 1) {
+        keyInput.keyCode = -1;
+        [keyInput resignIfFirstResponder];
+    }
+    
+    if (row != 2) {
+        [mappingPopup selectItemAtIndex:-1];
+        [mappingPopup resignIfFirstResponder];
+    } else if (!mappingPopup.selectedItem)
+        [mappingPopup selectItemAtIndex:0];
+    
+    if (row != 3) {
+        mouseDirSelect.selectedSegment = -1;
+        [mouseDirSelect resignIfFirstResponder];
+    } else if (mouseDirSelect.selectedSegment == -1)
+        mouseDirSelect.selectedSegment = 0;
+    
+    if (row != 4) {
+        mouseBtnSelect.selectedSegment = -1;
+        [mouseBtnSelect resignIfFirstResponder];
+    } else if (mouseBtnSelect.selectedSegment == -1)
+        mouseBtnSelect.selectedSegment = 0;
+    
+    if (row != 5) {
+        scrollDirSelect.selectedSegment = -1;
+        [scrollDirSelect resignIfFirstResponder];
+    } else if (scrollDirSelect.selectedSegment == -1)
+        scrollDirSelect.selectedSegment = 0;    
+}
+
+- (IBAction)radioChanged:(NSView *)sender {
+    [sender.window makeFirstResponder:sender];
+    if (radioButtons.selectedRow == 1)
+        [keyInput.window makeFirstResponder:keyInput];
+    [self commit];
+}
+
+- (void)keyInputField:(NJKeyInputField *)keyInput didChangeKey:(CGKeyCode)keyCode {
+    [radioButtons selectCellAtRow:1 column:0];
+    [radioButtons.window makeFirstResponder:radioButtons];
+    [self commit];
+}
+
+- (void)keyInputFieldDidClear:(NJKeyInputField *)keyInput {
+    [radioButtons selectCellAtRow:0 column:0];
+    [self commit];
+}
+
+- (void)mappingChosen:(id)sender {
+    [radioButtons selectCellAtRow:2 column:0];
+    [mappingPopup.window makeFirstResponder:mappingPopup];
+    [self commit];
+}
+
+- (void)mdirChanged:(NSView *)sender {
+    [radioButtons selectCellAtRow:3 column:0];
+    [sender.window makeFirstResponder:sender];
+    [self commit];
+}
+
+- (void)mbtnChanged:(NSView *)sender {
+    [radioButtons selectCellAtRow:4 column:0];
+    [sender.window makeFirstResponder:sender];
+    [self commit];
+}
+
+- (void)sdirChanged:(NSView *)sender {
+    [radioButtons selectCellAtRow:5 column:0];
+    [sender.window makeFirstResponder:sender];
+    [self commit];
+}
+
+- (NJOutput *)currentOutput {
+    return mappingsController.currentMapping[inputController.selectedInput];
+}
+
+- (NJOutput *)makeOutput {
+    switch (radioButtons.selectedRow) {
+        case 0:
+            return nil;
+        case 1:
+            if (keyInput.hasKeyCode) {
+                NJOutputKeyPress *k = [[NJOutputKeyPress alloc] init];
+                k.vk = keyInput.keyCode;
+                return k;
+            } else {
+                return nil;
+            }
+            break;
+        case 2: {
+            NJOutputMapping *c = [[NJOutputMapping alloc] init];
+            c.mapping = mappingsController.mappings[mappingPopup.indexOfSelectedItem];
+            return c;
+        }
+        case 3: {
+            NJOutputMouseMove *mm = [[NJOutputMouseMove alloc] init];
+            mm.axis = mouseDirSelect.selectedSegment;
+            return mm;
+        }
+        case 4: {
+            NJOutputMouseButton *mb = [[NJOutputMouseButton alloc] init];
+            mb.button = mouseBtnSelect.selectedSegment == 0 ? kCGMouseButtonLeft : kCGMouseButtonRight;
+            return mb;
+        }
+        case 5: {
+            NJOutputMouseScroll *ms = [[NJOutputMouseScroll alloc] init];
+            ms.amount = scrollDirSelect.selectedSegment ? 1 : -1;
+            return ms;
+        }
+        case 6: {
+            NJOutputSwitchMouseMode *tms = [[NJOutputSwitchMouseMode alloc] init];
+            return tms;
+        }
+        default:
+            return nil;
+    }
+}
+
+- (void)commit {
+    [self cleanUpInterface];
+    mappingsController.currentMapping[inputController.selectedInput] = [self makeOutput];
+    [mappingsController save];
+}
+
+- (BOOL)enabled {
+    return [radioButtons isEnabled];
+}
+
+- (void)setEnabled:(BOOL)enabled {
+    [radioButtons setEnabled:enabled];
+    [keyInput setEnabled:enabled];
+    [mappingPopup setEnabled:enabled];
+    [mouseDirSelect setEnabled:enabled];
+    [mouseBtnSelect setEnabled:enabled];
+    [scrollDirSelect setEnabled:enabled];
+}
+
+- (void)loadOutput:(NJOutput *)output forInput:(NJInput *)input {
+    if (!input) {
+        self.enabled = NO;
+        title.stringValue = @"";
+    } else {
+        self.enabled = YES;
+        NSString *inpFullName = input.name;
+        for (id <NJInputPathElement> cur = input.base; cur; cur = cur.base) {
+            inpFullName = [[NSString alloc] initWithFormat:@"%@ > %@", cur.name, inpFullName];
+        }
+        title.stringValue = [[NSString alloc] initWithFormat:@"%@ > %@", mappingsController.currentMapping.name, inpFullName];
+    }
+
+    if ([output isKindOfClass:NJOutputKeyPress.class]) {
+        [radioButtons selectCellAtRow:1 column:0];
+        keyInput.keyCode = [(NJOutputKeyPress*)output vk];
+    } else if ([output isKindOfClass:NJOutputMapping.class]) {
+        [radioButtons selectCellAtRow:2 column:0];
+        NSUInteger idx = [mappingsController.mappings
+                          indexOfObject:[(NJOutputMapping *)output mapping]];
+        if (idx == NSNotFound) {
+            [radioButtons selectCellAtRow:self.enabled ? 0 : -1 column:0];
+            [mappingPopup selectItemAtIndex:-1];
+        } else
+            [mappingPopup selectItemAtIndex:idx];
+    }
+    else if ([output isKindOfClass:NJOutputMouseMove.class]) {
+        [radioButtons selectCellAtRow:3 column:0];
+        [mouseDirSelect setSelectedSegment:[(NJOutputMouseMove *)output axis]];
+    }
+    else if ([output isKindOfClass:NJOutputMouseButton.class]) {
+        [radioButtons selectCellAtRow:4 column:0];
+        mouseBtnSelect.selectedSegment = [(NJOutputMouseButton *)output button] == kCGMouseButtonLeft ? 0 : 1;
+    }
+    else if ([output isKindOfClass:NJOutputMouseScroll.class]) {
+        [radioButtons selectCellAtRow:5 column:0];
+        scrollDirSelect.selectedSegment = [(NJOutputMouseScroll *)output amount] > 0;
+    }
+    else if ([output isKindOfClass:NJOutputSwitchMouseMode.class]) {
+        [radioButtons selectCellAtRow:6 column:0];
+    } else {
+        [radioButtons selectCellAtRow:self.enabled ? 0 : -1 column:0];
+    }
+    [self cleanUpInterface];
+}
+
+- (void)loadCurrent {
+    [self loadOutput:self.currentOutput forInput:inputController.selectedInput];
+}
+
+- (void)focusKey {
+    if (radioButtons.selectedRow <= 1)
+        [keyInput.window makeFirstResponder:keyInput];
+    else
+        [keyInput resignIfFirstResponder];
+}
+
+- (void)refreshMappings {
+    NSInteger initialIndex = mappingPopup.indexOfSelectedItem;
+    [mappingPopup.menu removeAllItems];
+    for (NJMapping *mapping in mappingsController.mappings) {
+        NSMenuItem *item = [[NSMenuItem alloc] initWithTitle:mapping.name
+                                                      action:@selector(mappingChosen:)
+                                               keyEquivalent:@""];
+        item.target = self;
+        [mappingPopup.menu addItem:item];
+    }
+    [mappingPopup selectItemAtIndex:initialIndex];
+}
+
+@end
diff --git a/NJOutputKeyPress.h b/NJOutputKeyPress.h
new file mode 100644 (file)
index 0000000..052b010
--- /dev/null
@@ -0,0 +1,15 @@
+//
+//  NJOutputKeyPress.h
+//  Enjoy
+//
+//  Created by Sam McCall on 5/05/09.
+//  Copyright 2009 University of Otago. All rights reserved.
+//
+
+#import "NJOutput.h"
+
+@interface NJOutputKeyPress : NJOutput
+
+@property (nonatomic, assign) CGKeyCode vk;
+
+@end
diff --git a/NJOutputKeyPress.m b/NJOutputKeyPress.m
new file mode 100644 (file)
index 0000000..c2000d8
--- /dev/null
@@ -0,0 +1,41 @@
+//
+//  NJOutputKeyPress.m
+//  Enjoy
+//
+//  Created by Sam McCall on 5/05/09.
+//
+
+#import "NJOutputKeyPress.h"
+
+#import "NJKeyInputField.h"
+
+@implementation NJOutputKeyPress
+
++ (NSString *)serializationCode {
+    return @"key";
+}
+
+- (NSDictionary *)serialize {
+    return @{ @"type": @"key press", @"key": @(_vk) };
+}
+
++ (NJOutput *)outputDeserialize:(NSDictionary *)serialization
+                  withMappings:(NSArray *)mappings {
+    NJOutputKeyPress *output = [[NJOutputKeyPress alloc] init];
+    output.vk = [serialization[@"key"] intValue];
+    return output;
+}
+
+- (void)trigger {
+    CGEventRef keyDown = CGEventCreateKeyboardEvent(NULL, _vk, YES);
+    CGEventPost(kCGHIDEventTap, keyDown);
+    CFRelease(keyDown);
+}
+
+- (void)untrigger {
+    CGEventRef keyUp = CGEventCreateKeyboardEvent(NULL, _vk, NO);
+    CGEventPost(kCGHIDEventTap, keyUp);
+    CFRelease(keyUp);
+}
+
+@end
diff --git a/NJOutputMapping.h b/NJOutputMapping.h
new file mode 100644 (file)
index 0000000..e8c3029
--- /dev/null
@@ -0,0 +1,17 @@
+//
+//  NJOutputMapping.h
+//  Enjoy
+//
+//  Created by Sam McCall on 6/05/09.
+//  Copyright 2009 University of Otago. All rights reserved.
+//
+
+#import "NJOutput.h"
+
+@class NJMapping;
+
+@interface NJOutputMapping : NJOutput
+
+@property (nonatomic, weak) NJMapping *mapping;
+
+@end
diff --git a/NJOutputMapping.m b/NJOutputMapping.m
new file mode 100644 (file)
index 0000000..e411172
--- /dev/null
@@ -0,0 +1,44 @@
+//
+//  NJOutputMapping.m
+//  Enjoy
+//
+//  Created by Sam McCall on 6/05/09.
+//
+
+#import "NJOutputMapping.h"
+
+#import "ApplicationController.h"
+#import "NJMapping.h"
+#import "NJMappingsController.h"
+
+@implementation NJOutputMapping
+
++ (NSString *)serializationCode {
+    return @"mapping";
+}
+
+- (NSDictionary *)serialize {
+    return _mapping
+        ? @{ @"type": @"mapping", @"name": _mapping.name }
+        : nil;
+}
+
++ (NJOutputMapping *)outputDeserialize:(NSDictionary *)serialization
+                        withMappings:(NSArray *)mappings {
+    NSString *name = serialization[@"name"];
+    NJOutputMapping *output = [[NJOutputMapping alloc] init];
+    for (NJMapping *mapping in mappings) {
+        if ([mapping.name isEqualToString:name]) {
+            output.mapping = mapping;
+            return output;
+        }
+    }
+    return nil;
+}
+
+- (void)trigger {
+    ApplicationController *ctrl = NSApplication.sharedApplication.delegate;
+    [ctrl.mappingsController activateMapping:_mapping];
+}
+
+@end
diff --git a/NJOutputMouseButton.h b/NJOutputMouseButton.h
new file mode 100644 (file)
index 0000000..4d790e5
--- /dev/null
@@ -0,0 +1,14 @@
+//
+//  NJOutputMouseButton.h
+//  Enjoy
+//
+//  Created by Yifeng Huang on 7/27/12.
+//
+
+#import "NJOutput.h"
+
+@interface NJOutputMouseButton : NJOutput
+
+@property (nonatomic, assign) CGMouseButton button;
+
+@end
diff --git a/NJOutputMouseButton.m b/NJOutputMouseButton.m
new file mode 100644 (file)
index 0000000..0cc403f
--- /dev/null
@@ -0,0 +1,51 @@
+//
+//  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": @"mouse button", @"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
diff --git a/NJOutputMouseMove.h b/NJOutputMouseMove.h
new file mode 100644 (file)
index 0000000..21db416
--- /dev/null
@@ -0,0 +1,14 @@
+//
+//  NJOutputMouseMove.h
+//  Enjoy
+//
+//  Created by Yifeng Huang on 7/26/12.
+//
+
+#import "NJOutput.h"
+
+@interface NJOutputMouseMove : NJOutput
+
+@property (nonatomic, assign) int axis;
+
+@end
diff --git a/NJOutputMouseMove.m b/NJOutputMouseMove.m
new file mode 100644 (file)
index 0000000..5e59d4e
--- /dev/null
@@ -0,0 +1,85 @@
+//
+//  NJOutputMouseMove.m
+//  Enjoy
+//
+//  Created by Yifeng Huang on 7/26/12.
+//
+
+#import "NJOutputMouseMove.h"
+
+#import "NJInputController.h"
+
+@implementation NJOutputMouseMove {
+    int sign;
+}
+
+-(BOOL) isContinuous {
+    return YES;
+}
+
++ (NSString *)serializationCode {
+    return @"mouse move";
+}
+
+- (NSDictionary *)serialize {
+    return @{ @"type": @"mouse move", @"axis": @(_axis) };
+}
+
++ (NJOutput *)outputDeserialize:(NSDictionary *)serialization
+                  withMappings:(NSArray *)mappings {
+       NJOutputMouseMove *output = [[NJOutputMouseMove alloc] init];
+    output.axis = [serialization[@"axis"] intValue];
+       return output;
+}
+
+- (BOOL)update:(NJInputController *)jc {
+    if (fabsf(self.magnitude) < 0.01) {
+        sign = 0;
+        return NO; // dead zone
+    }
+
+    // If the input crossed over High/Low, this output is done.
+    if (!sign)
+        sign = self.magnitude < 0 ? -1 : 1;
+    else if (sign / self.magnitude < 0) {
+        sign = 0;
+        return NO;
+    }
+    
+    CGFloat height = NSScreen.mainScreen.frame.size.height;
+    
+    // TODO
+    float speed = 4.f;
+    if (jc.frontWindowOnly)
+        speed = 12.f;
+    float dx = 0.f, dy = 0.f;
+    if (_axis == 0)
+        dx = self.magnitude * speed;
+    else
+        dy = self.magnitude * speed;
+    NSPoint mouseLoc = jc.mouseLoc;
+    mouseLoc.x += dx;
+    mouseLoc.y -= dy;
+    jc.mouseLoc = mouseLoc;
+    
+    CGEventRef move = CGEventCreateMouseEvent(NULL, kCGEventMouseMoved,
+                                              CGPointMake(mouseLoc.x, height - mouseLoc.y),
+                                              0);
+    CGEventSetType(move, kCGEventMouseMoved);
+    CGEventSetIntegerValueField(move, kCGMouseEventDeltaX, (int)dx);
+    CGEventSetIntegerValueField(move, kCGMouseEventDeltaY, (int)dy);
+    
+    if (jc.frontWindowOnly) {
+        ProcessSerialNumber psn;
+        GetFrontProcess(&psn);
+        CGEventPostToPSN(&psn, move);
+    }
+    else {
+        CGEventPost(kCGHIDEventTap, move);
+    }
+    
+    CFRelease(move);
+    return YES;
+}
+
+@end
diff --git a/NJOutputMouseScroll.h b/NJOutputMouseScroll.h
new file mode 100644 (file)
index 0000000..6ef2cdc
--- /dev/null
@@ -0,0 +1,14 @@
+//
+//  NJOutputMouseScroll.h
+//  Enjoy
+//
+//  Created by Yifeng Huang on 7/28/12.
+//
+
+#import "NJOutput.h"
+
+@interface NJOutputMouseScroll : NJOutput
+
+@property (nonatomic, assign) int amount;
+
+@end
diff --git a/NJOutputMouseScroll.m b/NJOutputMouseScroll.m
new file mode 100644 (file)
index 0000000..9057125
--- /dev/null
@@ -0,0 +1,69 @@
+//
+//  NJOutputMouseScroll.m
+//  Enjoy
+//
+//  Created by Yifeng Huang on 7/28/12.
+//
+
+#import "NJOutputMouseScroll.h"
+
+@implementation NJOutputMouseScroll {
+    int sign;
+}
+
++ (NSString *)serializationCode {
+    return @"mouse scroll";
+}
+
+- (NSDictionary *)serialize {
+    return @{ @"type": @"mouse scroll", @"amount": @(_amount) };
+}
+
++ (NJOutput *)outputDeserialize:(NSDictionary *)serialization
+                  withMappings:(NSArray *)mappings {
+       NJOutputMouseScroll *output = [[NJOutputMouseScroll alloc] init];
+    output.amount = [serialization[@"amount"] intValue];
+       return output;
+}
+
+- (void)trigger {
+    if (!self.magnitude) {
+        CGEventRef scroll = CGEventCreateScrollWheelEvent(NULL,
+                                                          kCGScrollEventUnitLine,
+                                                          1,
+                                                          _amount);
+        CGEventPost(kCGHIDEventTap, scroll);
+        CFRelease(scroll);
+    }
+}
+
+- (BOOL)update:(NJInputController *)jc {
+    if (fabsf(self.magnitude) < 0.01f) {
+        sign = 0;
+        return NO; // dead zone
+    }
+    
+    // If the input crossed over High/Low, this output is done.
+    if (!sign)
+        sign = self.magnitude < 0 ? -1 : 1;
+    else if (sign / self.magnitude < 0) {
+        sign = 0;
+        return NO;
+    }
+
+    int amount = (int)(16.f * fabsf(self.magnitude) * _amount);
+    CGEventRef scroll = CGEventCreateScrollWheelEvent(NULL,
+                                                      kCGScrollEventUnitPixel,
+                                                      1,
+                                                      amount);
+    CGEventPost(kCGHIDEventTap, scroll);
+    CFRelease(scroll);
+
+    return YES;
+}
+
+- (BOOL)isContinuous {
+    return YES;
+}
+
+@end
diff --git a/NJOutputSwitchMouseMode.h b/NJOutputSwitchMouseMode.h
new file mode 100644 (file)
index 0000000..790f84b
--- /dev/null
@@ -0,0 +1,12 @@
+//
+//  NJOutputSwitchMouseMode.h
+//  Enjoy
+//
+//  Created by Yifeng Huang on 7/28/12.
+//
+
+#import "NJOutput.h"
+
+@interface NJOutputSwitchMouseMode : NJOutput
+
+@end
diff --git a/NJOutputSwitchMouseMode.m b/NJOutputSwitchMouseMode.m
new file mode 100644 (file)
index 0000000..3332a91
--- /dev/null
@@ -0,0 +1,35 @@
+//
+//  NJOutputSwitchMouseMode.m
+//  Enjoy
+//
+//  Created by Yifeng Huang on 7/28/12.
+//
+
+#import "NJOutputSwitchMouseMode.h"
+
+#import "ApplicationController.h"
+#import "NJInputController.h"
+
+@implementation NJOutputSwitchMouseMode
+
++ (NSString *)serializationCode {
+    return @"switch mouse mode";
+}
+
+- (NSDictionary *)serialize {
+    return @{ @"type": @"switch mouse mode" };
+}
+
++ (NJOutput *)outputDeserialize:(NSDictionary *)serialization
+                  withMappings:(NSArray *)mappings {
+    return [[NJOutputSwitchMouseMode alloc] init];
+}
+- (void)trigger {
+    // FIXME: It's hacky to get at the controller this way, but it's
+    // also hacky to pass it. Shouldn't need to do either.
+    ApplicationController *ac = NSApplication.sharedApplication.delegate;
+    NJInputController *jc = ac.inputController;
+    jc.frontWindowOnly = !jc.frontWindowOnly;
+}
+
+@end
diff --git a/Target.h b/Target.h
deleted file mode 100644 (file)
index 1a37f01..0000000
--- a/Target.h
+++ /dev/null
@@ -1,26 +0,0 @@
-//
-//  Target.h
-//  Enjoy
-//
-//  Created by Sam McCall on 5/05/09.
-//  Copyright 2009 University of Otago. All rights reserved.
-//
-
-@class NJInputController;
-
-@interface Target : NSObject
-
-@property (nonatomic, assign) float magnitude;
-@property (nonatomic, assign) BOOL running;
-@property (nonatomic, readonly) BOOL isContinuous;
-
-- (void)trigger;
-- (void)untrigger;
-- (BOOL)update:(NJInputController *)jc;
-
-- (NSDictionary *)serialize;
-+ (Target *)targetDeserialize:(NSDictionary *)serialization
-                  withMappings:(NSArray *)mappings;
-+ (NSString *)serializationCode;
-
-@end
diff --git a/Target.m b/Target.m
deleted file mode 100644 (file)
index 097562e..0000000
--- a/Target.m
+++ /dev/null
@@ -1,89 +0,0 @@
-//
-//  Target.m
-//  Enjoy
-//
-//  Created by Sam McCall on 5/05/09.
-//
-
-#import "Target.h"
-
-#import "TargetKeyboard.h"
-#import "TargetConfig.h"
-#import "TargetMouseMove.h"
-#import "TargetMouseBtn.h"
-#import "TargetMouseScroll.h"
-#import "TargetToggleMouseScope.h"
-
-@implementation Target {
-    BOOL running;
-}
-
-+ (NSString *)serializationCode {
-    [self doesNotRecognizeSelector:_cmd];
-    return nil;
-}
-
-- (NSDictionary *)serialize {
-    [self doesNotRecognizeSelector:_cmd];
-    return nil;    
-}
-
-- (BOOL)isEqual:(id)object {
-    return [object isKindOfClass:Target.class]
-        && [[self serialize] isEqual:[object serialize]];
-}
-
-- (NSUInteger)hash {
-    return [[self serialize] hash];
-}
-
-+ (Target *)targetDeserialize:(NSDictionary *)serialization
-                  withMappings:(NSArray *)mappings {
-    // Don't crash loading old/bad mappings (but don't load them either).
-    if (![serialization isKindOfClass:NSDictionary.class])
-        return nil;
-    NSString *type = serialization[@"type"];
-    for (Class cls in @[TargetKeyboard.class,
-                        TargetConfig.class,
-                        TargetMouseMove.class,
-                        TargetMouseBtn.class,
-                        TargetMouseScroll.class,
-                        TargetToggleMouseScope.class
-         ]) {
-        if ([type isEqualToString:cls.serializationCode])
-            return [cls targetDeserialize:serialization withMappings:mappings];
-    }
-    
-    return nil;
-}
-
-- (void)trigger {
-}
-
-- (void)untrigger {
-}
-
-- (BOOL)update:(NJInputController *)jc {
-    return NO;
-}
-
-- (BOOL)isContinuous {
-    return NO;
-}
-
-- (BOOL)running {
-    return running;
-}
-
-- (void)setRunning:(BOOL)newRunning {
-    if (running != newRunning) {
-        running = newRunning;
-        if (running)
-            [self trigger];
-        else
-            [self untrigger];
-    }
-}
-
-
-@end
diff --git a/TargetConfig.h b/TargetConfig.h
deleted file mode 100644 (file)
index 1018e5d..0000000
+++ /dev/null
@@ -1,17 +0,0 @@
-//
-//  TargetConfig.h
-//  Enjoy
-//
-//  Created by Sam McCall on 6/05/09.
-//  Copyright 2009 University of Otago. All rights reserved.
-//
-
-#import "Target.h"
-
-@class NJMapping;
-
-@interface TargetConfig : Target
-
-@property (nonatomic, weak) NJMapping *mapping;
-
-@end
diff --git a/TargetConfig.m b/TargetConfig.m
deleted file mode 100644 (file)
index 0f892c6..0000000
+++ /dev/null
@@ -1,44 +0,0 @@
-//
-//  TargetConfig.m
-//  Enjoy
-//
-//  Created by Sam McCall on 6/05/09.
-//
-
-#import "TargetConfig.h"
-
-#import "ApplicationController.h"
-#import "NJMapping.h"
-#import "NJMappingsController.h"
-
-@implementation TargetConfig
-
-+ (NSString *)serializationCode {
-    return @"mapping";
-}
-
-- (NSDictionary *)serialize {
-    return _mapping
-        ? @{ @"type": @"mapping", @"name": _mapping.name }
-        : nil;
-}
-
-+ (TargetConfig *)targetDeserialize:(NSDictionary *)serialization
-                        withMappings:(NSArray *)mappings {
-    NSString *name = serialization[@"name"];
-    TargetConfig *target = [[TargetConfig alloc] init];
-    for (NJMapping *mapping in mappings) {
-        if ([mapping.name isEqualToString:name]) {
-            target.mapping = mapping;
-            return target;
-        }
-    }
-    return nil;
-}
-
-- (void)trigger {
-    ApplicationController *ctrl = NSApplication.sharedApplication.delegate;
-    [ctrl.mappingsController activateMapping:_mapping];
-}
-
-@end
diff --git a/TargetController.h b/TargetController.h
deleted file mode 100644 (file)
index da7974c..0000000
+++ /dev/null
@@ -1,38 +0,0 @@
-//
-//  TargetController.h
-//  Enjoy
-//
-//  Created by Sam McCall on 5/05/09.
-//  Copyright 2009 University of Otago. All rights reserved.
-//
-
-#import "NJKeyInputField.h"
-
-@class NJMappingsController;
-@class NJInputController;
-@class Target;
-@class TargetMouseMove;
-
-@interface TargetController : NSObject <NJKeyInputFieldDelegate> {
-    IBOutlet NJKeyInputField *keyInput;
-    IBOutlet NSMatrix *radioButtons;
-    IBOutlet NSSegmentedControl *mouseDirSelect;
-    IBOutlet NSSegmentedControl *mouseBtnSelect;
-    IBOutlet NSSegmentedControl *scrollDirSelect;
-    IBOutlet NSTextField *title;
-    IBOutlet NSPopUpButton *mappingPopup;
-    IBOutlet NJMappingsController *mappingsController;
-    IBOutlet NJInputController *joystickController;
-}
-
-@property (assign) BOOL enabled;
-
-- (void)loadCurrent;
-- (void)refreshMappings;
-- (IBAction)radioChanged:(id)sender;
-- (IBAction)mdirChanged:(id)sender;
-- (IBAction)mbtnChanged:(id)sender;
-- (IBAction)sdirChanged:(id)sender;
-- (void)focusKey;
-
-@end
diff --git a/TargetController.m b/TargetController.m
deleted file mode 100644 (file)
index 1da2c99..0000000
+++ /dev/null
@@ -1,235 +0,0 @@
-//
-//  TargetController.m
-//  Enjoy
-//
-//  Created by Sam McCall on 5/05/09.
-//
-
-#import "TargetController.h"
-
-#import "NJMappingsController.h"
-#import "NJMapping.h"
-#import "NJInput.h"
-#import "NJInputController.h"
-#import "NJKeyInputField.h"
-#import "TargetConfig.h"
-#import "TargetController.h"
-#import "TargetKeyboard.h"
-#import "TargetMouseBtn.h"
-#import "TargetMouseMove.h"
-#import "TargetMouseScroll.h"
-#import "TargetToggleMouseScope.h"
-
-@implementation TargetController
-
-- (void)cleanUpInterface {
-    NSInteger row = radioButtons.selectedRow;
-    
-    if (row != 1) {
-        keyInput.keyCode = -1;
-        [keyInput resignIfFirstResponder];
-    }
-    
-    if (row != 2) {
-        [mappingPopup selectItemAtIndex:-1];
-        [mappingPopup resignIfFirstResponder];
-    } else if (!mappingPopup.selectedItem)
-        [mappingPopup selectItemAtIndex:0];
-    
-    if (row != 3) {
-        mouseDirSelect.selectedSegment = -1;
-        [mouseDirSelect resignIfFirstResponder];
-    } else if (mouseDirSelect.selectedSegment == -1)
-        mouseDirSelect.selectedSegment = 0;
-    
-    if (row != 4) {
-        mouseBtnSelect.selectedSegment = -1;
-        [mouseBtnSelect resignIfFirstResponder];
-    } else if (mouseBtnSelect.selectedSegment == -1)
-        mouseBtnSelect.selectedSegment = 0;
-    
-    if (row != 5) {
-        scrollDirSelect.selectedSegment = -1;
-        [scrollDirSelect resignIfFirstResponder];
-    } else if (scrollDirSelect.selectedSegment == -1)
-        scrollDirSelect.selectedSegment = 0;    
-}
-
-- (IBAction)radioChanged:(NSView *)sender {
-    [sender.window makeFirstResponder:sender];
-    if (radioButtons.selectedRow == 1)
-        [keyInput.window makeFirstResponder:keyInput];
-    [self commit];
-}
-
-- (void)keyInputField:(NJKeyInputField *)keyInput didChangeKey:(CGKeyCode)keyCode {
-    [radioButtons selectCellAtRow:1 column:0];
-    [radioButtons.window makeFirstResponder:radioButtons];
-    [self commit];
-}
-
-- (void)keyInputFieldDidClear:(NJKeyInputField *)keyInput {
-    [radioButtons selectCellAtRow:0 column:0];
-    [self commit];
-}
-
-- (void)mappingChosen:(id)sender {
-    [radioButtons selectCellAtRow:2 column:0];
-    [mappingPopup.window makeFirstResponder:mappingPopup];
-    [self commit];
-}
-
-- (void)mdirChanged:(NSView *)sender {
-    [radioButtons selectCellAtRow:3 column:0];
-    [sender.window makeFirstResponder:sender];
-    [self commit];
-}
-
-- (void)mbtnChanged:(NSView *)sender {
-    [radioButtons selectCellAtRow:4 column:0];
-    [sender.window makeFirstResponder:sender];
-    [self commit];
-}
-
-- (void)sdirChanged:(NSView *)sender {
-    [radioButtons selectCellAtRow:5 column:0];
-    [sender.window makeFirstResponder:sender];
-    [self commit];
-}
-
-- (Target *)currentTarget {
-    return mappingsController.currentMapping[joystickController.selectedInput];
-}
-
-- (Target *)makeTarget {
-    switch (radioButtons.selectedRow) {
-        case 0:
-            return nil;
-        case 1:
-            if (keyInput.hasKeyCode) {
-                TargetKeyboard *k = [[TargetKeyboard alloc] init];
-                k.vk = keyInput.keyCode;
-                return k;
-            } else {
-                return nil;
-            }
-            break;
-        case 2: {
-            TargetConfig *c = [[TargetConfig alloc] init];
-            c.mapping = mappingsController.mappings[mappingPopup.indexOfSelectedItem];
-            return c;
-        }
-        case 3: {
-            TargetMouseMove *mm = [[TargetMouseMove alloc] init];
-            mm.axis = mouseDirSelect.selectedSegment;
-            return mm;
-        }
-        case 4: {
-            TargetMouseBtn *mb = [[TargetMouseBtn alloc] init];
-            mb.button = mouseBtnSelect.selectedSegment == 0 ? kCGMouseButtonLeft : kCGMouseButtonRight;
-            return mb;
-        }
-        case 5: {
-            TargetMouseScroll *ms = [[TargetMouseScroll alloc] init];
-            ms.amount = scrollDirSelect.selectedSegment ? 1 : -1;
-            return ms;
-        }
-        case 6: {
-            TargetToggleMouseScope *tms = [[TargetToggleMouseScope alloc] init];
-            return tms;
-        }
-        default:
-            return nil;
-    }
-}
-
-- (void)commit {
-    [self cleanUpInterface];
-    mappingsController.currentMapping[joystickController.selectedInput] = [self makeTarget];
-    [mappingsController save];
-}
-
-- (BOOL)enabled {
-    return [radioButtons isEnabled];
-}
-
-- (void)setEnabled:(BOOL)enabled {
-    [radioButtons setEnabled:enabled];
-    [keyInput setEnabled:enabled];
-    [mappingPopup setEnabled:enabled];
-    [mouseDirSelect setEnabled:enabled];
-    [mouseBtnSelect setEnabled:enabled];
-    [scrollDirSelect setEnabled:enabled];
-}
-
-- (void)loadTarget:(Target *)target forInput:(NJInput *)input {
-    if (!input) {
-        self.enabled = NO;
-        title.stringValue = @"";
-    } else {
-        self.enabled = YES;
-        NSString *inpFullName = input.name;
-        for (id <NJInputPathElement> cur = input.base; cur; cur = cur.base) {
-            inpFullName = [[NSString alloc] initWithFormat:@"%@ > %@", cur.name, inpFullName];
-        }
-        title.stringValue = [[NSString alloc] initWithFormat:@"%@ > %@", mappingsController.currentMapping.name, inpFullName];
-    }
-
-    if ([target isKindOfClass:TargetKeyboard.class]) {
-        [radioButtons selectCellAtRow:1 column:0];
-        keyInput.keyCode = [(TargetKeyboard*)target vk];
-    } else if ([target isKindOfClass:TargetConfig.class]) {
-        [radioButtons selectCellAtRow:2 column:0];
-        NSUInteger idx = [mappingsController.mappings
-                          indexOfObject:[(TargetConfig *)target mapping]];
-        if (idx == NSNotFound) {
-            [radioButtons selectCellAtRow:self.enabled ? 0 : -1 column:0];
-            [mappingPopup selectItemAtIndex:-1];
-        } else
-            [mappingPopup selectItemAtIndex:idx];
-    }
-    else if ([target isKindOfClass:TargetMouseMove.class]) {
-        [radioButtons selectCellAtRow:3 column:0];
-        [mouseDirSelect setSelectedSegment:[(TargetMouseMove *)target axis]];
-    }
-    else if ([target isKindOfClass:TargetMouseBtn.class]) {
-        [radioButtons selectCellAtRow:4 column:0];
-        mouseBtnSelect.selectedSegment = [(TargetMouseBtn *)target button] == kCGMouseButtonLeft ? 0 : 1;
-    }
-    else if ([target isKindOfClass:TargetMouseScroll.class]) {
-        [radioButtons selectCellAtRow:5 column:0];
-        scrollDirSelect.selectedSegment = [(TargetMouseScroll *)target amount] > 0;
-    }
-    else if ([target isKindOfClass:TargetToggleMouseScope.class]) {
-        [radioButtons selectCellAtRow:6 column:0];
-    } else {
-        [radioButtons selectCellAtRow:self.enabled ? 0 : -1 column:0];
-    }
-    [self cleanUpInterface];
-}
-
-- (void)loadCurrent {
-    [self loadTarget:self.currentTarget forInput:joystickController.selectedInput];
-}
-
-- (void)focusKey {
-    if (radioButtons.selectedRow <= 1)
-        [keyInput.window makeFirstResponder:keyInput];
-    else
-        [keyInput resignIfFirstResponder];
-}
-
-- (void)refreshMappings {
-    NSInteger initialIndex = mappingPopup.indexOfSelectedItem;
-    [mappingPopup.menu removeAllItems];
-    for (NJMapping *mapping in mappingsController.mappings) {
-        NSMenuItem *item = [[NSMenuItem alloc] initWithTitle:mapping.name
-                                                      action:@selector(mappingChosen:)
-                                               keyEquivalent:@""];
-        item.target = self;
-        [mappingPopup.menu addItem:item];
-    }
-    [mappingPopup selectItemAtIndex:initialIndex];
-}
-
-@end
diff --git a/TargetKeyboard.h b/TargetKeyboard.h
deleted file mode 100644 (file)
index 551bb8d..0000000
+++ /dev/null
@@ -1,15 +0,0 @@
-//
-//  TargetKeyboard.h
-//  Enjoy
-//
-//  Created by Sam McCall on 5/05/09.
-//  Copyright 2009 University of Otago. All rights reserved.
-//
-
-#import "Target.h"
-
-@interface TargetKeyboard : Target
-
-@property (nonatomic, assign) CGKeyCode vk;
-
-@end
diff --git a/TargetKeyboard.m b/TargetKeyboard.m
deleted file mode 100644 (file)
index eaabd07..0000000
+++ /dev/null
@@ -1,41 +0,0 @@
-//
-//  TargetKeyboard.m
-//  Enjoy
-//
-//  Created by Sam McCall on 5/05/09.
-//
-
-#import "TargetKeyboard.h"
-
-#import "NJKeyInputField.h"
-
-@implementation TargetKeyboard
-
-+ (NSString *)serializationCode {
-    return @"key";
-}
-
-- (NSDictionary *)serialize {
-    return @{ @"type": @"key", @"key": @(_vk) };
-}
-
-+ (Target *)targetDeserialize:(NSDictionary *)serialization
-                  withMappings:(NSArray *)mappings {
-    TargetKeyboard *target = [[TargetKeyboard alloc] init];
-    target.vk = [serialization[@"key"] intValue];
-    return target;
-}
-
-- (void)trigger {
-    CGEventRef keyDown = CGEventCreateKeyboardEvent(NULL, _vk, YES);
-    CGEventPost(kCGHIDEventTap, keyDown);
-    CFRelease(keyDown);
-}
-
-- (void)untrigger {
-    CGEventRef keyUp = CGEventCreateKeyboardEvent(NULL, _vk, NO);
-    CGEventPost(kCGHIDEventTap, keyUp);
-    CFRelease(keyUp);
-}
-
-@end
diff --git a/TargetMouseBtn.h b/TargetMouseBtn.h
deleted file mode 100644 (file)
index 2597b2d..0000000
+++ /dev/null
@@ -1,14 +0,0 @@
-//
-//  TargetMouseBtn.h
-//  Enjoy
-//
-//  Created by Yifeng Huang on 7/27/12.
-//
-
-#import "Target.h"
-
-@interface TargetMouseBtn : Target
-
-@property (nonatomic, assign) CGMouseButton button;
-
-@end
diff --git a/TargetMouseBtn.m b/TargetMouseBtn.m
deleted file mode 100644 (file)
index a19b484..0000000
+++ /dev/null
@@ -1,51 +0,0 @@
-//
-//  TargetMouseBtn.m
-//  Enjoy
-//
-//  Created by Yifeng Huang on 7/27/12.
-//
-
-#import "TargetMouseBtn.h"
-
-@implementation TargetMouseBtn
-
-+ (NSString *)serializationCode {
-    return @"mbtn";
-}
-
-- (NSDictionary *)serialize {
-    return @{ @"type": @"mbtn", @"button": @(_button) };
-}
-
-+ (Target *)targetDeserialize:(NSDictionary *)serialization
-                  withMappings:(NSArray *)mappings {
-       TargetMouseBtn *target = [[TargetMouseBtn alloc] init];
-    target.button = [serialization[@"button"] intValue];
-       return target;
-}
-
--(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
diff --git a/TargetMouseMove.h b/TargetMouseMove.h
deleted file mode 100644 (file)
index e91b569..0000000
+++ /dev/null
@@ -1,14 +0,0 @@
-//
-//  TargetMouseMove.h
-//  Enjoy
-//
-//  Created by Yifeng Huang on 7/26/12.
-//
-
-#import "Target.h"
-
-@interface TargetMouseMove : Target
-
-@property (nonatomic, assign) int axis;
-
-@end
diff --git a/TargetMouseMove.m b/TargetMouseMove.m
deleted file mode 100644 (file)
index b1d52a0..0000000
+++ /dev/null
@@ -1,85 +0,0 @@
-//
-//  TargetMouseMove.m
-//  Enjoy
-//
-//  Created by Yifeng Huang on 7/26/12.
-//
-
-#import "TargetMouseMove.h"
-
-#import "NJInputController.h"
-
-@implementation TargetMouseMove {
-    int sign;
-}
-
--(BOOL) isContinuous {
-    return YES;
-}
-
-+ (NSString *)serializationCode {
-    return @"mmove";
-}
-
-- (NSDictionary *)serialize {
-    return @{ @"type": @"mmove", @"axis": @(_axis) };
-}
-
-+ (Target *)targetDeserialize:(NSDictionary *)serialization
-                  withMappings:(NSArray *)mappings {
-       TargetMouseMove *target = [[TargetMouseMove alloc] init];
-    target.axis = [serialization[@"axis"] intValue];
-       return target;
-}
-
-- (BOOL)update:(NJInputController *)jc {
-    if (fabsf(self.magnitude) < 0.01) {
-        sign = 0;
-        return NO; // dead zone
-    }
-
-    // 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) {
-        sign = 0;
-        return NO;
-    }
-    
-    CGFloat height = NSScreen.mainScreen.frame.size.height;
-    
-    // TODO
-    float speed = 4.f;
-    if (jc.frontWindowOnly)
-        speed = 12.f;
-    float dx = 0.f, dy = 0.f;
-    if (_axis == 0)
-        dx = self.magnitude * speed;
-    else
-        dy = self.magnitude * speed;
-    NSPoint mouseLoc = jc.mouseLoc;
-    mouseLoc.x += dx;
-    mouseLoc.y -= dy;
-    jc.mouseLoc = mouseLoc;
-    
-    CGEventRef move = CGEventCreateMouseEvent(NULL, kCGEventMouseMoved,
-                                              CGPointMake(mouseLoc.x, height - mouseLoc.y),
-                                              0);
-    CGEventSetType(move, kCGEventMouseMoved);
-    CGEventSetIntegerValueField(move, kCGMouseEventDeltaX, (int)dx);
-    CGEventSetIntegerValueField(move, kCGMouseEventDeltaY, (int)dy);
-    
-    if (jc.frontWindowOnly) {
-        ProcessSerialNumber psn;
-        GetFrontProcess(&psn);
-        CGEventPostToPSN(&psn, move);
-    }
-    else {
-        CGEventPost(kCGHIDEventTap, move);
-    }
-    
-    CFRelease(move);
-    return YES;
-}
-
-@end
diff --git a/TargetMouseScroll.h b/TargetMouseScroll.h
deleted file mode 100644 (file)
index d261659..0000000
+++ /dev/null
@@ -1,14 +0,0 @@
-//
-//  TargetMouseScroll.h
-//  Enjoy
-//
-//  Created by Yifeng Huang on 7/28/12.
-//
-
-#import "Target.h"
-
-@interface TargetMouseScroll : Target
-
-@property (nonatomic, assign) int amount;
-
-@end
diff --git a/TargetMouseScroll.m b/TargetMouseScroll.m
deleted file mode 100644 (file)
index 8f87c02..0000000
+++ /dev/null
@@ -1,69 +0,0 @@
-//
-//  TargetMouseScroll.m
-//  Enjoy
-//
-//  Created by Yifeng Huang on 7/28/12.
-//
-
-#import "TargetMouseScroll.h"
-
-@implementation TargetMouseScroll {
-    int sign;
-}
-
-+ (NSString *)serializationCode {
-    return @"mscroll";
-}
-
-- (NSDictionary *)serialize {
-    return @{ @"type": @"mscroll", @"amount": @(_amount) };
-}
-
-+ (Target *)targetDeserialize:(NSDictionary *)serialization
-                  withMappings:(NSArray *)mappings {
-       TargetMouseScroll *target = [[TargetMouseScroll alloc] init];
-    target.amount = [serialization[@"amount"] intValue];
-       return target;
-}
-
-- (void)trigger {
-    if (!self.magnitude) {
-        CGEventRef scroll = CGEventCreateScrollWheelEvent(NULL,
-                                                          kCGScrollEventUnitLine,
-                                                          1,
-                                                          _amount);
-        CGEventPost(kCGHIDEventTap, scroll);
-        CFRelease(scroll);
-    }
-}
-
-- (BOOL)update:(NJInputController *)jc {
-    if (fabsf(self.magnitude) < 0.01f) {
-        sign = 0;
-        return NO; // dead zone
-    }
-    
-    // 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) {
-        sign = 0;
-        return NO;
-    }
-
-    int amount = (int)(16.f * fabsf(self.magnitude) * _amount);
-    CGEventRef scroll = CGEventCreateScrollWheelEvent(NULL,
-                                                      kCGScrollEventUnitPixel,
-                                                      1,
-                                                      amount);
-    CGEventPost(kCGHIDEventTap, scroll);
-    CFRelease(scroll);
-
-    return YES;
-}
-
-- (BOOL)isContinuous {
-    return YES;
-}
-
-@end
diff --git a/TargetToggleMouseScope.h b/TargetToggleMouseScope.h
deleted file mode 100644 (file)
index a935c67..0000000
+++ /dev/null
@@ -1,12 +0,0 @@
-//
-//  TargetToggleMouseScope.h
-//  Enjoy
-//
-//  Created by Yifeng Huang on 7/28/12.
-//
-
-#import "Target.h"
-
-@interface TargetToggleMouseScope : Target
-
-@end
diff --git a/TargetToggleMouseScope.m b/TargetToggleMouseScope.m
deleted file mode 100644 (file)
index 0413b73..0000000
+++ /dev/null
@@ -1,36 +0,0 @@
-//
-//  TargetToggleMouseScope.m
-//  Enjoy
-//
-//  Created by Yifeng Huang on 7/28/12.
-//
-
-#import "TargetToggleMouseScope.h"
-
-#import "ApplicationController.h"
-#import "NJInputController.h"
-
-@implementation TargetToggleMouseScope
-
-+ (NSString *)serializationCode {
-    return @"mtoggle";
-}
-
-- (NSDictionary *)serialize {
-    return @{ @"type": @"mtoggle" };
-}
-
-+ (Target *)targetDeserialize:(NSDictionary *)serialization
-                  withMappings:(NSArray *)mappings {
-       TargetToggleMouseScope *target = [[TargetToggleMouseScope alloc] init];
-       return target;
-}
-- (void)trigger {
-    // FIXME: It's hacky to get at the controller this way, but it's
-    // also hacky to pass it. Shouldn't need to do either.
-    ApplicationController *ac = NSApplication.sharedApplication.delegate;
-    NJInputController *jc = ac.inputController;
-    jc.frontWindowOnly = !jc.frontWindowOnly;
-}
-
-@end