From bdd3587bb3eadc9ddfe2ae385134de25bc13d770 Mon Sep 17 00:00:00 2001
From: Joe Wreschnig
Date: Wed, 13 Mar 2013 18:32:10 +0100
Subject: [PATCH 01/16] Style issues. Remove dead code.
---
Classes/NJDevice.m | 14 +++++---------
1 file changed, 5 insertions(+), 9 deletions(-)
diff --git a/Classes/NJDevice.m b/Classes/NJDevice.m
index a5efd96..3b0cc6a 100644
--- a/Classes/NJDevice.m
+++ b/Classes/NJDevice.m
@@ -61,16 +61,16 @@ static NSArray *InputsForElement(IOHIDDeviceRef device, id base) {
}
@implementation NJDevice {
- int vendorId;
- int productId;
+ int _vendorId;
+ int _productId;
}
- (id)initWithDevice:(IOHIDDeviceRef)dev {
if ((self = [super initWithName:nil did:nil base:nil])) {
self.device = dev;
self.productName = (__bridge NSString *)IOHIDDeviceGetProperty(dev, CFSTR(kIOHIDProductKey));
- vendorId = [(__bridge NSNumber *)IOHIDDeviceGetProperty(dev, CFSTR(kIOHIDVendorIDKey)) intValue];
- productId = [(__bridge NSNumber *)IOHIDDeviceGetProperty(dev, CFSTR(kIOHIDProductIDKey)) intValue];
+ _vendorId = [(__bridge NSNumber *)IOHIDDeviceGetProperty(dev, CFSTR(kIOHIDVendorIDKey)) intValue];
+ _productId = [(__bridge NSNumber *)IOHIDDeviceGetProperty(dev, CFSTR(kIOHIDProductIDKey)) intValue];
self.children = InputsForElement(dev, self);
}
return self;
@@ -80,12 +80,8 @@ static NSArray *InputsForElement(IOHIDDeviceRef device, id base) {
return [NSString stringWithFormat:@"%@ #%d", _productName, _index];
}
-- (id)base {
- return nil;
-}
-
- (NSString *)uid {
- return [NSString stringWithFormat: @"%d:%d:%d", vendorId, productId, _index];
+ return [NSString stringWithFormat: @"%d:%d:%d", _vendorId, _productId, _index];
}
- (NJInput *)findInputByCookie:(IOHIDElementCookie)cookie {
--
2.20.1
From 9923a1899abb5f85259cc912a43435dd5a3ae6a7 Mon Sep 17 00:00:00 2001
From: Joe Wreschnig
Date: Wed, 13 Mar 2013 18:33:46 +0100
Subject: [PATCH 02/16] Add mapping for 6180 the moon.
---
Website/mappings/6180 the moon.enjoyable | 45 ++++++++++++++++++++++++
1 file changed, 45 insertions(+)
create mode 100644 Website/mappings/6180 the moon.enjoyable
diff --git a/Website/mappings/6180 the moon.enjoyable b/Website/mappings/6180 the moon.enjoyable
new file mode 100644
index 0000000..047f1fa
--- /dev/null
+++ b/Website/mappings/6180 the moon.enjoyable
@@ -0,0 +1,45 @@
+{
+ "name" : "6180 the moon",
+ "entries" : {
+ "1356:616:1~Button 8" : {
+ "type" : "key press",
+ "key" : 123
+ },
+ "1356:616:1~Button 7" : {
+ "type" : "key press",
+ "key" : 125
+ },
+ "1356:616:1~Button 6" : {
+ "type" : "key press",
+ "key" : 124
+ },
+ "1356:616:1~Button 5" : {
+ "type" : "key press",
+ "key" : 126
+ },
+ "1356:616:1~Button 16" : {
+ "type" : "key press",
+ "key" : 49
+ },
+ "1356:616:1~Button 4" : {
+ "type" : "key press",
+ "key" : 53
+ },
+ "1356:616:1~Button 15" : {
+ "type" : "key press",
+ "key" : 126
+ },
+ "1356:616:1~Button 1" : {
+ "type" : "key press",
+ "key" : 15
+ },
+ "1356:616:1~Button 12" : {
+ "type" : "key press",
+ "key" : 49
+ },
+ "1356:616:1~Button 14" : {
+ "type" : "key press",
+ "key" : 49
+ }
+ }
+}
\ No newline at end of file
--
2.20.1
From f8ae7787fe3fe272eaf04586e3007339c907fb33 Mon Sep 17 00:00:00 2001
From: Joe Wreschnig
Date: Wed, 13 Mar 2013 18:34:41 +0100
Subject: [PATCH 03/16] Support relaunching in the background as part of
resume/launch items.
---
Categories/NSRunningApplication+LoginItem.h | 19 +++++
Categories/NSRunningApplication+LoginItem.m | 89 +++++++++++++++++++++
Classes/EnjoyableApplicationDelegate.m | 14 +++-
Enjoyable.xcodeproj/project.pbxproj | 6 ++
Info.plist | 2 +-
Other Sources/Enjoyable_Prefix.pch | 1 +
Resources/English.lproj/MainMenu.xib | 6 +-
Website/index.html | 1 +
8 files changed, 132 insertions(+), 6 deletions(-)
create mode 100644 Categories/NSRunningApplication+LoginItem.h
create mode 100644 Categories/NSRunningApplication+LoginItem.m
diff --git a/Categories/NSRunningApplication+LoginItem.h b/Categories/NSRunningApplication+LoginItem.h
new file mode 100644
index 0000000..da5dd19
--- /dev/null
+++ b/Categories/NSRunningApplication+LoginItem.h
@@ -0,0 +1,19 @@
+//
+// NSRunningApplication+LoginItem.h
+// Enjoyable
+//
+// Created by Joe Wreschnig on 3/13/13.
+//
+//
+
+#import
+
+@interface NSRunningApplication (LoginItem)
+ // Don't be a jerk. Ask the user before doing this.
+
+- (BOOL)isLoginItem;
+- (void)addToLoginItems;
+- (void)removeFromLoginItems;
+- (BOOL)wasLaunchedAsLoginItemOrResume;
+
+@end
diff --git a/Categories/NSRunningApplication+LoginItem.m b/Categories/NSRunningApplication+LoginItem.m
new file mode 100644
index 0000000..53a9521
--- /dev/null
+++ b/Categories/NSRunningApplication+LoginItem.m
@@ -0,0 +1,89 @@
+//
+// NSApplication+LoginItem.m
+// Enjoyable
+//
+// Created by Joe Wreschnig on 3/13/13.
+//
+//
+
+#import "NSRunningApplication+LoginItem.h"
+
+#import
+
+static const UInt32 RESOLVE_FLAGS = kLSSharedFileListNoUserInteraction
+ | kLSSharedFileListDoNotMountVolumes;
+
+@implementation NSRunningApplication (LoginItem)
+
+- (BOOL)isLoginItem {
+ LSSharedFileListRef loginItems = LSSharedFileListCreate(
+ NULL, kLSSharedFileListSessionLoginItems, NULL);
+ NSURL *myURL = self.bundleURL;
+ BOOL found = NO;
+ UInt32 seed = 0;
+ NSArray *currentLoginItems = CFBridgingRelease(
+ LSSharedFileListCopySnapshot(loginItems, &seed));
+ for (id obj in currentLoginItems) {
+ LSSharedFileListItemRef item = (__bridge LSSharedFileListItemRef)obj;
+ CFURLRef itemURL = NULL;
+ if (!LSSharedFileListItemResolve(item, RESOLVE_FLAGS, &itemURL, NULL)) {
+ found = CFEqual(itemURL, (__bridge CFURLRef)myURL);
+ CFRelease(itemURL);
+ }
+ if (found)
+ break;
+ }
+ CFRelease(loginItems);
+ return found;
+}
+
+- (void)addToLoginItems {
+ if (!self.isLoginItem) {
+ NSURL *myURL = self.bundleURL;
+ LSSharedFileListRef loginItems = LSSharedFileListCreate(
+ NULL, kLSSharedFileListSessionLoginItems, NULL);
+ LSSharedFileListInsertItemURL(
+ loginItems, kLSSharedFileListItemBeforeFirst,
+ NULL, NULL, (__bridge CFURLRef)myURL, NULL, NULL);
+ CFRelease(loginItems);
+ }
+}
+
+- (void)removeFromLoginItems {
+ LSSharedFileListRef loginItems = LSSharedFileListCreate(
+ NULL, kLSSharedFileListSessionLoginItems, NULL);
+ NSURL *myURL = self.bundleURL;
+ UInt32 seed = 0;
+ NSArray *currentLoginItems = CFBridgingRelease(
+ LSSharedFileListCopySnapshot(loginItems, &seed));
+ for (id obj in currentLoginItems) {
+ LSSharedFileListItemRef item = (__bridge LSSharedFileListItemRef)obj;
+ CFURLRef itemURL = NULL;
+ if (!LSSharedFileListItemResolve(item, RESOLVE_FLAGS, &itemURL, NULL)) {
+ if (CFEqual(itemURL, (__bridge CFURLRef)myURL))
+ LSSharedFileListItemRemove(loginItems, item);
+ CFRelease(itemURL);
+ }
+ }
+ CFRelease(loginItems);
+}
+
+- (BOOL)wasLaunchedAsLoginItemOrResume {
+ ProcessSerialNumber psn = { 0, kCurrentProcess };
+ NSDictionary *processInfo = CFBridgingRelease(
+ ProcessInformationCopyDictionary(
+ &psn, kProcessDictionaryIncludeAllInformationMask));
+ long long parent = [processInfo[@"ParentPSN"] longLongValue];
+ ProcessSerialNumber parentPsn = {
+ (parent >> 32) & 0x00000000FFFFFFFFLL,
+ parent & 0x00000000FFFFFFFFLL
+ };
+
+ NSDictionary *parentInfo = CFBridgingRelease(
+ ProcessInformationCopyDictionary(
+ &parentPsn, kProcessDictionaryIncludeAllInformationMask));
+ return [parentInfo[@"FileCreator"] isEqualToString:@"lgnw"];
+}
+
+
+@end
diff --git a/Classes/EnjoyableApplicationDelegate.m b/Classes/EnjoyableApplicationDelegate.m
index f151399..f02ec90 100644
--- a/Classes/EnjoyableApplicationDelegate.m
+++ b/Classes/EnjoyableApplicationDelegate.m
@@ -48,7 +48,14 @@
}
- (void)applicationDidFinishLaunching:(NSNotification *)notification {
- [window makeKeyAndOrderFront:nil];
+ if (NSRunningApplication.currentApplication.wasLaunchedAsLoginItemOrResume
+ && [NSUserDefaults.standardUserDefaults boolForKey:@"hidden in status item"]) {
+ [self transformIntoElement:self];
+ NSApplication *app = notification.object;
+ [app deactivate];
+ } else {
+ [window makeKeyAndOrderFront:nil];
+ }
}
- (BOOL)applicationShouldHandleReopen:(NSApplication *)theApplication
@@ -65,15 +72,18 @@
[NSObject cancelPreviousPerformRequestsWithTarget:self
selector:@selector(transformIntoElement:)
object:self];
+ [NSUserDefaults.standardUserDefaults setBool:NO forKey:@"hidden in status item"];
}
- (void)applicationWillBecomeActive:(NSNotification *)notification {
- [self restoreToForeground:notification];
+ if (window.isVisible)
+ [self restoreToForeground:notification];
}
- (void)transformIntoElement:(id)sender {
ProcessSerialNumber psn = { 0, kCurrentProcess };
TransformProcessType(&psn, kProcessTransformToUIElementApplication);
+ [NSUserDefaults.standardUserDefaults setBool:YES forKey:@"hidden in status item"];
}
- (void)flashStatusItem {
diff --git a/Enjoyable.xcodeproj/project.pbxproj b/Enjoyable.xcodeproj/project.pbxproj
index eee41a1..d428220 100644
--- a/Enjoyable.xcodeproj/project.pbxproj
+++ b/Enjoyable.xcodeproj/project.pbxproj
@@ -15,6 +15,7 @@
EE3D897F16EA817E00596D1F /* Status Menu Icon Disabled.png in Resources */ = {isa = PBXBuildFile; fileRef = EE3D897D16EA817E00596D1F /* Status Menu Icon Disabled.png */; };
EE3D898016EA817E00596D1F /* Status Menu Icon.png in Resources */ = {isa = PBXBuildFile; fileRef = EE3D897E16EA817E00596D1F /* Status Menu Icon.png */; };
EE6A122E16E8F46300EDBD32 /* Icon.icns in Resources */ = {isa = PBXBuildFile; fileRef = EE6A122D16E8F46300EDBD32 /* Icon.icns */; };
+ EE8455DD16F0E46B00F32A01 /* NSRunningApplication+LoginItem.m in Sources */ = {isa = PBXBuildFile; fileRef = EE8455DC16F0E46B00F32A01 /* NSRunningApplication+LoginItem.m */; };
EED4CE6E16ED692400C65AA8 /* NJMappingMenuController.m in Sources */ = {isa = PBXBuildFile; fileRef = EED4CE6D16ED692400C65AA8 /* NJMappingMenuController.m */; };
EED4CE7716EE195100C65AA8 /* Sparkle.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = EED4CE7616EE195100C65AA8 /* Sparkle.framework */; };
EED4CE7816EE195B00C65AA8 /* Sparkle.framework in Copy Sparkle Framework */ = {isa = PBXBuildFile; fileRef = EED4CE7616EE195100C65AA8 /* Sparkle.framework */; };
@@ -78,6 +79,8 @@
EE3D897D16EA817E00596D1F /* Status Menu Icon Disabled.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = "Status Menu Icon Disabled.png"; path = "Resources/Status Menu Icon Disabled.png"; sourceTree = ""; };
EE3D897E16EA817E00596D1F /* Status Menu Icon.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = "Status Menu Icon.png"; path = "Resources/Status Menu Icon.png"; sourceTree = ""; };
EE6A122D16E8F46300EDBD32 /* Icon.icns */ = {isa = PBXFileReference; lastKnownFileType = image.icns; path = Icon.icns; sourceTree = ""; };
+ EE8455DB16F0E46B00F32A01 /* NSRunningApplication+LoginItem.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = "NSRunningApplication+LoginItem.h"; path = "Categories/NSRunningApplication+LoginItem.h"; sourceTree = ""; };
+ EE8455DC16F0E46B00F32A01 /* NSRunningApplication+LoginItem.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = "NSRunningApplication+LoginItem.m"; path = "Categories/NSRunningApplication+LoginItem.m"; sourceTree = ""; };
EED4CE6C16ED692400C65AA8 /* NJMappingMenuController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = NJMappingMenuController.h; path = Classes/NJMappingMenuController.h; sourceTree = ""; };
EED4CE6D16ED692400C65AA8 /* NJMappingMenuController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = NJMappingMenuController.m; path = Classes/NJMappingMenuController.m; sourceTree = ""; };
EED4CE7616EE195100C65AA8 /* Sparkle.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; path = Sparkle.framework; sourceTree = ""; };
@@ -283,6 +286,8 @@
EE1D5F8B16E403D600749C36 /* Categories */ = {
isa = PBXGroup;
children = (
+ EE8455DB16F0E46B00F32A01 /* NSRunningApplication+LoginItem.h */,
+ EE8455DC16F0E46B00F32A01 /* NSRunningApplication+LoginItem.m */,
EEF17D2716E8E2E100D7DC4D /* NSError+Description.h */,
EEF17D2816E8E2E100D7DC4D /* NSError+Description.m */,
EEF17D2916E8E2E100D7DC4D /* NSFileManager+UniqueNames.h */,
@@ -436,6 +441,7 @@
EED4CE6E16ED692400C65AA8 /* NJMappingMenuController.m in Sources */,
EEE703DC16F089FE002FDD69 /* NJHIDManager.m in Sources */,
EEE703DE16F0B3F6002FDD69 /* NJInputPathElement.m in Sources */,
+ EE8455DD16F0E46B00F32A01 /* NSRunningApplication+LoginItem.m in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
diff --git a/Info.plist b/Info.plist
index f3cc683..6191eaa 100644
--- a/Info.plist
+++ b/Info.plist
@@ -46,7 +46,7 @@
CFBundleSignature
????
CFBundleVersion
- 248
+ 258
LSApplicationCategoryType
public.app-category.utilities
NSHumanReadableCopyright
diff --git a/Other Sources/Enjoyable_Prefix.pch b/Other Sources/Enjoyable_Prefix.pch
index 61d6aee..b0d1f40 100644
--- a/Other Sources/Enjoyable_Prefix.pch
+++ b/Other Sources/Enjoyable_Prefix.pch
@@ -15,3 +15,4 @@
#import "NSFileManager+UniqueNames.h"
#import "NSString+FixFilename.h"
#import "NSRunningApplication+NJPossibleNames.h"
+#import "NSRunningApplication+LoginItem.h"
diff --git a/Resources/English.lproj/MainMenu.xib b/Resources/English.lproj/MainMenu.xib
index c63659b..98b5cef 100644
--- a/Resources/English.lproj/MainMenu.xib
+++ b/Resources/English.lproj/MainMenu.xib
@@ -567,7 +567,7 @@ aW5nLg
{232, 321}
-
+
YES
NO
YES
@@ -697,7 +697,7 @@ aW5nLg
{234, 323}
-
+
150034
@@ -3026,7 +3026,7 @@ aW5nLg
com.apple.InterfaceBuilder.CocoaPlugin
{{114, 276}, {770, 487}}
-
+
com.apple.InterfaceBuilder.CocoaPlugin
com.apple.InterfaceBuilder.CocoaPlugin
com.apple.InterfaceBuilder.CocoaPlugin
diff --git a/Website/index.html b/Website/index.html
index 6525b71..03d3468 100644
--- a/Website/index.html
+++ b/Website/index.html
@@ -51,6 +51,7 @@
them.
+ 6180 the moon
Anodyne
BasketBelle
Canabalt
--
2.20.1
From 466bd075d9b9da440240a02ef82ce39253fb4220 Mon Sep 17 00:00:00 2001
From: Joe Wreschnig
Date: Wed, 13 Mar 2013 19:06:45 +0100
Subject: [PATCH 04/16] UI element applications don't restore correctly, this
needs more work/testing.
---
Classes/EnjoyableApplicationDelegate.m | 9 +--------
Info.plist | 2 +-
2 files changed, 2 insertions(+), 9 deletions(-)
diff --git a/Classes/EnjoyableApplicationDelegate.m b/Classes/EnjoyableApplicationDelegate.m
index f02ec90..411067e 100644
--- a/Classes/EnjoyableApplicationDelegate.m
+++ b/Classes/EnjoyableApplicationDelegate.m
@@ -48,14 +48,7 @@
}
- (void)applicationDidFinishLaunching:(NSNotification *)notification {
- if (NSRunningApplication.currentApplication.wasLaunchedAsLoginItemOrResume
- && [NSUserDefaults.standardUserDefaults boolForKey:@"hidden in status item"]) {
- [self transformIntoElement:self];
- NSApplication *app = notification.object;
- [app deactivate];
- } else {
- [window makeKeyAndOrderFront:nil];
- }
+ [window makeKeyAndOrderFront:nil];
}
- (BOOL)applicationShouldHandleReopen:(NSApplication *)theApplication
diff --git a/Info.plist b/Info.plist
index 6191eaa..2b34274 100644
--- a/Info.plist
+++ b/Info.plist
@@ -46,7 +46,7 @@
CFBundleSignature
????
CFBundleVersion
- 258
+ 259
LSApplicationCategoryType
public.app-category.utilities
NSHumanReadableCopyright
--
2.20.1
From b417eb4ae97804070277eb19cc596bdb6bb9d281 Mon Sep 17 00:00:00 2001
From: Joe Wreschnig
Date: Wed, 13 Mar 2013 21:10:54 +0100
Subject: [PATCH 05/16] Second try at login items. If the user hides Enjoyable
in the status bar, explain and ask what to do. Try to have least-annoying
interactions with Sparkle updater's additional prompt.
---
Classes/EnjoyableApplicationDelegate.h | 3 +-
Classes/EnjoyableApplicationDelegate.m | 49 +++++++++++++++++++-
Info.plist | 4 +-
Resources/English.lproj/Localizable.strings | Bin 6424 -> 7520 bytes
Resources/English.lproj/MainMenu.xib | 10 +++-
5 files changed, 61 insertions(+), 5 deletions(-)
diff --git a/Classes/EnjoyableApplicationDelegate.h b/Classes/EnjoyableApplicationDelegate.h
index f61578b..acea8a9 100644
--- a/Classes/EnjoyableApplicationDelegate.h
+++ b/Classes/EnjoyableApplicationDelegate.h
@@ -11,7 +11,8 @@
#import "NJMappingMenuController.h"
@interface EnjoyableApplicationDelegate : NSObject {
+ NJMappingMenuDelegate,
+ NSWindowDelegate> {
IBOutlet NSMenu *dockMenu;
IBOutlet NSMenu *statusItemMenu;
IBOutlet NSWindow *window;
diff --git a/Classes/EnjoyableApplicationDelegate.m b/Classes/EnjoyableApplicationDelegate.m
index 411067e..b1d9907 100644
--- a/Classes/EnjoyableApplicationDelegate.m
+++ b/Classes/EnjoyableApplicationDelegate.m
@@ -5,6 +5,8 @@
// Created by Sam McCall on 4/05/09.
//
+#import
+
#import "EnjoyableApplicationDelegate.h"
#import "NJMapping.h"
@@ -48,7 +50,11 @@
}
- (void)applicationDidFinishLaunching:(NSNotification *)notification {
- [window makeKeyAndOrderFront:nil];
+ if ([NSUserDefaults.standardUserDefaults boolForKey:@"hidden in status item"]
+ && NSRunningApplication.currentApplication.wasLaunchedAsLoginItemOrResume)
+ [self transformIntoElement:nil];
+ else
+ [window makeKeyAndOrderFront:nil];
}
- (BOOL)applicationShouldHandleReopen:(NSApplication *)theApplication
@@ -143,5 +149,46 @@
[self.mappingsController mappingPressed:self];
}
+- (void)loginItemPromptDidEnd:(NSWindow *)sheet
+ returnCode:(int)returnCode
+ contextInfo:(void *)contextInfo {
+ if (returnCode == NSAlertDefaultReturn) {
+ [NSRunningApplication.currentApplication addToLoginItems];
+ // If we're going to automatically start, don't bug the user
+ // about automatic updates next boot - they probably want it,
+ // and if they don't they probably want a prompt for it less.
+ SUUpdater.sharedUpdater.automaticallyChecksForUpdates = YES;
+ }
+}
+
+- (void)loginItemPromptDidDismiss:(NSWindow *)sheet
+ returnCode:(int)returnCode
+ contextInfo:(void *)contextInfo {
+ [NSUserDefaults.standardUserDefaults setBool:YES forKey:@"explained login items"];
+ [window performClose:sheet];
+}
+
+- (BOOL)windowShouldClose:(NSWindow *)sender {
+ if (sender != window
+ || NSRunningApplication.currentApplication.isLoginItem
+ || [NSUserDefaults.standardUserDefaults boolForKey:@"explained login items"])
+ return YES;
+ NSBeginAlertSheet(
+ NSLocalizedString(@"login items prompt", @"alert prompt for adding to login items"),
+ NSLocalizedString(@"login items add button", @"button to add to login items"),
+ NSLocalizedString(@"login items don't add button", @"button to not add to login items"),
+ nil, window, self,
+ @selector(loginItemPromptDidEnd:returnCode:contextInfo:),
+ @selector(loginItemPromptDidDismiss:returnCode:contextInfo:),
+ NULL,
+ NSLocalizedString(@"login items explanation", @"a brief explanation of login items")
+ );
+ for (int i = 0; i < 10; ++i)
+ [self performSelector:@selector(flashStatusItem)
+ withObject:self
+ afterDelay:0.5 * i];
+ return NO;
+}
+
@end
diff --git a/Info.plist b/Info.plist
index 2b34274..285b858 100644
--- a/Info.plist
+++ b/Info.plist
@@ -42,11 +42,11 @@
CFBundlePackageType
APPL
CFBundleShortVersionString
- 1.0
+ 1.1
CFBundleSignature
????
CFBundleVersion
- 259
+ 294
LSApplicationCategoryType
public.app-category.utilities
NSHumanReadableCopyright
diff --git a/Resources/English.lproj/Localizable.strings b/Resources/English.lproj/Localizable.strings
index 564ef88d1ae705702f756a03d3bddd1b4785727c..8b9a71782f2bf1dcc87e4fa301c7df7b43d4a61f 100644
GIT binary patch
delta 953
zcmbu8ze)o^5XJ|q7(0uAg}B5*2ok|kku+LqAy|kY!sYIw(PR_uE@-MegIuAnU?=zn
zR(8IEkK%9kviXAnK{@tzcXsESZ)U!I-u>Epy{g;=(vesa$;3#XxhGv_-L+UJ%z;FF
zZLxCAF2ic@>9JFr;h%xfm6UZ&cBCxT#pn5Fd988A?O+`52>)A(-lXp
zBC3$kQB$Hy&?70`h*Q;Wiv8Fh%y9Z~IYodf=#ZQYq7KNsk443w67-T4BY#@nczj>A
h`g%Gj)pIP~(V_swTgjZd{q6aTe$~FbomM`Uz5z(5uK54}
delta 16
YcmaE0HN$8_oY>@DEFznCNiAan06ho>od5s;
diff --git a/Resources/English.lproj/MainMenu.xib b/Resources/English.lproj/MainMenu.xib
index 98b5cef..2a95667 100644
--- a/Resources/English.lproj/MainMenu.xib
+++ b/Resources/English.lproj/MainMenu.xib
@@ -1629,6 +1629,14 @@ aW5nLg
941
+
+
+ delegate
+
+
+
+ 977
+
delegate
@@ -3259,7 +3267,7 @@ aW5nLg
- 976
+ 977
--
2.20.1
From 561fa1774ce33b5a4a8112ba5802cc33a2ca819d Mon Sep 17 00:00:00 2001
From: Joe Wreschnig
Date: Thu, 14 Mar 2013 14:02:06 +0100
Subject: [PATCH 06/16] Write proper constructors for NJInput and subclasses.
Rename base to parent to match children, d(evice internal)id to e(lement)id
to avoid confusion with actual device IDs/UID.
---
Classes/NJDevice.m | 40 ++++++++++++++++++------------------
Classes/NJDeviceController.m | 4 ++--
Classes/NJInput.h | 9 +++++---
Classes/NJInput.m | 14 ++++++++-----
Classes/NJInputAnalog.h | 4 +++-
Classes/NJInputAnalog.m | 34 ++++++++++++++++--------------
Classes/NJInputButton.h | 4 +++-
Classes/NJInputButton.m | 18 ++++++++--------
Classes/NJInputHat.h | 4 +++-
Classes/NJInputHat.m | 37 +++++++++++++++++++--------------
Classes/NJInputPathElement.h | 6 +++---
Classes/NJInputPathElement.m | 12 +++++------
Classes/NJOutputController.m | 2 +-
Info.plist | 2 +-
14 files changed, 108 insertions(+), 82 deletions(-)
diff --git a/Classes/NJDevice.m b/Classes/NJDevice.m
index 3b0cc6a..e4c6b3d 100644
--- a/Classes/NJDevice.m
+++ b/Classes/NJDevice.m
@@ -12,7 +12,7 @@
#import "NJInputHat.h"
#import "NJInputButton.h"
-static NSArray *InputsForElement(IOHIDDeviceRef device, id base) {
+static NSArray *InputsForElement(IOHIDDeviceRef device, id parent) {
CFArrayRef elements = IOHIDDeviceCopyMatchingElements(device, NULL, kIOHIDOptionsTypeNone);
NSMutableArray *children = [NSMutableArray arrayWithCapacity:CFArrayGetCount(elements)];
@@ -20,14 +20,13 @@ static NSArray *InputsForElement(IOHIDDeviceRef device, id base) {
int axes = 0;
int hats = 0;
- for (int i = 0; i < CFArrayGetCount(elements); i++) {
+ for (CFIndex i = 0; i < CFArrayGetCount(elements); i++) {
IOHIDElementRef element = (IOHIDElementRef)CFArrayGetValueAtIndex(elements, i);
- int type = IOHIDElementGetType(element);
- unsigned usage = IOHIDElementGetUsage(element);
- unsigned usagePage = IOHIDElementGetUsagePage(element);
- long max = IOHIDElementGetPhysicalMax(element);
- long min = IOHIDElementGetPhysicalMin(element);
- CFStringRef elName = IOHIDElementGetName(element);
+ IOHIDElementType type = IOHIDElementGetType(element);
+ uint32_t usage = IOHIDElementGetUsage(element);
+ uint32_t usagePage = IOHIDElementGetUsagePage(element);
+ CFIndex max = IOHIDElementGetPhysicalMax(element);
+ CFIndex min = IOHIDElementGetPhysicalMin(element);
NJInput *input = nil;
@@ -36,23 +35,24 @@ static NSArray *InputsForElement(IOHIDDeviceRef device, id base) {
|| type == kIOHIDElementTypeInput_Button))
continue;
- if (max - min == 1 || usagePage == kHIDPage_Button || type == kIOHIDElementTypeInput_Button) {
- input = [[NJInputButton alloc] initWithName:(__bridge NSString *)elName
- idx:++buttons
- max:max];
+ if (max - min == 1
+ || usagePage == kHIDPage_Button
+ || type == kIOHIDElementTypeInput_Button) {
+ input = [[NJInputButton alloc] initWithElement:element
+ index:++buttons
+ parent:parent];
} else if (usage == kHIDUsage_GD_Hatswitch) {
- input = [[NJInputHat alloc] initWithIndex:++hats];
+ input = [[NJInputHat alloc] initWithElement:element
+ index:++hats
+ parent:parent];
} else if (usage >= kHIDUsage_GD_X && usage <= kHIDUsage_GD_Rz) {
- input = [[NJInputAnalog alloc] initWithIndex:++axes
- rawMin:min
- rawMax:max];
+ input = [[NJInputAnalog alloc] initWithElement:element
+ index:++axes
+ parent:parent];
} else {
continue;
}
- // TODO(jfw): Should be moved into better constructors.
- input.base = base;
- input.cookie = IOHIDElementGetCookie(element);
[children addObject:input];
}
@@ -66,7 +66,7 @@ static NSArray *InputsForElement(IOHIDDeviceRef device, id base) {
}
- (id)initWithDevice:(IOHIDDeviceRef)dev {
- if ((self = [super initWithName:nil did:nil base:nil])) {
+ if ((self = [super initWithName:nil eid:nil parent:nil])) {
self.device = dev;
self.productName = (__bridge NSString *)IOHIDDeviceGetProperty(dev, CFSTR(kIOHIDProductKey));
_vendorId = [(__bridge NSNumber *)IOHIDDeviceGetProperty(dev, CFSTR(kIOHIDVendorIDKey)) intValue];
diff --git a/Classes/NJDeviceController.m b/Classes/NJDeviceController.m
index 6fc4d13..8cc5f2a 100644
--- a/Classes/NJDeviceController.m
+++ b/Classes/NJDeviceController.m
@@ -83,7 +83,7 @@
- (void)expandRecursive:(NJInputPathElement *)pathElement {
if (pathElement) {
- [self expandRecursive:pathElement.base];
+ [self expandRecursive:pathElement.parent];
[outlineView expandItem:pathElement];
}
}
@@ -251,7 +251,7 @@ static int findAvailableIndex(NSArray *list, NJDevice *dev) {
- (NJInput *)selectedInput {
NJInputPathElement *item = [outlineView itemAtRow:outlineView.selectedRow];
- return (NJInput *)((!item.children && item.base) ? item : nil);
+ return (NJInput *)((!item.children && item.parent) ? item : nil);
}
- (NSInteger)outlineView:(NSOutlineView *)outlineView
diff --git a/Classes/NJInput.h b/Classes/NJInput.h
index b9d2dca..db47121 100644
--- a/Classes/NJInput.h
+++ b/Classes/NJInput.h
@@ -10,10 +10,13 @@
@interface NJInput : NJInputPathElement
+#define NJINPUT_DID(name, index) [[NSString alloc] initWithFormat:@"%s %d", name, index]
+#define NJINPUT_NAME(name, index) [[NSString alloc] initWithFormat:name, index]
+
- (id)initWithName:(NSString *)name
- did:(NSString *)did
- cookie:(IOHIDElementCookie)cookie
- base:(NJInputPathElement *)base;
+ eid:(NSString *)eid
+ element:(IOHIDElementRef)element
+ parent:(NJInputPathElement *)parent;
@property (nonatomic, assign) IOHIDElementCookie cookie;
@property (nonatomic, assign) BOOL active;
diff --git a/Classes/NJInput.m b/Classes/NJInput.m
index 78376e6..82d5993 100644
--- a/Classes/NJInput.m
+++ b/Classes/NJInput.m
@@ -10,11 +10,15 @@
@implementation NJInput
- (id)initWithName:(NSString *)name
- did:(NSString *)did
- cookie:(IOHIDElementCookie)cookie
- base:(NJInputPathElement *)base {
- if ((self = [super initWithName:name did:did base:base])) {
- self.cookie = cookie;
+ eid:(NSString *)eid
+ element:(IOHIDElementRef)element
+ parent:(NJInputPathElement *)parent
+{
+ NSString *elementName = (__bridge NSString *)(IOHIDElementGetName(element));
+ if (elementName.length)
+ name = [name stringByAppendingFormat:@"- %@", elementName];
+ if ((self = [super initWithName:name eid:eid parent:parent])) {
+ self.cookie = IOHIDElementGetCookie(element);
}
return self;
}
diff --git a/Classes/NJInputAnalog.h b/Classes/NJInputAnalog.h
index e79ed89..de35e3d 100644
--- a/Classes/NJInputAnalog.h
+++ b/Classes/NJInputAnalog.h
@@ -12,6 +12,8 @@
@interface NJInputAnalog : NJInput
-- (id)initWithIndex:(int)index rawMin:(long)rawMin rawMax:(long)rawMax;
+- (id)initWithElement:(IOHIDElementRef)element
+ index:(int)index
+ parent:(NJInputPathElement *)parent;
@end
diff --git a/Classes/NJInputAnalog.m b/Classes/NJInputAnalog.m
index af64954..3746c11 100644
--- a/Classes/NJInputAnalog.m
+++ b/Classes/NJInputAnalog.m
@@ -9,33 +9,37 @@
#import "NJInputAnalog.h"
-static float normalize(long p, long min, long max) {
+static float normalize(CFIndex p, CFIndex min, CFIndex max) {
return 2 * (p - min) / (float)(max - min) - 1;
}
@implementation NJInputAnalog {
- long rawMin;
- long rawMax;
+ CFIndex _rawMin;
+ CFIndex _rawMax;
}
-- (id)initWithIndex:(int)index rawMin:(long)rawMin_ rawMax:(long)rawMax_ {
- NSString *name = [[NSString alloc] initWithFormat:NSLocalizedString(@"axis %d", @"axis name"), index];
- NSString *did = [[NSString alloc] initWithFormat:@"Axis %d", index];
- if ((self = [super initWithName:name did:did base:nil])) {
+- (id)initWithElement:(IOHIDElementRef)element
+ index:(int)index
+ parent:(NJInputPathElement *)parent
+{
+ if ((self = [super initWithName:NJINPUT_NAME(NSLocalizedString(@"axis %d", @"axis name"), index)
+ eid:NJINPUT_DID("Axis", index)
+ element:element
+ parent:nil])) {
self.children = @[[[NJInput alloc] initWithName:NSLocalizedString(@"axis low", @"axis low trigger")
- did:@"Low"
- base:self],
+ eid:@"Low"
+ parent:self],
[[NJInput alloc] initWithName:NSLocalizedString(@"axis high", @"axis high trigger")
- did:@"High"
- base:self]];
- rawMax = rawMax_;
- rawMin = rawMin_;
+ eid:@"High"
+ parent:self]];
+ _rawMax = IOHIDElementGetPhysicalMax(element);
+ _rawMin = IOHIDElementGetPhysicalMin(element);
}
return self;
}
- (id)findSubInputForValue:(IOHIDValueRef)value {
- float mag = normalize(IOHIDValueGetIntegerValue(value), rawMin, rawMax);
+ float mag = normalize(IOHIDValueGetIntegerValue(value), _rawMin, _rawMax);
if (mag < -DEAD_ZONE)
return self.children[0];
else if (mag > DEAD_ZONE)
@@ -45,7 +49,7 @@ static float normalize(long p, long min, long max) {
}
- (void)notifyEvent:(IOHIDValueRef)value {
- float magnitude = self.magnitude = normalize(IOHIDValueGetIntegerValue(value), rawMin, rawMax);
+ float magnitude = self.magnitude = normalize(IOHIDValueGetIntegerValue(value), _rawMin, _rawMax);
[self.children[0] setMagnitude:fabsf(MIN(magnitude, 0))];
[self.children[1] setMagnitude:fabsf(MAX(magnitude, 0))];
[self.children[0] setActive:magnitude < -DEAD_ZONE];
diff --git a/Classes/NJInputButton.h b/Classes/NJInputButton.h
index 31cba73..e9abdd3 100644
--- a/Classes/NJInputButton.h
+++ b/Classes/NJInputButton.h
@@ -10,6 +10,8 @@
@interface NJInputButton : NJInput
-- (id)initWithName:(NSString *)name idx:(int)idx max:(long)max;
+- (id)initWithElement:(IOHIDElementRef)element
+ index:(int)index
+ parent:(NJInputPathElement *)parent;
@end
diff --git a/Classes/NJInputButton.m b/Classes/NJInputButton.m
index caa759b..354220a 100644
--- a/Classes/NJInputButton.m
+++ b/Classes/NJInputButton.m
@@ -8,16 +8,18 @@
#import "NJInputButton.h"
@implementation NJInputButton {
- long _max;
+ CFIndex _max;
}
-- (id)initWithName:(NSString *)name idx:(int)idx max:(long)max {
- NSString *fullname = [NSString stringWithFormat:NSLocalizedString(@"button %d", @"button name"), idx];
- if (name.length)
- fullname = [fullname stringByAppendingFormat:@"- %@", name];
- NSString *did = [[NSString alloc] initWithFormat:@"Button %d", idx];
- if ((self = [super initWithName:fullname did:did base:nil])) {
- _max = max;
+- (id)initWithElement:(IOHIDElementRef)element
+ index:(int)index
+ parent:(NJInputPathElement *)parent
+{
+ if ((self = [super initWithName:NJINPUT_NAME(NSLocalizedString(@"button %d", @"button name"), index)
+ eid:NJINPUT_DID("Button", index)
+ element:element
+ parent:parent])) {
+ _max = IOHIDElementGetLogicalMax(element);
}
return self;
}
diff --git a/Classes/NJInputHat.h b/Classes/NJInputHat.h
index 5290d71..67bb21d 100644
--- a/Classes/NJInputHat.h
+++ b/Classes/NJInputHat.h
@@ -10,6 +10,8 @@
@interface NJInputHat : NJInput
-- (id)initWithIndex:(int)index;
+- (id)initWithElement:(IOHIDElementRef)element
+ index:(int)index
+ parent:(NJInputPathElement *)parent;
@end
diff --git a/Classes/NJInputHat.m b/Classes/NJInputHat.m
index 46ea94f..0a5afa2 100644
--- a/Classes/NJInputHat.m
+++ b/Classes/NJInputHat.m
@@ -27,31 +27,38 @@ static BOOL active_fourway[20] = {
NO, NO, YES, NO , // W
};
-@implementation NJInputHat
+@implementation NJInputHat {
+ CFIndex _max;
+}
-- (id)initWithIndex:(int)index {
- NSString *name = [NSString stringWithFormat:NSLocalizedString(@"hat switch %d", @"hat switch name"), index];
- NSString *did = [NSString stringWithFormat:@"Hat Switch %d", index];
- if ((self = [super initWithName:name did:did base:nil])) {
+- (id)initWithElement:(IOHIDElementRef)element
+ index:(int)index
+ parent:(NJInputPathElement *)parent
+{
+ if ((self = [super initWithName:NJINPUT_NAME(NSLocalizedString(@"hat switch %d", @"hat switch name"), index)
+ eid:NJINPUT_DID("Hat Switch", index)
+ element:element
+ parent:parent])) {
self.children = @[[[NJInput alloc] initWithName:NSLocalizedString(@"hat up", @"hat switch up state")
- did:@"Up"
- base:self],
+ eid:@"Up"
+ parent:self],
[[NJInput alloc] initWithName:NSLocalizedString(@"hat down", @"hat switch down state")
- did:@"Down"
- base:self],
+ eid:@"Down"
+ parent:self],
[[NJInput alloc] initWithName:NSLocalizedString(@"hat left", @"hat switch left state")
- did:@"Left"
- base:self],
+ eid:@"Left"
+ parent:self],
[[NJInput alloc] initWithName:NSLocalizedString(@"hat right", @"hat switch right state")
- did:@"Right"
- base:self]];
+ eid:@"Right"
+ parent:self]];
+ _max = IOHIDElementGetLogicalMax(element);
}
return self;
}
- (id)findSubInputForValue:(IOHIDValueRef)value {
long parsed = IOHIDValueGetIntegerValue(value);
- switch (IOHIDElementGetLogicalMax(IOHIDValueGetElement(value))) {
+ switch (_max) {
case 7: // 8-way switch, 0-7.
switch (parsed) {
case 0: return self.children[0];
@@ -91,7 +98,7 @@ static BOOL active_fourway[20] = {
- (void)notifyEvent:(IOHIDValueRef)value {
long parsed = IOHIDValueGetIntegerValue(value);
- long size = IOHIDElementGetLogicalMax(IOHIDValueGetElement(value));
+ long size = _max;
// Skip first row in table if 0 is not neutral.
if (size & 1) {
parsed++;
diff --git a/Classes/NJInputPathElement.h b/Classes/NJInputPathElement.h
index 3ad50c9..98c96fd 100644
--- a/Classes/NJInputPathElement.h
+++ b/Classes/NJInputPathElement.h
@@ -8,10 +8,10 @@
@interface NJInputPathElement : NSObject
- (id)initWithName:(NSString *)name
- did:(NSString *)did
- base:(NJInputPathElement *)base;
+ eid:(NSString *)eid
+ parent:(NJInputPathElement *)parent;
-@property (nonatomic, weak) NJInputPathElement *base;
+@property (nonatomic, weak) NJInputPathElement *parent;
@property (nonatomic, copy) NSString *name;
@property (nonatomic, readonly) NSString *uid;
@property (nonatomic, strong) NSArray *children;
diff --git a/Classes/NJInputPathElement.m b/Classes/NJInputPathElement.m
index eb5bfa7..ca9265e 100644
--- a/Classes/NJInputPathElement.m
+++ b/Classes/NJInputPathElement.m
@@ -9,16 +9,16 @@
#include "NJInputPathElement.h"
@implementation NJInputPathElement {
- NSString *_did;
+ NSString *_eid;
}
- (id)initWithName:(NSString *)name
- did:(NSString *)did
- base:(NJInputPathElement *)base {
+ eid:(NSString *)eid
+ parent:(NJInputPathElement *)parent {
if ((self = [super init])) {
self.name = name;
- self.base = base;
- _did = did;
+ self.parent = parent;
+ _eid = eid;
}
return self;
}
@@ -33,7 +33,7 @@
}
- (NSString *)uid {
- return [NSString stringWithFormat:@"%@~%@", _base.uid, _did];
+ return [NSString stringWithFormat:@"%@~%@", _parent.uid, _eid];
}
- (NJInputPathElement *)elementForUID:(NSString *)uid {
diff --git a/Classes/NJOutputController.m b/Classes/NJOutputController.m
index 4c8ce64..95d28c4 100644
--- a/Classes/NJOutputController.m
+++ b/Classes/NJOutputController.m
@@ -229,7 +229,7 @@
} else {
self.enabled = YES;
NSString *inpFullName = input.name;
- for (NJInputPathElement *cur = input.base; cur; cur = cur.base) {
+ for (NJInputPathElement *cur = input.parent; cur; cur = cur.parent) {
inpFullName = [[NSString alloc] initWithFormat:@"%@ ⸠%@", cur.name, inpFullName];
}
title.stringValue = inpFullName;
diff --git a/Info.plist b/Info.plist
index 285b858..bc56ad4 100644
--- a/Info.plist
+++ b/Info.plist
@@ -46,7 +46,7 @@
CFBundleSignature
????
CFBundleVersion
- 294
+ 296
LSApplicationCategoryType
public.app-category.utilities
NSHumanReadableCopyright
--
2.20.1
From eb9ae7c6c0504f07fe058e9be43ec26763be4591 Mon Sep 17 00:00:00 2001
From: Joe Wreschnig
Date: Thu, 14 Mar 2013 20:05:05 +0100
Subject: [PATCH 07/16] Some more renames.
---
Classes/EnjoyableApplicationDelegate.m | 12 ++--
Classes/NJDevice.m | 2 +-
Classes/NJDeviceController.h | 4 +-
Classes/NJDeviceController.m | 26 ++++----
Classes/NJInput.h | 2 +-
Classes/NJInput.m | 4 +-
Classes/NJInputAnalog.m | 2 +-
Classes/NJMappingMenuController.h | 4 +-
Classes/NJMappingMenuController.m | 20 +++---
Info.plist | 2 +-
Other Sources/NJEvents.h | 4 +-
Resources/English.lproj/Localizable.strings | Bin 7520 -> 7516 bytes
Resources/English.lproj/MainMenu.xib | 66 +++++++-------------
13 files changed, 63 insertions(+), 85 deletions(-)
diff --git a/Classes/EnjoyableApplicationDelegate.m b/Classes/EnjoyableApplicationDelegate.m
index b1d9907..db62f53 100644
--- a/Classes/EnjoyableApplicationDelegate.m
+++ b/Classes/EnjoyableApplicationDelegate.m
@@ -31,13 +31,13 @@
object:nil];
[NSNotificationCenter.defaultCenter
addObserver:self
- selector:@selector(eventTranslationActivated:)
- name:NJEventTranslationActivated
+ selector:@selector(eventSimulationStarted:)
+ name:NJEventSimulationStarted
object:nil];
[NSNotificationCenter.defaultCenter
addObserver:self
- selector:@selector(eventTranslationDeactivated:)
- name:NJEventTranslationDeactivated
+ selector:@selector(eventSimulationStopped:)
+ name:NJEventSimulationStopped
object:nil];
[self.mappingsController load];
@@ -104,7 +104,7 @@
return NO;
}
-- (void)eventTranslationActivated:(NSNotification *)note {
+- (void)eventSimulationStarted:(NSNotification *)note {
statusItem.image = [NSImage imageNamed:@"Status Menu Icon"];
[NSWorkspace.sharedWorkspace.notificationCenter
addObserver:self
@@ -113,7 +113,7 @@
object:nil];
}
-- (void)eventTranslationDeactivated:(NSNotification *)note {
+- (void)eventSimulationStopped:(NSNotification *)note {
statusItem.image = [NSImage imageNamed:@"Status Menu Icon Disabled"];
[NSWorkspace.sharedWorkspace.notificationCenter
removeObserver:self
diff --git a/Classes/NJDevice.m b/Classes/NJDevice.m
index e4c6b3d..b03898f 100644
--- a/Classes/NJDevice.m
+++ b/Classes/NJDevice.m
@@ -81,7 +81,7 @@ static NSArray *InputsForElement(IOHIDDeviceRef device, id parent) {
}
- (NSString *)uid {
- return [NSString stringWithFormat: @"%d:%d:%d", _vendorId, _productId, _index];
+ return [NSString stringWithFormat:@"%d:%d:%d", _vendorId, _productId, _index];
}
- (NJInput *)findInputByCookie:(IOHIDElementCookie)cookie {
diff --git a/Classes/NJDeviceController.h b/Classes/NJDeviceController.h
index f49d647..1391121 100644
--- a/Classes/NJDeviceController.h
+++ b/Classes/NJDeviceController.h
@@ -26,8 +26,8 @@
@property (nonatomic, readonly) NJInput *selectedInput;
@property (nonatomic, assign) NSPoint mouseLoc;
-@property (nonatomic, assign) BOOL translatingEvents;
+@property (nonatomic, assign) BOOL simulatingEvents;
-- (IBAction)translatingEventsChanged:(NSButton *)sender;
+- (IBAction)simulatingEventsChanged:(NSButton *)sender;
@end
diff --git a/Classes/NJDeviceController.m b/Classes/NJDeviceController.m
index 8cc5f2a..39ec389 100644
--- a/Classes/NJDeviceController.m
+++ b/Classes/NJDeviceController.m
@@ -144,7 +144,7 @@
- (void)hidManager:(NJHIDManager *)manager
valueChanged:(IOHIDValueRef)value
fromDevice:(IOHIDDeviceRef)device {
- if (self.translatingEvents) {
+ if (self.simulatingEvents) {
[self runOutputForDevice:device value:value];
} else {
[self showOutputForDevice:device value:value];
@@ -222,7 +222,7 @@ static int findAvailableIndex(NSArray *list, NJDevice *dev) {
didPresentSelector:nil
contextInfo:nil];
}
- self.translatingEvents = NO;
+ self.simulatingEvents = NO;
if (manager.running)
[self hidManagerDidStart:manager];
else
@@ -312,18 +312,18 @@ objectValueForTableColumn:(NSTableColumn *)tableColumn
forKey:@"expanded rows"];
}
-- (void)setTranslatingEvents:(BOOL)translatingEvents {
- if (translatingEvents != _translatingEvents) {
- _translatingEvents = translatingEvents;
- NSInteger state = translatingEvents ? NSOnState : NSOffState;
+- (void)setSimulatingEvents:(BOOL)simulatingEvents {
+ if (simulatingEvents != _simulatingEvents) {
+ _simulatingEvents = simulatingEvents;
+ NSInteger state = simulatingEvents ? NSOnState : NSOffState;
translatingEventsButton.state = state;
- NSString *name = translatingEvents
- ? NJEventTranslationActivated
- : NJEventTranslationDeactivated;
+ NSString *name = simulatingEvents
+ ? NJEventSimulationStarted
+ : NJEventSimulationStopped;
[NSNotificationCenter.defaultCenter postNotificationName:name
object:self];
- if (!translatingEvents && !NSApplication.sharedApplication.isActive)
+ if (!simulatingEvents && !NSApplication.sharedApplication.isActive)
[self stopHid];
else
[self startHid];
@@ -343,12 +343,12 @@ objectValueForTableColumn:(NSTableColumn *)tableColumn
}
- (void)stopHidIfDisabled:(NSNotification *)application {
- if (!self.translatingEvents)
+ if (!self.simulatingEvents)
[self stopHid];
}
-- (IBAction)translatingEventsChanged:(NSButton *)sender {
- self.translatingEvents = sender.state == NSOnState;
+- (IBAction)simulatingEventsChanged:(NSButton *)sender {
+ self.simulatingEvents = sender.state == NSOnState;
}
@end
diff --git a/Classes/NJInput.h b/Classes/NJInput.h
index db47121..b530c37 100644
--- a/Classes/NJInput.h
+++ b/Classes/NJInput.h
@@ -18,7 +18,7 @@
element:(IOHIDElementRef)element
parent:(NJInputPathElement *)parent;
-@property (nonatomic, assign) IOHIDElementCookie cookie;
+@property (nonatomic, readonly) IOHIDElementCookie cookie;
@property (nonatomic, assign) BOOL active;
@property (nonatomic, assign) float magnitude;
diff --git a/Classes/NJInput.m b/Classes/NJInput.m
index 82d5993..d7144a0 100644
--- a/Classes/NJInput.m
+++ b/Classes/NJInput.m
@@ -14,11 +14,11 @@
element:(IOHIDElementRef)element
parent:(NJInputPathElement *)parent
{
- NSString *elementName = (__bridge NSString *)(IOHIDElementGetName(element));
+ NSString *elementName = (__bridge NSString *)IOHIDElementGetName(element);
if (elementName.length)
name = [name stringByAppendingFormat:@"- %@", elementName];
if ((self = [super initWithName:name eid:eid parent:parent])) {
- self.cookie = IOHIDElementGetCookie(element);
+ _cookie = IOHIDElementGetCookie(element);
}
return self;
}
diff --git a/Classes/NJInputAnalog.m b/Classes/NJInputAnalog.m
index 3746c11..1f65f48 100644
--- a/Classes/NJInputAnalog.m
+++ b/Classes/NJInputAnalog.m
@@ -25,7 +25,7 @@ static float normalize(CFIndex p, CFIndex min, CFIndex max) {
if ((self = [super initWithName:NJINPUT_NAME(NSLocalizedString(@"axis %d", @"axis name"), index)
eid:NJINPUT_DID("Axis", index)
element:element
- parent:nil])) {
+ parent:parent])) {
self.children = @[[[NJInput alloc] initWithName:NSLocalizedString(@"axis low", @"axis low trigger")
eid:@"Low"
parent:self],
diff --git a/Classes/NJMappingMenuController.h b/Classes/NJMappingMenuController.h
index 9c9432a..a2de7e9 100644
--- a/Classes/NJMappingMenuController.h
+++ b/Classes/NJMappingMenuController.h
@@ -42,8 +42,8 @@
@property (nonatomic, assign) BOOL hasKeyEquivalents;
// Whether or not to add key equivalents to the menu items.
-@property (nonatomic, strong) IBOutlet NSMenuItem *eventTranslationToggle;
- // A menu item representing the current event translation state.
+@property (nonatomic, strong) IBOutlet NSMenuItem *eventSimulationToggle;
+ // A menu item representing the current event simulation state.
// This outlet is optional.
diff --git a/Classes/NJMappingMenuController.m b/Classes/NJMappingMenuController.m
index 03ce31d..6d9250f 100644
--- a/Classes/NJMappingMenuController.m
+++ b/Classes/NJMappingMenuController.m
@@ -27,12 +27,12 @@
name:NJEventMappingChanged
object:nil];
[center addObserver:self
- selector:@selector(eventTranslationActivated:)
- name:NJEventTranslationActivated
+ selector:@selector(eventSimulationStarted:)
+ name:NJEventSimulationStarted
object:nil];
[center addObserver:self
- selector:@selector(eventTranslationDeactivated:)
- name:NJEventTranslationDeactivated
+ selector:@selector(eventSimulationStopped:)
+ name:NJEventSimulationStopped
object:nil];
}
return self;
@@ -99,14 +99,14 @@
item.state = mapping == item.representedObject;
}
-- (void)eventTranslationActivated:(NSNotification *)note {
- self.eventTranslationToggle.title = NSLocalizedString(@"Disable",
- @"menu item text to disable event translation");
+- (void)eventSimulationStarted:(NSNotification *)note {
+ self.eventSimulationToggle.title = NSLocalizedString(@"Disable",
+ @"menu item text to disable event simulation");
}
-- (void)eventTranslationDeactivated:(NSNotification *)note {
- self.eventTranslationToggle.title = NSLocalizedString(@"Enable",
- @"menu item text to enable event translation");
+- (void)eventSimulationStopped:(NSNotification *)note {
+ self.eventSimulationToggle.title = NSLocalizedString(@"Enable",
+ @"menu item text to enable event simulation");
}
@end
diff --git a/Info.plist b/Info.plist
index bc56ad4..0ea7a95 100644
--- a/Info.plist
+++ b/Info.plist
@@ -46,7 +46,7 @@
CFBundleSignature
????
CFBundleVersion
- 296
+ 298
LSApplicationCategoryType
public.app-category.utilities
NSHumanReadableCopyright
diff --git a/Other Sources/NJEvents.h b/Other Sources/NJEvents.h
index 5485154..204a270 100644
--- a/Other Sources/NJEvents.h
+++ b/Other Sources/NJEvents.h
@@ -8,8 +8,8 @@
#define NJEventMappingChanged @"com.yukkurigames.Enjoyable.MappingChanged"
#define NJEventMappingListChanged @"com.yukkurigames.Enjoyable.MappingListChanged"
-#define NJEventTranslationActivated @"com.yukkurigames.Enjoyable.EventTranslationActivated"
-#define NJEventTranslationDeactivated @"com.yukkurigames.Enjoyable.EventTranslationDeactivated"
+#define NJEventSimulationStarted @"com.yukkurigames.Enjoyable.EventSimulationStarted"
+#define NJEventSimulationStopped @"com.yukkurigames.Enjoyable.EventSimulationStopped"
#define NJMappingKey @"com.yukkurigames.Enjoyable.Mapping"
#define NJMappingListKey @"com.yukkurigames.Enjoyable.MappingList"
diff --git a/Resources/English.lproj/Localizable.strings b/Resources/English.lproj/Localizable.strings
index 8b9a71782f2bf1dcc87e4fa301c7df7b43d4a61f..0e30ce1842093ae8662c75ed023e88a319e3faa0 100644
GIT binary patch
delta 36
lcmaE0b;oK$8Vh?dLncEmL+NBjR`JPgEJZN>W=7U{2>{lI3Pb<^
delta 36
jcmca(^}uRF8VhF$LlHwFLmor%
{664, 323}
-
+
256
@@ -501,7 +501,6 @@
-2147483374
{{20, 20}, {194, 283}}
-
_NS:22
YES
@@ -531,7 +530,6 @@ Lg
274
{{20, 20}, {194, 283}}
-
_NS:22
YES
@@ -566,7 +564,6 @@ aW5nLg
{232, 321}
-
YES
NO
@@ -662,7 +659,6 @@ aW5nLg
{{1, 1}, {232, 321}}
-
@@ -673,7 +669,6 @@ aW5nLg
-2147483392
{{1, 1}, {8, 298}}
-
NO
@@ -685,7 +680,6 @@ aW5nLg
-2147483392
{{-100, -100}, {473, 15}}
-
NO
1
@@ -696,7 +690,6 @@ aW5nLg
{234, 323}
-
150034
@@ -710,7 +703,6 @@ aW5nLg
{234, 323}
-
_NS:9
NSView
@@ -724,7 +716,6 @@ aW5nLg
265
{{189, 117}, {224, 20}}
-
_NS:9
YES
@@ -766,7 +757,6 @@ aW5nLg
268
{{343, 31}, {70, 18}}
-
_NS:9
YES
@@ -797,7 +787,6 @@ aW5nLg
265
{{189, 33}, {150, 20}}
-
_NS:9
YES
@@ -842,7 +831,6 @@ aW5nLg
265
{{191, 24}, {146, 16}}
-
_NS:9
YES
@@ -868,7 +856,6 @@ aW5nLg
265
{{189, 70}, {224, 24}}
-
_NS:9
YES
@@ -922,7 +909,6 @@ aW5nLg
265
{{191, 108}, {220, 16}}
-
_NS:9
YES
@@ -948,7 +934,6 @@ aW5nLg
265
{{191, 196}, {220, 23}}
-
_NS:9
NJKeyInputField
@@ -958,7 +943,6 @@ aW5nLg
265
{{188, 153}, {226, 26}}
-
YES
826
-
-
- translatingEventsChanged:
-
-
-
- 878
-
translatingEventsButton
@@ -1709,6 +1679,14 @@ aW5nLg
976
+
+
+ simulatingEventsChanged:
+
+
+
+ 978
+
mappingsController
@@ -2101,14 +2079,6 @@ aW5nLg
933
-
-
- eventTranslationToggle
-
-
-
- 951
-
menu
@@ -2125,6 +2095,14 @@ aW5nLg
956
+
+
+ eventSimulationToggle
+
+
+
+ 980
+
menu
@@ -2143,11 +2121,11 @@ aW5nLg
- eventTranslationToggle
+ eventSimulationToggle
- 959
+ 979
@@ -2167,11 +2145,11 @@ aW5nLg
- eventTranslationToggle
+ eventSimulationToggle
- 965
+ 981
@@ -3267,7 +3245,7 @@ aW5nLg
- 977
+ 981
--
2.20.1
From 48c014b3f30482f32f50a3a60e88584930265277 Mon Sep 17 00:00:00 2001
From: Joe Wreschnig
Date: Thu, 14 Mar 2013 21:06:40 +0100
Subject: [PATCH 08/16] Mappings list doesn't need to be public anymore.
---
Classes/NJMappingsController.h | 1 -
1 file changed, 1 deletion(-)
diff --git a/Classes/NJMappingsController.h b/Classes/NJMappingsController.h
index dcb44b0..a4d9c18 100644
--- a/Classes/NJMappingsController.h
+++ b/Classes/NJMappingsController.h
@@ -24,7 +24,6 @@
}
@property (nonatomic, readonly) NJMapping *currentMapping;
-@property (nonatomic, readonly) NSArray *mappings;
- (NJMapping *)objectForKeyedSubscript:(NSString *)name;
- (NJMapping *)objectAtIndexedSubscript:(NSUInteger)idx;
--
2.20.1
From 6dddafbcf505939751ddb2d66ffb586d150aaaa8 Mon Sep 17 00:00:00 2001
From: Joe Wreschnig
Date: Thu, 14 Mar 2013 21:10:22 +0100
Subject: [PATCH 09/16] Don't let the app control itself, it only leads to
accidents or mouse bugs. Don't auto-focus the key field when simulating
either.
---
Classes/NJDeviceController.m | 6 ++++--
Info.plist | 2 +-
.../Contents/Resources/English.lproj/pgs/mouse.html | 10 ----------
.../Contents/Resources/English.lproj/pgs/whatsnew.html | 5 +++++
4 files changed, 10 insertions(+), 13 deletions(-)
diff --git a/Classes/NJDeviceController.m b/Classes/NJDeviceController.m
index 39ec389..0b0fe92 100644
--- a/Classes/NJDeviceController.m
+++ b/Classes/NJDeviceController.m
@@ -138,13 +138,15 @@
[self expandRecursive:handler];
[outlineView selectRowIndexes:[NSIndexSet indexSetWithIndex:[outlineView rowForItem:handler]]
byExtendingSelection: NO];
- [outputController focusKey];
+ if (!self.simulatingEvents)
+ [outputController focusKey];
}
- (void)hidManager:(NJHIDManager *)manager
valueChanged:(IOHIDValueRef)value
fromDevice:(IOHIDDeviceRef)device {
- if (self.simulatingEvents) {
+ if (self.simulatingEvents
+ && !NSApplication.sharedApplication.isActive) {
[self runOutputForDevice:device value:value];
} else {
[self showOutputForDevice:device value:value];
diff --git a/Info.plist b/Info.plist
index 0ea7a95..ed9e83f 100644
--- a/Info.plist
+++ b/Info.plist
@@ -46,7 +46,7 @@
CFBundleSignature
????
CFBundleVersion
- 298
+ 301
LSApplicationCategoryType
public.app-category.utilities
NSHumanReadableCopyright
diff --git a/Resources/Help/Contents/Resources/English.lproj/pgs/mouse.html b/Resources/Help/Contents/Resources/English.lproj/pgs/mouse.html
index 5436540..f52c5b6 100644
--- a/Resources/Help/Contents/Resources/English.lproj/pgs/mouse.html
+++ b/Resources/Help/Contents/Resources/English.lproj/pgs/mouse.html
@@ -76,15 +76,5 @@
change this globally in  > System Preferences⦠> Mouse
and  > System Preferences⦠> Trackpad .
-
- Known Issues
-
- Enjoyable is unable to send most mouse events to itself - the
- application will freeze until you click on it with a real mouse
- or touchpad. If you find another appliation that has problems
- with Enjoyable's mouse support please
- file a ticket in the issue tracker .
-