From: Joe Wreschnig Date: Sun, 3 Mar 2013 22:49:27 +0000 (+0100) Subject: Rename the application delegate, and hopefully catch the last vestiges of the old... X-Git-Tag: version-1.0~48 X-Git-Url: https://git.yukkurigames.com/?a=commitdiff_plain;h=d0f4d54bb9eb66cbd19fa4dabb56fc09f42bd22d;p=enjoyable.git Rename the application delegate, and hopefully catch the last vestiges of the old names. --- diff --git a/ApplicationController.h b/ApplicationController.h deleted file mode 100644 index a1b8742..0000000 --- a/ApplicationController.h +++ /dev/null @@ -1,28 +0,0 @@ -// -// ApplicationController.h -// Enjoy -// -// Created by Sam McCall on 4/05/09. -// Copyright 2009 University of Otago. All rights reserved. -// - -@class NJInputController; -@class NJOutputController; -@class NJMappingsController; - -@interface ApplicationController : NSObject { - IBOutlet NSDrawer *drawer; - IBOutlet NSWindow *mainWindow; - IBOutlet NSToolbarItem *activeButton; - IBOutlet NSMenuItem *activeMenuItem; - IBOutlet NSMenu *dockMenuBase; -} - -@property (nonatomic, strong) IBOutlet NJInputController *inputController; -@property (nonatomic, strong) IBOutlet NJOutputController *outputController; -@property (nonatomic, strong) IBOutlet NJMappingsController *mappingsController; - -- (IBAction)toggleActivity:(id)sender; -- (void)mappingsChanged; - -@end diff --git a/ApplicationController.m b/ApplicationController.m deleted file mode 100644 index faad07a..0000000 --- a/ApplicationController.m +++ /dev/null @@ -1,111 +0,0 @@ -// -// ApplicationController.m -// Enjoy -// -// Created by Sam McCall on 4/05/09. -// - -#import "ApplicationController.h" - -#import "NJMapping.h" -#import "NJMappingsController.h" -#import "NJInputController.h" -#import "NJOutputController.h" -#import "NJEvents.h" - -@implementation ApplicationController { - BOOL active; -} - -- (void)didSwitchApplication:(NSNotification *)notification { - NSRunningApplication *currentApp = notification.userInfo[NSWorkspaceApplicationKey]; - [self.mappingsController activateMappingForProcess:currentApp.localizedName]; -} - -- (void)applicationDidFinishLaunching:(NSNotification *)notification { - [drawer open]; - self.outputController.enabled = NO; - [self.inputController setup]; - [self.mappingsController load]; - [NSNotificationCenter.defaultCenter - addObserver:self - selector:@selector(mappingDidChange:) - name:NJEventMappingChanged - object:nil]; - [NSNotificationCenter.defaultCenter - addObserver:self - selector:@selector(eventTranslationActivated:) - name:NJEventTranslationActivated - object:nil]; - [NSNotificationCenter.defaultCenter - addObserver:self - selector:@selector(eventTranslationDeactivated:) - name:NJEventTranslationDeactivated - object:nil]; -} - -- (void)applicationWillTerminate:(NSNotification *)aNotification { - [NSUserDefaults.standardUserDefaults synchronize]; -} - -- (void)eventTranslationActivated:(NSNotification *)note { - activeButton.image = [NSImage imageNamed:@"NSStopProgressFreestandingTemplate"]; - activeMenuItem.state = [note.object translatingEvents]; - [NSWorkspace.sharedWorkspace.notificationCenter - addObserver:self - selector:@selector(didSwitchApplication:) - name:NSWorkspaceDidActivateApplicationNotification - object:nil]; - NSLog(@"Listening for application changes."); -} - -- (void)eventTranslationDeactivated:(NSNotification *)note { - activeButton.image = [NSImage imageNamed:@"NSGoRightTemplate"]; - activeMenuItem.state = [note.object translatingEvents]; - [NSWorkspace.sharedWorkspace.notificationCenter - removeObserver:self - name:NSWorkspaceDidActivateApplicationNotification - object:nil]; - NSLog(@"Ignoring application changes."); -} - -- (IBAction)toggleActivity:(id)sender { - self.inputController.translatingEvents = !self.inputController.translatingEvents; -} - -- (NSInteger)firstMappingMenuIndex { - for (NSInteger i = dockMenuBase.numberOfItems - 1; i >= 0; --i) - if ([dockMenuBase itemAtIndex:i].isSeparatorItem) - return i + 1; - return dockMenuBase.numberOfItems; -} - -- (void)mappingsChanged { - NSInteger removeFrom = self.firstMappingMenuIndex; - while (dockMenuBase.numberOfItems > removeFrom) - [dockMenuBase removeItemAtIndex:dockMenuBase.numberOfItems - 1]; - int added = 0; - for (NJMapping *mapping in self.mappingsController.mappings) { - NSString *keyEquiv = ++added < 10 ? @(added).stringValue : @""; - [dockMenuBase addItemWithTitle:mapping.name - action:@selector(chooseMapping:) - keyEquivalent:keyEquiv]; - - } - [_outputController refreshMappings]; -} - -- (void)mappingDidChange:(NSNotification *)note { - NSInteger firstMapping = self.firstMappingMenuIndex; - NJMapping *current = note.object; - NSArray *mappings = self.mappingsController.mappings; - for (NSUInteger i = 0; i < mappings.count; ++i) - [dockMenuBase itemAtIndex:i + firstMapping].state = mappings[i] == current; -} - -- (void)chooseMapping:(id)sender { - NSInteger idx = [dockMenuBase indexOfItem:sender] - self.firstMappingMenuIndex; - NJMapping *chosen = self.mappingsController.mappings[idx]; - [_mappingsController activateMapping:chosen]; -} -@end diff --git a/English.lproj/MainMenu.xib b/English.lproj/MainMenu.xib index 8dd62bf..1a87bd7 100644 --- a/English.lproj/MainMenu.xib +++ b/English.lproj/MainMenu.xib @@ -1125,13 +1125,13 @@ - ApplicationController + EnjoyableApplicationDelegate NJMappingsController - NJInputController + NJDeviceController NJOutputController @@ -2237,147 +2237,6 @@ - - ApplicationController - NSObject - - toggleActivity: - id - - - toggleActivity: - - toggleActivity: - id - - - - NSToolbarItem - NSMenuItem - ConfigsController - NSMenu - NSDrawer - JoystickController - NSWindow - TargetController - - - - activeButton - NSToolbarItem - - - activeMenuItem - NSMenuItem - - - configsController - ConfigsController - - - dockMenuBase - NSMenu - - - drawer - NSDrawer - - - jsController - JoystickController - - - mainWindow - NSWindow - - - targetController - TargetController - - - - IBProjectSource - ./Classes/ApplicationController.h - - - - ConfigsController - NSObject - - id - id - id - id - - - - addPressed: - id - - - exportPressed: - id - - - importPressed: - id - - - removePressed: - id - - - - NSButton - NSTableView - TargetController - - - - removeButton - NSButton - - - tableView - NSTableView - - - targetController - TargetController - - - - IBProjectSource - ./Classes/ConfigsController.h - - - - JoystickController - NSObject - - ConfigsController - NSOutlineView - TargetController - - - - configsController - ConfigsController - - - outlineView - NSOutlineView - - - targetController - TargetController - - - - IBProjectSource - ./Classes/JoystickController.h - - NJKeyInputField NSTextField @@ -2397,92 +2256,6 @@ ./Classes/NJKeyInputField.h - - TargetController - NSObject - - id - id - id - id - id - - - - configChosen: - id - - - mbtnChanged: - id - - - mdirChanged: - id - - - radioChanged: - id - - - sdirChanged: - id - - - - NSPopUpButton - ConfigsController - JoystickController - NJKeyInputField - NSSegmentedControl - NSSegmentedControl - NSMatrix - NSSegmentedControl - NSTextField - - - - configPopup - NSPopUpButton - - - configsController - ConfigsController - - - joystickController - JoystickController - - - keyInput - NJKeyInputField - - - mouseBtnSelect - NSSegmentedControl - - - mouseDirSelect - NSSegmentedControl - - - radioButtons - NSMatrix - - - scrollDirSelect - NSSegmentedControl - - - title - NSTextField - - - - IBProjectSource - ./Classes/TargetController.h - - 0 diff --git a/Enjoyable.xcodeproj/project.pbxproj b/Enjoyable.xcodeproj/project.pbxproj index c633833..ccdd256 100644 --- a/Enjoyable.xcodeproj/project.pbxproj +++ b/Enjoyable.xcodeproj/project.pbxproj @@ -27,9 +27,9 @@ 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 */; }; + D594BEF90FAE6FF2007A85F2 /* NJDeviceController.m in Sources */ = {isa = PBXBuildFile; fileRef = D594BEF80FAE6FF2007A85F2 /* NJDeviceController.m */; }; D594BF000FAE7397007A85F2 /* IOKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = D594BEFF0FAE7397007A85F2 /* IOKit.framework */; }; - D594BF830FAE9661007A85F2 /* ApplicationController.m in Sources */ = {isa = PBXBuildFile; fileRef = D594BF820FAE9661007A85F2 /* ApplicationController.m */; }; + D594BF830FAE9661007A85F2 /* EnjoyableApplicationDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = D594BF820FAE9661007A85F2 /* EnjoyableApplicationDelegate.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 */; }; @@ -78,11 +78,11 @@ D594BE850FAE6219007A85F2 /* NJDevice.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = NJDevice.m; sourceTree = ""; }; D594BE880FAE64AD007A85F2 /* NJInput.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NJInput.h; sourceTree = ""; }; D594BE890FAE64AD007A85F2 /* NJInput.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = NJInput.m; sourceTree = ""; }; - D594BEF70FAE6FF2007A85F2 /* NJInputController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NJInputController.h; sourceTree = ""; }; - D594BEF80FAE6FF2007A85F2 /* NJInputController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = NJInputController.m; sourceTree = ""; }; + D594BEF70FAE6FF2007A85F2 /* NJDeviceController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NJDeviceController.h; sourceTree = ""; }; + D594BEF80FAE6FF2007A85F2 /* NJDeviceController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = NJDeviceController.m; sourceTree = ""; }; D594BEFF0FAE7397007A85F2 /* IOKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = IOKit.framework; path = /System/Library/Frameworks/IOKit.framework; sourceTree = ""; }; - D594BF810FAE9661007A85F2 /* ApplicationController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ApplicationController.h; sourceTree = ""; }; - D594BF820FAE9661007A85F2 /* ApplicationController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ApplicationController.m; sourceTree = ""; }; + D594BF810FAE9661007A85F2 /* EnjoyableApplicationDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = EnjoyableApplicationDelegate.h; sourceTree = ""; }; + D594BF820FAE9661007A85F2 /* EnjoyableApplicationDelegate.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = EnjoyableApplicationDelegate.m; sourceTree = ""; }; D5F8096F0FB093400006A4DE /* NJOutputMapping.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NJOutputMapping.h; sourceTree = ""; }; D5F809700FB093400006A4DE /* NJOutputMapping.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = NJOutputMapping.m; sourceTree = ""; }; EE1D7C9016E01E7000B000EB /* NSView+FirstResponder.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "NSView+FirstResponder.h"; sourceTree = ""; }; @@ -109,44 +109,43 @@ 080E96DDFE201D6D7F000001 /* Classes */ = { isa = PBXGroup; children = ( - D5617D290FAF579A00928B3A /* NJInputAnalog.h */, - D5617D2A0FAF579A00928B3A /* NJInputAnalog.m */, + D594BF810FAE9661007A85F2 /* EnjoyableApplicationDelegate.h */, + D594BF820FAE9661007A85F2 /* EnjoyableApplicationDelegate.m */, + D594BEF70FAE6FF2007A85F2 /* NJDeviceController.h */, + D594BEF80FAE6FF2007A85F2 /* NJDeviceController.m */, + D5617A340FAEB74000928B3A /* NJMappingsController.h */, + D5617A350FAEB74000928B3A /* NJMappingsController.m */, + D5617FE20FAFD7B000928B3A /* NJOutputController.h */, + D5617FE30FAFD7B000928B3A /* NJOutputController.m */, + D5617FE50FAFDB5800928B3A /* NJKeyInputField.h */, + D5617FE60FAFDB5800928B3A /* NJKeyInputField.m */, + D5617A370FAEBA1800928B3A /* NJMapping.h */, + D5617A380FAEBA1800928B3A /* NJMapping.m */, D594BE840FAE6219007A85F2 /* NJDevice.h */, D594BE850FAE6219007A85F2 /* NJDevice.m */, + EEF86B7316E2241000674B87 /* NJInputPathElement.h */, D594BE880FAE64AD007A85F2 /* NJInput.h */, D594BE890FAE64AD007A85F2 /* NJInput.m */, - D5617D240FAF579300928B3A /* NJInputHat.h */, - D5617D250FAF579300928B3A /* NJInputHat.m */, + D5617D290FAF579A00928B3A /* NJInputAnalog.h */, + D5617D2A0FAF579A00928B3A /* NJInputAnalog.m */, D5617D180FAF568100928B3A /* NJInputButton.h */, D5617D190FAF568100928B3A /* NJInputButton.m */, - D594BEF70FAE6FF2007A85F2 /* NJInputController.h */, - D594BEF80FAE6FF2007A85F2 /* NJInputController.m */, - D594BF810FAE9661007A85F2 /* ApplicationController.h */, - D594BF820FAE9661007A85F2 /* ApplicationController.m */, - D5617A340FAEB74000928B3A /* NJMappingsController.h */, - D5617A350FAEB74000928B3A /* NJMappingsController.m */, - D5617A370FAEBA1800928B3A /* NJMapping.h */, - D5617A380FAEBA1800928B3A /* NJMapping.m */, - D5F8096F0FB093400006A4DE /* NJOutputMapping.h */, - D5F809700FB093400006A4DE /* NJOutputMapping.m */, + D5617D240FAF579300928B3A /* NJInputHat.h */, + D5617D250FAF579300928B3A /* NJInputHat.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 /* NJOutputMouseMove.h */, - 8BD9B54215C230FE00929C5D /* NJOutputMouseMove.m */, + D5F8096F0FB093400006A4DE /* NJOutputMapping.h */, + D5F809700FB093400006A4DE /* NJOutputMapping.m */, 8B7E476A15C314A200C588FA /* NJOutputMouseButton.h */, 8B7E476B15C314A200C588FA /* NJOutputMouseButton.m */, + 8BD9B54115C230FE00929C5D /* NJOutputMouseMove.h */, + 8BD9B54215C230FE00929C5D /* NJOutputMouseMove.m */, 8BEFAD9A15C46BFF00823AEC /* NJOutputMouseScroll.h */, 8BEFAD9B15C46BFF00823AEC /* NJOutputMouseScroll.m */, 8BEFAD9E15C476DC00823AEC /* NJOutputSwitchMouseMode.h */, 8BEFAD9F15C476DC00823AEC /* NJOutputSwitchMouseMode.m */, - EEF86B7316E2241000674B87 /* NJInputPathElement.h */, - EEF86B7416E298CD00674B87 /* NJEvents.h */, ); name = Classes; sourceTree = ""; @@ -181,6 +180,7 @@ isa = PBXGroup; children = ( 080E96DDFE201D6D7F000001 /* Classes */, + EE1D5F8B16E403D600749C36 /* Categories */, 29B97315FDCFA39411CA2CEA /* Other Sources */, 29B97317FDCFA39411CA2CEA /* Resources */, 29B97323FDCFA39411CA2CEA /* Frameworks */, @@ -192,12 +192,9 @@ 29B97315FDCFA39411CA2CEA /* Other Sources */ = { isa = PBXGroup; children = ( - 32CA4F630368D1EE00C91783 /* Enjoyable_Prefix.pch */, 29B97316FDCFA39411CA2CEA /* main.m */, - EE1D7C9416E0ECCF00B000EB /* NSError+Description.h */, - EE1D7C9516E0ECCF00B000EB /* NSError+Description.m */, - EE1D7C9016E01E7000B000EB /* NSView+FirstResponder.h */, - EE1D7C9116E01E7000B000EB /* NSView+FirstResponder.m */, + EEF86B7416E298CD00674B87 /* NJEvents.h */, + 32CA4F630368D1EE00C91783 /* Enjoyable_Prefix.pch */, ); name = "Other Sources"; sourceTree = ""; @@ -223,6 +220,17 @@ name = Frameworks; sourceTree = ""; }; + EE1D5F8B16E403D600749C36 /* Categories */ = { + isa = PBXGroup; + children = ( + EE1D7C9416E0ECCF00B000EB /* NSError+Description.h */, + EE1D7C9516E0ECCF00B000EB /* NSError+Description.m */, + EE1D7C9016E01E7000B000EB /* NSView+FirstResponder.h */, + EE1D7C9116E01E7000B000EB /* NSView+FirstResponder.m */, + ); + name = Categories; + sourceTree = ""; + }; /* End PBXGroup section */ /* Begin PBXNativeTarget section */ @@ -293,8 +301,8 @@ 8D11072D0486CEB800E47090 /* main.m in Sources */, D594BE860FAE6219007A85F2 /* NJDevice.m in Sources */, D594BE8A0FAE64AD007A85F2 /* NJInput.m in Sources */, - D594BEF90FAE6FF2007A85F2 /* NJInputController.m in Sources */, - D594BF830FAE9661007A85F2 /* ApplicationController.m in Sources */, + D594BEF90FAE6FF2007A85F2 /* NJDeviceController.m in Sources */, + D594BF830FAE9661007A85F2 /* EnjoyableApplicationDelegate.m in Sources */, D5617A360FAEB74000928B3A /* NJMappingsController.m in Sources */, D5617A390FAEBA1800928B3A /* NJMapping.m in Sources */, D5617D1A0FAF568100928B3A /* NJInputButton.m in Sources */, diff --git a/EnjoyableApplicationDelegate.h b/EnjoyableApplicationDelegate.h new file mode 100644 index 0000000..6a198e6 --- /dev/null +++ b/EnjoyableApplicationDelegate.h @@ -0,0 +1,28 @@ +// +// EnjoyableApplicationDelegate.h +// Enjoy +// +// Created by Sam McCall on 4/05/09. +// Copyright 2009 University of Otago. All rights reserved. +// + +@class NJDeviceController; +@class NJOutputController; +@class NJMappingsController; + +@interface EnjoyableApplicationDelegate : NSObject { + IBOutlet NSDrawer *drawer; + IBOutlet NSWindow *mainWindow; + IBOutlet NSToolbarItem *activeButton; + IBOutlet NSMenuItem *activeMenuItem; + IBOutlet NSMenu *dockMenuBase; +} + +@property (nonatomic, strong) IBOutlet NJDeviceController *inputController; +@property (nonatomic, strong) IBOutlet NJOutputController *outputController; +@property (nonatomic, strong) IBOutlet NJMappingsController *mappingsController; + +- (IBAction)toggleActivity:(id)sender; +- (void)mappingsChanged; + +@end diff --git a/EnjoyableApplicationDelegate.m b/EnjoyableApplicationDelegate.m new file mode 100644 index 0000000..23324d3 --- /dev/null +++ b/EnjoyableApplicationDelegate.m @@ -0,0 +1,109 @@ +// +// EnjoyableApplicationDelegate.m +// Enjoy +// +// Created by Sam McCall on 4/05/09. +// + +#import "EnjoyableApplicationDelegate.h" + +#import "NJMapping.h" +#import "NJMappingsController.h" +#import "NJDeviceController.h" +#import "NJOutputController.h" +#import "NJEvents.h" + +@implementation EnjoyableApplicationDelegate { + NSInteger mappingsMenuIndex; +} + +- (void)didSwitchApplication:(NSNotification *)notification { + NSRunningApplication *currentApp = notification.userInfo[NSWorkspaceApplicationKey]; + [self.mappingsController activateMappingForProcess:currentApp.localizedName]; +} + +- (void)applicationDidFinishLaunching:(NSNotification *)notification { + [NSNotificationCenter.defaultCenter + addObserver:self + selector:@selector(mappingDidChange:) + name:NJEventMappingChanged + object:nil]; + [NSNotificationCenter.defaultCenter + addObserver:self + selector:@selector(eventTranslationActivated:) + name:NJEventTranslationActivated + object:nil]; + [NSNotificationCenter.defaultCenter + addObserver:self + selector:@selector(eventTranslationDeactivated:) + name:NJEventTranslationDeactivated + object:nil]; + + mappingsMenuIndex = dockMenuBase.numberOfItems; + while (![dockMenuBase itemAtIndex:mappingsMenuIndex - 1].isSeparatorItem) + --mappingsMenuIndex; + + [drawer open]; + self.outputController.enabled = NO; + [self.inputController setup]; + [self.mappingsController load]; +} + +- (void)applicationWillTerminate:(NSNotification *)aNotification { + [NSUserDefaults.standardUserDefaults synchronize]; +} + +- (void)eventTranslationActivated:(NSNotification *)note { + activeButton.image = [NSImage imageNamed:@"NSStopProgressFreestandingTemplate"]; + activeMenuItem.state = [note.object translatingEvents]; + [NSWorkspace.sharedWorkspace.notificationCenter + addObserver:self + selector:@selector(didSwitchApplication:) + name:NSWorkspaceDidActivateApplicationNotification + object:nil]; + NSLog(@"Listening for application changes."); +} + +- (void)eventTranslationDeactivated:(NSNotification *)note { + activeButton.image = [NSImage imageNamed:@"NSGoRightTemplate"]; + activeMenuItem.state = [note.object translatingEvents]; + [NSWorkspace.sharedWorkspace.notificationCenter + removeObserver:self + name:NSWorkspaceDidActivateApplicationNotification + object:nil]; + NSLog(@"Ignoring application changes."); +} + +- (IBAction)toggleActivity:(id)sender { + self.inputController.translatingEvents = !self.inputController.translatingEvents; +} + +- (void)mappingsChanged { + NSInteger removeFrom = mappingsMenuIndex; + while (dockMenuBase.numberOfItems > removeFrom) + [dockMenuBase removeItemAtIndex:dockMenuBase.numberOfItems - 1]; + int added = 0; + for (NJMapping *mapping in self.mappingsController.mappings) { + NSString *keyEquiv = ++added < 10 ? @(added).stringValue : @""; + [dockMenuBase addItemWithTitle:mapping.name + action:@selector(chooseMapping:) + keyEquivalent:keyEquiv]; + + } + [_outputController refreshMappings]; +} + +- (void)mappingDidChange:(NSNotification *)note { + NJMapping *current = note.object; + NSArray *mappings = self.mappingsController.mappings; + for (NSUInteger i = 0; i < mappings.count; ++i) + [dockMenuBase itemAtIndex:i + mappingsMenuIndex].state = mappings[i] == current; +} + +- (void)chooseMapping:(id)sender { + NSInteger idx = [dockMenuBase indexOfItem:sender] - mappingsMenuIndex; + NJMapping *chosen = self.mappingsController.mappings[idx]; + [_mappingsController activateMapping:chosen]; +} + +@end diff --git a/NJDeviceController.h b/NJDeviceController.h new file mode 100644 index 0000000..2769222 --- /dev/null +++ b/NJDeviceController.h @@ -0,0 +1,28 @@ +// +// NJDeviceController.h +// Enjoy +// +// Created by Sam McCall on 4/05/09. +// Copyright 2009 University of Otago. All rights reserved. +// + +@class NJDevice; +@class NJInput; +@class NJMappingsController; +@class NJOutputController; + +@interface NJDeviceController : NSObject { + IBOutlet NSOutlineView *outlineView; + IBOutlet NJOutputController *outputController; + IBOutlet NJMappingsController *mappingsController; +} + +- (void)setup; +- (NJDevice *)findDeviceByRef:(IOHIDDeviceRef)device; + +@property (nonatomic, readonly) NJInput *selectedInput; +@property (nonatomic, assign) NSPoint mouseLoc; +@property (nonatomic, assign) BOOL frontWindowOnly; +@property (nonatomic, assign) BOOL translatingEvents; + +@end diff --git a/NJDeviceController.m b/NJDeviceController.m new file mode 100644 index 0000000..e68cfdb --- /dev/null +++ b/NJDeviceController.m @@ -0,0 +1,235 @@ +// +// NJDeviceController.m +// Enjoy +// +// Created by Sam McCall on 4/05/09. +// + +#import "NJDeviceController.h" + +#import "NJMapping.h" +#import "NJMappingsController.h" +#import "NJDevice.h" +#import "NJInput.h" +#import "NJOutput.h" +#import "NJOutputController.h" +#import "NJEvents.h" + +@implementation NJDeviceController { + IOHIDManagerRef hidManager; + NSTimer *continuousTimer; + NSMutableArray *runningOutputs; + NSMutableArray *_devices; +} + +- (id)init { + if ((self = [super init])) { + _devices = [[NSMutableArray alloc] initWithCapacity:16]; + runningOutputs = [[NSMutableArray alloc] initWithCapacity:32]; + } + return self; +} + +- (void)dealloc { + [continuousTimer invalidate]; + IOHIDManagerClose(hidManager, kIOHIDOptionsTypeNone); + CFRelease(hidManager); +} + +- (void)expandRecursive:(id )pathElement { + if (pathElement) { + [self expandRecursive:pathElement.base]; + [outlineView expandItem:pathElement]; + } +} + +- (void)addRunningOutput:(NJOutput *)output { + if (![runningOutputs containsObject:output]) { + [runningOutputs addObject:output]; + } + if (!continuousTimer) { + continuousTimer = [NSTimer scheduledTimerWithTimeInterval:1.f/60.f + target:self + selector:@selector(updateContinuousInputs:) + userInfo:nil + repeats:YES]; + NSLog(@"Scheduled continuous output timer."); + } +} + +- (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) { + NJOutput *output = mappingsController.currentMapping[subInput]; + output.magnitude = mainInput.magnitude; + output.running = subInput.active; + if (output.running && output.isContinuous) + [self addRunningOutput:output]; + } +} + +- (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]; + [outputController focusKey]; +} + +static void input_callback(void *ctx, IOReturn inResult, void *inSender, IOHIDValueRef value) { + NJDeviceController *controller = (__bridge NJDeviceController *)ctx; + IOHIDDeviceRef device = IOHIDQueueGetDevice(inSender); + + if (controller.translatingEvents) { + [controller runOutputForDevice:device value:value]; + } else if ([NSApplication sharedApplication].mainWindow.isVisible) { + [controller showOutputForDevice:device value:value]; + } +} + +static int findAvailableIndex(NSArray *list, NJDevice *dev) { + for (int index = 1; ; index++) { + BOOL available = YES; + for (NJDevice *used in list) { + if ([used.productName isEqualToString:dev.productName] && used.index == index) { + available = NO; + break; + } + } + if (available) + return index; + } +} + +- (void)addDeviceForDevice:(IOHIDDeviceRef)device { + IOHIDDeviceRegisterInputValueCallback(device, input_callback, (__bridge void*)self); + NJDevice *dev = [[NJDevice alloc] initWithDevice:device]; + dev.index = findAvailableIndex(_devices, dev); + [_devices addObject:dev]; + [outlineView reloadData]; +} + +static void add_callback(void *ctx, IOReturn inResult, void *inSender, IOHIDDeviceRef device) { + NJDeviceController *controller = (__bridge NJDeviceController *)ctx; + [controller addDeviceForDevice:device]; +} + +- (NJDevice *)findDeviceByRef:(IOHIDDeviceRef)device { + for (NJDevice *dev in _devices) + if (dev.device == device) + return dev; + return nil; +} + +static void remove_callback(void *ctx, IOReturn inResult, void *inSender, IOHIDDeviceRef device) { + NJDeviceController *controller = (__bridge NJDeviceController *)ctx; + [controller removeDeviceForDevice:device]; +} + +- (void)removeDeviceForDevice:(IOHIDDeviceRef)device { + NJDevice *match = [self findDeviceByRef:device]; + IOHIDDeviceRegisterInputValueCallback(device, NULL, NULL); + if (match) { + [_devices removeObject:match]; + [outlineView reloadData]; + } + +} + +- (void)updateContinuousInputs:(NSTimer *)timer { + self.mouseLoc = [NSEvent mouseLocation]; + for (NJOutput *output in [runningOutputs copy]) { + if (![output update:self]) { + [runningOutputs removeObject:output]; + } + } + if (!runningOutputs.count) { + [continuousTimer invalidate]; + continuousTimer = nil; + NSLog(@"Unscheduled continuous output timer."); + } +} + +#define NSSTR(e) ((NSString *)CFSTR(e)) + +- (void)setup { + hidManager = IOHIDManagerCreate(kCFAllocatorDefault, kIOHIDOptionsTypeNone); + NSArray *criteria = @[ @{ NSSTR(kIOHIDDeviceUsagePageKey) : @(kHIDPage_GenericDesktop), + NSSTR(kIOHIDDeviceUsageKey) : @(kHIDUsage_GD_Joystick) }, + @{ NSSTR(kIOHIDDeviceUsagePageKey) : @(kHIDPage_GenericDesktop), + NSSTR(kIOHIDDeviceUsageKey) : @(kHIDUsage_GD_GamePad) }, + @{ NSSTR(kIOHIDDeviceUsagePageKey) : @(kHIDPage_GenericDesktop), + NSSTR(kIOHIDDeviceUsageKey) : @(kHIDUsage_GD_MultiAxisController) } + ]; + IOHIDManagerSetDeviceMatchingMultiple(hidManager, (__bridge CFArrayRef)criteria); + + IOHIDManagerScheduleWithRunLoop(hidManager, CFRunLoopGetCurrent(), kCFRunLoopDefaultMode); + IOReturn ret = IOHIDManagerOpen(hidManager, kIOHIDOptionsTypeNone); + if (ret != kIOReturnSuccess) { + [[NSAlert alertWithMessageText:@"Input devices are unavailable" + defaultButton:nil + alternateButton:nil + otherButton:nil + informativeTextWithFormat:@"Error 0x%08x occured trying to access your devices. " + @"Input may not be correctly detected or mapped.", + ret] + beginSheetModalForWindow:outlineView.window + modalDelegate:nil + didEndSelector:nil + contextInfo:nil]; + } + + IOHIDManagerRegisterDeviceMatchingCallback(hidManager, add_callback, (__bridge void *)self); + IOHIDManagerRegisterDeviceRemovalCallback(hidManager, remove_callback, (__bridge void *)self); +} + +- (NJInput *)selectedInput { + id item = [outlineView itemAtRow:outlineView.selectedRow]; + return (!item.children && item.base) ? item : nil; +} + +- (NSInteger)outlineView:(NSOutlineView *)outlineView + numberOfChildrenOfItem:(id )item { + return item ? item.children.count : _devices.count; +} + +- (BOOL)outlineView:(NSOutlineView *)outlineView + isItemExpandable:(id )item { + return item ? [[item children] count] > 0: YES; +} + +- (id)outlineView:(NSOutlineView *)outlineView + child:(NSInteger)index + ofItem:(id )item { + return item ? item.children[index] : _devices[index]; +} + +- (id)outlineView:(NSOutlineView *)outlineView +objectValueForTableColumn:(NSTableColumn *)tableColumn + byItem:(id )item { + return item ? item.name : @"root"; +} + +- (void)outlineViewSelectionDidChange:(NSNotification *)notification { + + [outputController loadCurrent]; +} + +- (void)setTranslatingEvents:(BOOL)translatingEvents { + if (translatingEvents != _translatingEvents) { + _translatingEvents = translatingEvents; + NSString *name = translatingEvents + ? NJEventTranslationActivated + : NJEventTranslationDeactivated; + [NSNotificationCenter.defaultCenter postNotificationName:name + object:self]; + } +} + +@end diff --git a/NJInputController.h b/NJInputController.h deleted file mode 100644 index fdd0532..0000000 --- a/NJInputController.h +++ /dev/null @@ -1,28 +0,0 @@ -// -// NJInputController.h -// Enjoy -// -// Created by Sam McCall on 4/05/09. -// Copyright 2009 University of Otago. All rights reserved. -// - -@class NJDevice; -@class NJInput; -@class NJMappingsController; -@class NJOutputController; - -@interface NJInputController : NSObject { - IBOutlet NSOutlineView *outlineView; - IBOutlet NJOutputController *outputController; - IBOutlet NJMappingsController *mappingsController; -} - -- (void)setup; -- (NJDevice *)findDeviceByRef:(IOHIDDeviceRef)device; - -@property (nonatomic, readonly) NJInput *selectedInput; -@property (nonatomic, assign) NSPoint mouseLoc; -@property (nonatomic, assign) BOOL frontWindowOnly; -@property (nonatomic, assign) BOOL translatingEvents; - -@end diff --git a/NJInputController.m b/NJInputController.m deleted file mode 100644 index 618e99b..0000000 --- a/NJInputController.m +++ /dev/null @@ -1,235 +0,0 @@ -// -// NJInputController.h -// Enjoy -// -// Created by Sam McCall on 4/05/09. -// - -#import "NJInputController.h" - -#import "NJMapping.h" -#import "NJMappingsController.h" -#import "NJDevice.h" -#import "NJInput.h" -#import "NJOutput.h" -#import "NJOutputController.h" -#import "NJEvents.h" - -@implementation NJInputController { - IOHIDManagerRef hidManager; - NSTimer *continuousTimer; - NSMutableArray *runningOutputs; - NSMutableArray *_devices; -} - -- (id)init { - if ((self = [super init])) { - _devices = [[NSMutableArray alloc] initWithCapacity:16]; - runningOutputs = [[NSMutableArray alloc] initWithCapacity:32]; - } - return self; -} - -- (void)dealloc { - [continuousTimer invalidate]; - IOHIDManagerClose(hidManager, kIOHIDOptionsTypeNone); - CFRelease(hidManager); -} - -- (void)expandRecursive:(id )pathElement { - if (pathElement) { - [self expandRecursive:pathElement.base]; - [outlineView expandItem:pathElement]; - } -} - -- (void)addRunningOutput:(NJOutput *)output { - if (![runningOutputs containsObject:output]) { - [runningOutputs addObject:output]; - } - if (!continuousTimer) { - continuousTimer = [NSTimer scheduledTimerWithTimeInterval:1.f/60.f - target:self - selector:@selector(updateContinuousInputs:) - userInfo:nil - repeats:YES]; - NSLog(@"Scheduled continuous output timer."); - } -} - -- (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) { - NJOutput *output = mappingsController.currentMapping[subInput]; - output.magnitude = mainInput.magnitude; - output.running = subInput.active; - if (output.running && output.isContinuous) - [self addRunningOutput:output]; - } -} - -- (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]; - [outputController focusKey]; -} - -static void input_callback(void *ctx, IOReturn inResult, void *inSender, IOHIDValueRef value) { - NJInputController *controller = (__bridge NJInputController *)ctx; - IOHIDDeviceRef device = IOHIDQueueGetDevice(inSender); - - if (controller.translatingEvents) { - [controller runOutputForDevice:device value:value]; - } else if ([NSApplication sharedApplication].mainWindow.isVisible) { - [controller showOutputForDevice:device value:value]; - } -} - -static int findAvailableIndex(NSArray *list, NJDevice *dev) { - for (int index = 1; ; index++) { - BOOL available = YES; - for (NJDevice *used in list) { - if ([used.productName isEqualToString:dev.productName] && used.index == index) { - available = NO; - break; - } - } - if (available) - return index; - } -} - -- (void)addDeviceForDevice:(IOHIDDeviceRef)device { - IOHIDDeviceRegisterInputValueCallback(device, input_callback, (__bridge void*)self); - NJDevice *dev = [[NJDevice alloc] initWithDevice:device]; - 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 addDeviceForDevice:device]; -} - -- (NJDevice *)findDeviceByRef:(IOHIDDeviceRef)device { - for (NJDevice *dev in _devices) - if (dev.device == device) - return dev; - return nil; -} - -static void remove_callback(void *ctx, IOReturn inResult, void *inSender, IOHIDDeviceRef device) { - NJInputController *controller = (__bridge NJInputController *)ctx; - [controller removeDeviceForDevice:device]; -} - -- (void)removeDeviceForDevice:(IOHIDDeviceRef)device { - NJDevice *match = [self findDeviceByRef:device]; - IOHIDDeviceRegisterInputValueCallback(device, NULL, NULL); - if (match) { - [_devices removeObject:match]; - [outlineView reloadData]; - } - -} - -- (void)updateContinuousInputs:(NSTimer *)timer { - self.mouseLoc = [NSEvent mouseLocation]; - for (NJOutput *output in [runningOutputs copy]) { - if (![output update:self]) { - [runningOutputs removeObject:output]; - } - } - if (!runningOutputs.count) { - [continuousTimer invalidate]; - continuousTimer = nil; - NSLog(@"Unscheduled continuous output timer."); - } -} - -#define NSSTR(e) ((NSString *)CFSTR(e)) - -- (void)setup { - hidManager = IOHIDManagerCreate(kCFAllocatorDefault, kIOHIDOptionsTypeNone); - NSArray *criteria = @[ @{ NSSTR(kIOHIDDeviceUsagePageKey) : @(kHIDPage_GenericDesktop), - NSSTR(kIOHIDDeviceUsageKey) : @(kHIDUsage_GD_Joystick) }, - @{ NSSTR(kIOHIDDeviceUsagePageKey) : @(kHIDPage_GenericDesktop), - NSSTR(kIOHIDDeviceUsageKey) : @(kHIDUsage_GD_GamePad) }, - @{ NSSTR(kIOHIDDeviceUsagePageKey) : @(kHIDPage_GenericDesktop), - NSSTR(kIOHIDDeviceUsageKey) : @(kHIDUsage_GD_MultiAxisController) } - ]; - IOHIDManagerSetDeviceMatchingMultiple(hidManager, (__bridge CFArrayRef)criteria); - - IOHIDManagerScheduleWithRunLoop(hidManager, CFRunLoopGetCurrent(), kCFRunLoopDefaultMode); - IOReturn ret = IOHIDManagerOpen(hidManager, kIOHIDOptionsTypeNone); - if (ret != kIOReturnSuccess) { - [[NSAlert alertWithMessageText:@"Input devices are unavailable" - defaultButton:nil - alternateButton:nil - otherButton:nil - informativeTextWithFormat:@"Error 0x%08x occured trying to access your devices. " - @"Input may not be correctly detected or mapped.", - ret] - beginSheetModalForWindow:outlineView.window - modalDelegate:nil - didEndSelector:nil - contextInfo:nil]; - } - - IOHIDManagerRegisterDeviceMatchingCallback(hidManager, add_callback, (__bridge void *)self); - IOHIDManagerRegisterDeviceRemovalCallback(hidManager, remove_callback, (__bridge void *)self); -} - -- (NJInput *)selectedInput { - id item = [outlineView itemAtRow:outlineView.selectedRow]; - return (!item.children && item.base) ? item : nil; -} - -- (NSInteger)outlineView:(NSOutlineView *)outlineView - numberOfChildrenOfItem:(id )item { - return item ? item.children.count : _devices.count; -} - -- (BOOL)outlineView:(NSOutlineView *)outlineView - isItemExpandable:(id )item { - return item ? [[item children] count] > 0: YES; -} - -- (id)outlineView:(NSOutlineView *)outlineView - child:(NSInteger)index - ofItem:(id )item { - return item ? item.children[index] : _devices[index]; -} - -- (id)outlineView:(NSOutlineView *)outlineView -objectValueForTableColumn:(NSTableColumn *)tableColumn - byItem:(id )item { - return item ? item.name : @"root"; -} - -- (void)outlineViewSelectionDidChange:(NSNotification *)notification { - - [outputController loadCurrent]; -} - -- (void)setTranslatingEvents:(BOOL)translatingEvents { - if (translatingEvents != _translatingEvents) { - _translatingEvents = translatingEvents; - NSString *name = translatingEvents - ? NJEventTranslationActivated - : NJEventTranslationDeactivated; - [NSNotificationCenter.defaultCenter postNotificationName:name - object:self]; - } -} - -@end diff --git a/NJMappingsController.m b/NJMappingsController.m index e01cb91..fe96462 100644 --- a/NJMappingsController.m +++ b/NJMappingsController.m @@ -7,7 +7,7 @@ #import "NJMappingsController.h" -#import "ApplicationController.h" +#import "EnjoyableApplicationDelegate.h" #import "NJMapping.h" #import "NJMappingsController.h" #import "NJOutput.h" @@ -62,7 +62,7 @@ - (IBAction)addPressed:(id)sender { NJMapping *newMapping = [[NJMapping alloc] initWithName:@"Untitled"]; [_mappings addObject:newMapping]; - [(ApplicationController *)NSApplication.sharedApplication.delegate mappingsChanged]; + [(EnjoyableApplicationDelegate *)NSApplication.sharedApplication.delegate mappingsChanged]; [tableView reloadData]; [tableView selectRowIndexes:[NSIndexSet indexSetWithIndex:_mappings.count - 1] byExtendingSelection:NO]; [tableView editColumn:0 row:_mappings.count - 1 withEvent:nil select:YES]; @@ -75,7 +75,7 @@ [_mappings removeObjectAtIndex:tableView.selectedRow]; [tableView reloadData]; - [(ApplicationController *)NSApplication.sharedApplication.delegate mappingsChanged]; + [(EnjoyableApplicationDelegate *)NSApplication.sharedApplication.delegate mappingsChanged]; [self activateMapping:_mappings[0]]; [self save]; } @@ -92,7 +92,7 @@ - (void)tableView:(NSTableView *)view setObjectValue:(NSString *)obj forTableColumn:(NSTableColumn *)col row:(NSInteger)index { [(NJMapping *)_mappings[index] setName:obj]; [tableView reloadData]; - [(ApplicationController *)NSApplication.sharedApplication.delegate mappingsChanged]; + [(EnjoyableApplicationDelegate *)NSApplication.sharedApplication.delegate mappingsChanged]; } - (NSInteger)numberOfRowsInTableView:(NSTableView *)tableView { @@ -147,7 +147,7 @@ current = 0; _mappings = newMappings; [tableView reloadData]; - [(ApplicationController *)NSApplication.sharedApplication.delegate mappingsChanged]; + [(EnjoyableApplicationDelegate *)NSApplication.sharedApplication.delegate mappingsChanged]; [self activateMapping:_mappings[current]]; } } @@ -234,7 +234,7 @@ } [self save]; - [(ApplicationController *)NSApplication.sharedApplication.delegate mappingsChanged]; + [(EnjoyableApplicationDelegate *)NSApplication.sharedApplication.delegate mappingsChanged]; [self activateMapping:mapping]; [outputController loadCurrent]; diff --git a/NJOutput.h b/NJOutput.h index 2bfc167..b82c4e7 100644 --- a/NJOutput.h +++ b/NJOutput.h @@ -6,7 +6,7 @@ // Copyright 2009 University of Otago. All rights reserved. // -@class NJInputController; +@class NJDeviceController; @interface NJOutput : NSObject @@ -16,7 +16,7 @@ - (void)trigger; - (void)untrigger; -- (BOOL)update:(NJInputController *)jc; +- (BOOL)update:(NJDeviceController *)jc; - (NSDictionary *)serialize; + (NJOutput *)outputDeserialize:(NSDictionary *)serialization diff --git a/NJOutput.m b/NJOutput.m index dd751e1..ab29ed8 100644 --- a/NJOutput.m +++ b/NJOutput.m @@ -63,7 +63,7 @@ - (void)untrigger { } -- (BOOL)update:(NJInputController *)jc { +- (BOOL)update:(NJDeviceController *)jc { return NO; } diff --git a/NJOutputController.h b/NJOutputController.h index bf590a6..5b9a749 100644 --- a/NJOutputController.h +++ b/NJOutputController.h @@ -9,7 +9,7 @@ #import "NJKeyInputField.h" @class NJMappingsController; -@class NJInputController; +@class NJDeviceController; @class NJOutput; @class NJOutputMouseMove; @@ -22,7 +22,7 @@ IBOutlet NSTextField *title; IBOutlet NSPopUpButton *mappingPopup; IBOutlet NJMappingsController *mappingsController; - IBOutlet NJInputController *inputController; + IBOutlet NJDeviceController *inputController; } @property (assign) BOOL enabled; diff --git a/NJOutputController.m b/NJOutputController.m index f05c615..6725125 100644 --- a/NJOutputController.m +++ b/NJOutputController.m @@ -10,7 +10,7 @@ #import "NJMappingsController.h" #import "NJMapping.h" #import "NJInput.h" -#import "NJInputController.h" +#import "NJDeviceController.h" #import "NJKeyInputField.h" #import "NJOutputMapping.h" #import "NJOutputController.h" diff --git a/NJOutputMapping.m b/NJOutputMapping.m index e411172..5cd5d9f 100644 --- a/NJOutputMapping.m +++ b/NJOutputMapping.m @@ -7,7 +7,7 @@ #import "NJOutputMapping.h" -#import "ApplicationController.h" +#import "EnjoyableApplicationDelegate.h" #import "NJMapping.h" #import "NJMappingsController.h" @@ -37,7 +37,7 @@ } - (void)trigger { - ApplicationController *ctrl = NSApplication.sharedApplication.delegate; + EnjoyableApplicationDelegate *ctrl = NSApplication.sharedApplication.delegate; [ctrl.mappingsController activateMapping:_mapping]; } diff --git a/NJOutputMouseMove.m b/NJOutputMouseMove.m index 5e59d4e..3346fb2 100644 --- a/NJOutputMouseMove.m +++ b/NJOutputMouseMove.m @@ -7,7 +7,7 @@ #import "NJOutputMouseMove.h" -#import "NJInputController.h" +#import "NJDeviceController.h" @implementation NJOutputMouseMove { int sign; @@ -32,7 +32,7 @@ return output; } -- (BOOL)update:(NJInputController *)jc { +- (BOOL)update:(NJDeviceController *)jc { if (fabsf(self.magnitude) < 0.01) { sign = 0; return NO; // dead zone diff --git a/NJOutputMouseScroll.m b/NJOutputMouseScroll.m index 9057125..2f6d2d6 100644 --- a/NJOutputMouseScroll.m +++ b/NJOutputMouseScroll.m @@ -37,7 +37,7 @@ } } -- (BOOL)update:(NJInputController *)jc { +- (BOOL)update:(NJDeviceController *)jc { if (fabsf(self.magnitude) < 0.01f) { sign = 0; return NO; // dead zone diff --git a/NJOutputSwitchMouseMode.m b/NJOutputSwitchMouseMode.m index 3332a91..1750869 100644 --- a/NJOutputSwitchMouseMode.m +++ b/NJOutputSwitchMouseMode.m @@ -7,8 +7,8 @@ #import "NJOutputSwitchMouseMode.h" -#import "ApplicationController.h" -#import "NJInputController.h" +#import "EnjoyableApplicationDelegate.h" +#import "NJDeviceController.h" @implementation NJOutputSwitchMouseMode @@ -27,8 +27,8 @@ - (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; + EnjoyableApplicationDelegate *ac = NSApplication.sharedApplication.delegate; + NJDeviceController *jc = ac.inputController; jc.frontWindowOnly = !jc.frontWindowOnly; }