From: Joe Wreschnig Date: Mon, 1 Apr 2013 11:39:04 +0000 (+0200) Subject: More better names. X-Git-Tag: version-1.1~1 X-Git-Url: https://git.yukkurigames.com/?p=enjoyable.git;a=commitdiff_plain;h=281e575060f936fd9483d1cf6416851b3783fe42;ds=sidebyside More better names. --- diff --git a/Classes/NJDevice.h b/Classes/NJDevice.h index 9f2cb97..d6e5dc2 100644 --- a/Classes/NJDevice.h +++ b/Classes/NJDevice.h @@ -15,7 +15,6 @@ - (id)initWithDevice:(IOHIDDeviceRef)device; @property (nonatomic, assign) int index; -@property (nonatomic, copy) NSString *productName; @property (nonatomic, assign) IOHIDDeviceRef device; - (NJInput *)handlerForEvent:(IOHIDValueRef)value; diff --git a/Classes/NJDevice.m b/Classes/NJDevice.m index bf39251..c6cc201 100644 --- a/Classes/NJDevice.m +++ b/Classes/NJDevice.m @@ -66,9 +66,9 @@ static NSArray *InputsForElement(IOHIDDeviceRef device, id parent) { } - (id)initWithDevice:(IOHIDDeviceRef)dev { - if ((self = [super initWithName:nil eid:nil parent:nil])) { + NSString *name = (__bridge NSString *)IOHIDDeviceGetProperty(dev, CFSTR(kIOHIDProductKey)); + if ((self = [super initWithName:name eid:nil parent: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]; self.children = InputsForElement(dev, self); @@ -79,12 +79,11 @@ static NSArray *InputsForElement(IOHIDDeviceRef device, id parent) { - (BOOL)isEqual:(id)object { return [object isKindOfClass:NJDevice.class] - && [[(NJDevice *)object productName] isEqualToString:self.productName] - && [(NJDevice *)object index] == self.index; + && [[(NJDevice *)object name] isEqualToString:self.name]; } - (NSString *)name { - return [NSString stringWithFormat:@"%@ #%d", _productName, _index]; + return [NSString stringWithFormat:@"%@ #%d", super.name, _index]; } - (NSString *)uid { diff --git a/Classes/NJKeyInputField.h b/Classes/NJKeyInputField.h index c32e16c..bc1876c 100644 --- a/Classes/NJKeyInputField.h +++ b/Classes/NJKeyInputField.h @@ -11,14 +11,13 @@ extern const CGKeyCode NJKeyInputFieldEmpty; @protocol NJKeyInputFieldDelegate; -@interface NJKeyInputField : NSControl +@interface NJKeyInputField : NSControl // An NJKeyInputField is a NSTextField-like widget that receives // exactly one key press, and displays the name of that key, then // resigns its first responder status. It can also inform a // special delegate when its content changes. -+ (NSString *)stringForKeyCode:(CGKeyCode)keyCode; - // Give the string name for a virtual key code. ++ (NSString *)displayNameForKeyCode:(CGKeyCode)keyCode; @property (nonatomic, weak) IBOutlet id delegate; @@ -28,14 +27,14 @@ extern const CGKeyCode NJKeyInputFieldEmpty; // inform the delegate. @property (nonatomic, readonly) BOOL hasKeyCode; - // True if any key is active, false otherwise. + // YES if any key is set, NO otherwise. - (void)clear; // Clear the currently active key and call the delegate. @end -@protocol NJKeyInputFieldDelegate +@protocol NJKeyInputFieldDelegate - (void)keyInputField:(NJKeyInputField *)keyInput didChangeKey:(CGKeyCode)keyCode; diff --git a/Classes/NJKeyInputField.m b/Classes/NJKeyInputField.m index 791911b..36435f0 100644 --- a/Classes/NJKeyInputField.m +++ b/Classes/NJKeyInputField.m @@ -20,6 +20,9 @@ enum { const CGKeyCode NJKeyInputFieldEmpty = kVK_MAX; +@interface NJKeyInputField () +@end + @implementation NJKeyInputField { NSTextField *field; NSImageView *warning; @@ -52,7 +55,7 @@ const CGKeyCode NJKeyInputFieldEmpty = kVK_MAX; - (void)clear { self.keyCode = NJKeyInputFieldEmpty; - [self.delegate keyInputFieldDidClear:self]; + [self.delegate keyInputFieldDidClear:self]; [self resignIfFirstResponder]; } @@ -60,7 +63,7 @@ const CGKeyCode NJKeyInputFieldEmpty = kVK_MAX; return self.keyCode != NJKeyInputFieldEmpty; } -+ (NSString *)stringForKeyCode:(CGKeyCode)keyCode { ++ (NSString *)displayNameForKeyCode:(CGKeyCode)keyCode { switch (keyCode) { case kVK_F1: return @"F1"; case kVK_F2: return @"F2"; @@ -204,7 +207,6 @@ const CGKeyCode NJKeyInputFieldEmpty = kVK_MAX; case kVK_ApplicationMenu: return NSLocalizedString(@"Menu", "keyboard key"); - case kVK_MAX: // NJKeyInputFieldEmpty return @""; default: @@ -230,7 +232,7 @@ const CGKeyCode NJKeyInputFieldEmpty = kVK_MAX; - (void)setKeyCode:(CGKeyCode)keyCode { _keyCode = keyCode; - field.stringValue = [NJKeyInputField stringForKeyCode:keyCode]; + field.stringValue = [NJKeyInputField displayNameForKeyCode:keyCode]; } - (void)keyDown:(NSEvent *)event { diff --git a/Classes/NJMapping.m b/Classes/NJMapping.m index 3d5cd67..bcd2a8d 100644 --- a/Classes/NJMapping.m +++ b/Classes/NJMapping.m @@ -39,7 +39,7 @@ if ([entries isKindOfClass:NSDictionary.class]) { for (id key in entries) { if ([key isKindOfClass:NSString.class]) { - NJOutput *output = [NJOutput outputDeserialize:entries[key]]; + NJOutput *output = [NJOutput outputWithSerialization:entries[key]]; if (output) _entries[key] = output; } diff --git a/Classes/NJMappingMenuController.h b/Classes/NJMappingMenuController.h index 33c06bb..ff62d41 100644 --- a/Classes/NJMappingMenuController.h +++ b/Classes/NJMappingMenuController.h @@ -46,5 +46,4 @@ // A menu item representing the current event simulation state. // This outlet is optional. - @end diff --git a/Classes/NJMappingsViewController.h b/Classes/NJMappingsViewController.h index 8e1055a..d1cdb1f 100644 --- a/Classes/NJMappingsViewController.h +++ b/Classes/NJMappingsViewController.h @@ -37,7 +37,6 @@ - (void)beginUpdates; - (void)endUpdates; - @end @protocol NJMappingsViewControllerDelegate diff --git a/Classes/NJOutput.h b/Classes/NJOutput.h index 52c0320..1c57d45 100644 --- a/Classes/NJOutput.h +++ b/Classes/NJOutput.h @@ -16,10 +16,10 @@ - (void)trigger; - (void)untrigger; -- (BOOL)update:(NJInputController *)jc; +- (BOOL)update:(NJInputController *)ic; - (NSDictionary *)serialize; -+ (NJOutput *)outputDeserialize:(NSDictionary *)serialization; ++ (NJOutput *)outputWithSerialization:(NSDictionary *)serialization; + (NSString *)serializationCode; - (void)postLoadProcess:(id )allMappings; diff --git a/Classes/NJOutput.m b/Classes/NJOutput.m index 8b21164..bf9e2e8 100644 --- a/Classes/NJOutput.m +++ b/Classes/NJOutput.m @@ -36,7 +36,7 @@ return [[self serialize] hash]; } -+ (NJOutput *)outputDeserialize:(NSDictionary *)serialization { ++ (NJOutput *)outputWithSerialization:(NSDictionary *)serialization { // Don't crash loading old/bad mappings (but don't load them either). if (![serialization isKindOfClass:NSDictionary.class]) return nil; @@ -48,7 +48,7 @@ NJOutputMouseScroll.class ]) { if ([type isEqualToString:cls.serializationCode]) - return [cls outputDeserialize:serialization]; + return [cls outputWithSerialization:serialization]; } return nil; @@ -60,7 +60,7 @@ - (void)untrigger { } -- (BOOL)update:(NJInputController *)jc { +- (BOOL)update:(NJInputController *)ic { return NO; } diff --git a/Classes/NJOutputKeyPress.m b/Classes/NJOutputKeyPress.m index 7b8c631..a69d8f3 100644 --- a/Classes/NJOutputKeyPress.m +++ b/Classes/NJOutputKeyPress.m @@ -21,7 +21,7 @@ : nil; } -+ (NJOutput *)outputDeserialize:(NSDictionary *)serialization { ++ (NJOutput *)outputWithSerialization:(NSDictionary *)serialization { NJOutputKeyPress *output = [[NJOutputKeyPress alloc] init]; output.keyCode = [serialization[@"key"] intValue]; return output; diff --git a/Classes/NJOutputMapping.m b/Classes/NJOutputMapping.m index 2ee6a84..124c8a3 100644 --- a/Classes/NJOutputMapping.m +++ b/Classes/NJOutputMapping.m @@ -23,7 +23,7 @@ : nil; } -+ (NJOutputMapping *)outputDeserialize:(NSDictionary *)serialization { ++ (NJOutputMapping *)outputWithSerialization:(NSDictionary *)serialization { NSString *name = serialization[@"name"]; NJOutputMapping *output = [[NJOutputMapping alloc] init]; output.mappingName = name; diff --git a/Classes/NJOutputMouseButton.m b/Classes/NJOutputMouseButton.m index 0b039d1..068a5dd 100644 --- a/Classes/NJOutputMouseButton.m +++ b/Classes/NJOutputMouseButton.m @@ -36,7 +36,7 @@ return @{ @"type": self.class.serializationCode, @"button": @(_button) }; } -+ (NJOutput *)outputDeserialize:(NSDictionary *)serialization { ++ (NJOutput *)outputWithSerialization:(NSDictionary *)serialization { NJOutputMouseButton *output = [[NJOutputMouseButton alloc] init]; output.button = [serialization[@"button"] intValue]; return output; diff --git a/Classes/NJOutputMouseMove.m b/Classes/NJOutputMouseMove.m index f943546..0918593 100644 --- a/Classes/NJOutputMouseMove.m +++ b/Classes/NJOutputMouseMove.m @@ -22,7 +22,7 @@ }; } -+ (NJOutput *)outputDeserialize:(NSDictionary *)serialization { ++ (NJOutput *)outputWithSerialization:(NSDictionary *)serialization { NJOutputMouseMove *output = [[NJOutputMouseMove alloc] init]; output.axis = [serialization[@"axis"] intValue]; output.speed = [serialization[@"speed"] floatValue]; @@ -37,7 +37,7 @@ #define CLAMP(a, l, h) MIN(h, MAX(a, l)) -- (BOOL)update:(NJInputController *)jc { +- (BOOL)update:(NJInputController *)ic { if (self.magnitude < 0.05) return NO; // dead zone @@ -58,10 +58,10 @@ dy = self.magnitude * _speed; break; } - NSPoint mouseLoc = jc.mouseLoc; + NSPoint mouseLoc = ic.mouseLoc; mouseLoc.x = CLAMP(mouseLoc.x + dx, 0, size.width - 1); mouseLoc.y = CLAMP(mouseLoc.y - dy, 0, size.height - 1); - jc.mouseLoc = mouseLoc; + ic.mouseLoc = mouseLoc; CGEventRef move = CGEventCreateMouseEvent(NULL, kCGEventMouseMoved, CGPointMake(mouseLoc.x, size.height - mouseLoc.y), diff --git a/Classes/NJOutputMouseScroll.m b/Classes/NJOutputMouseScroll.m index b2775a8..1ae08cc 100644 --- a/Classes/NJOutputMouseScroll.m +++ b/Classes/NJOutputMouseScroll.m @@ -21,7 +21,7 @@ }; } -+ (NJOutput *)outputDeserialize:(NSDictionary *)serialization { ++ (NJOutput *)outputWithSerialization:(NSDictionary *)serialization { NJOutputMouseScroll *output = [[NJOutputMouseScroll alloc] init]; output.direction = [serialization[@"direction"] intValue]; output.speed = [serialization[@"speed"] floatValue]; @@ -52,7 +52,7 @@ } } -- (BOOL)update:(NJInputController *)jc { +- (BOOL)update:(NJInputController *)ic { if (self.magnitude < 0.05f) return NO; // dead zone diff --git a/Classes/NJOutputViewController.h b/Classes/NJOutputViewController.h index fe251cd..7e35b70 100644 --- a/Classes/NJOutputViewController.h +++ b/Classes/NJOutputViewController.h @@ -33,10 +33,10 @@ - (void)loadOutput:(NJOutput *)output forInput:(NJInput *)input; - (void)focusKey; -- (IBAction)radioChanged:(id)sender; -- (IBAction)mdirChanged:(id)sender; -- (IBAction)mbtnChanged:(id)sender; -- (IBAction)sdirChanged:(id)sender; +- (IBAction)outputTypeChanged:(id)sender; +- (IBAction)mouseDirectionChanged:(id)sender; +- (IBAction)mouseButtonChanged:(id)sender; +- (IBAction)scrollDirectionChanged:(id)sender; - (IBAction)mouseSpeedChanged:(id)sender; - (IBAction)scrollSpeedChanged:(id)sender; - (IBAction)scrollTypeChanged:(id)sender; diff --git a/Classes/NJOutputViewController.m b/Classes/NJOutputViewController.m index 0ca3938..9bd723b 100644 --- a/Classes/NJOutputViewController.m +++ b/Classes/NJOutputViewController.m @@ -83,7 +83,7 @@ } -- (IBAction)radioChanged:(NSView *)sender { +- (IBAction)outputTypeChanged:(NSView *)sender { [sender.window makeFirstResponder:sender]; if (self.radioButtons.selectedRow == 1) [self.keyInput.window makeFirstResponder:self.keyInput]; @@ -108,7 +108,7 @@ [self commit]; } -- (void)mdirChanged:(NSView *)sender { +- (void)mouseDirectionChanged:(NSView *)sender { [self.radioButtons selectCellAtRow:3 column:0]; [sender.window makeFirstResponder:sender]; [self commit]; @@ -120,13 +120,13 @@ [self commit]; } -- (void)mbtnChanged:(NSView *)sender { +- (void)mouseButtonChanged:(NSView *)sender { [self.radioButtons selectCellAtRow:4 column:0]; [sender.window makeFirstResponder:sender]; [self commit]; } -- (void)sdirChanged:(NSView *)sender { +- (void)scrollDirectionChanged:(NSView *)sender { [self.radioButtons selectCellAtRow:5 column:0]; [sender.window makeFirstResponder:sender]; [self commit]; diff --git a/Info.plist b/Info.plist index 3f58f54..b48d847 100644 --- a/Info.plist +++ b/Info.plist @@ -46,7 +46,7 @@ CFBundleSignature ???? CFBundleVersion - 579 + 582 LSApplicationCategoryType public.app-category.utilities NSHumanReadableCopyright diff --git a/Resources/English.lproj/MainMenu.xib b/Resources/English.lproj/MainMenu.xib index 7a2e668..60e65bd 100644 --- a/Resources/English.lproj/MainMenu.xib +++ b/Resources/English.lproj/MainMenu.xib @@ -488,7 +488,7 @@ {664, 323} - + 256 @@ -500,7 +500,6 @@ -2147483374 {{20, 20}, {194, 283}} - _NS:22 YES @@ -530,7 +529,6 @@ Lg 274 {{20, 20}, {194, 283}} - _NS:22 YES @@ -565,7 +563,6 @@ aW5nLg {232, 321} - YES NO @@ -661,7 +658,6 @@ aW5nLg {{1, 1}, {232, 321}} - @@ -672,7 +668,6 @@ aW5nLg -2147483392 {{1, 1}, {8, 298}} - NO @@ -684,7 +679,6 @@ aW5nLg -2147483392 {{-100, -100}, {473, 15}} - NO 1 @@ -695,7 +689,6 @@ aW5nLg {234, 323} - 150034 @@ -709,7 +702,6 @@ aW5nLg {234, 323} - _NS:9 NSView @@ -723,7 +715,6 @@ aW5nLg 268 {{197, 157}, {193, 21}} - _NS:9 YES @@ -748,7 +739,6 @@ aW5nLg 265 {{189, 117}, {224, 20}} - _NS:9 YES @@ -790,7 +780,6 @@ aW5nLg 268 {{343, 31}, {70, 18}} - _NS:9 YES @@ -821,7 +810,6 @@ aW5nLg 265 {{189, 33}, {150, 20}} - _NS:9 YES @@ -866,7 +854,6 @@ aW5nLg 265 {{191, 24}, {146, 16}} - _NS:9 YES @@ -892,7 +879,6 @@ aW5nLg 265 {{189, 70}, {224, 24}} - _NS:9 YES @@ -946,7 +932,6 @@ aW5nLg 265 {{191, 108}, {220, 16}} - _NS:9 YES @@ -972,7 +957,6 @@ aW5nLg 265 {{191, 196}, {220, 23}} - _NS:9 NJKeyInputField @@ -982,7 +966,6 @@ aW5nLg 265 {{188, 153}, {226, 26}} - YES @@ -1015,7 +998,6 @@ aW5nLg 268 {{24, 20}, {163, 250}} - NO 6 @@ -1146,7 +1128,6 @@ aW5nLg 266 {{9, 286}, {412, 17}} - YES @@ -1170,7 +1151,6 @@ aW5nLg 10 {{12, 276}, {406, 5}} - {0, 0} @@ -1197,15 +1177,12 @@ aW5nLg {{233, 0}, {431, 323}} - _NS:9 NSView {664, 323} - - {{0, 0}, {1440, 878}} @@ -1310,7 +1287,7 @@ aW5nLg YES - + 256 @@ -1326,7 +1303,6 @@ aW5nLg 256 {198, 198} - YES NO @@ -1384,7 +1360,6 @@ aW5nLg {{1, 1}, {198, 198}} - @@ -1395,7 +1370,6 @@ aW5nLg -2147483392 {{306, 1}, {15, 403}} - NO @@ -1407,7 +1381,6 @@ aW5nLg -2147483392 {{-100, -100}, {366, 16}} - NO 1 @@ -1418,7 +1391,6 @@ aW5nLg {{0, 20}, {200, 200}} - 150034 @@ -1434,7 +1406,6 @@ aW5nLg 268 {{66, -1}, {68, 23}} - _NS:22 YES @@ -1463,7 +1434,6 @@ aW5nLg 292 {{0, -1}, {34, 23}} - YES @@ -1490,7 +1460,6 @@ aW5nLg 292 {{166, -1}, {34, 23}} - YES 67108864 @@ -1512,7 +1481,6 @@ aW5nLg 292 {{133, -1}, {34, 23}} - YES @@ -1535,7 +1503,6 @@ aW5nLg 292 {{33, -1}, {34, 23}} - YES @@ -1559,8 +1526,6 @@ aW5nLg {200, 220} - - NSView @@ -1835,22 +1800,6 @@ aW5nLg 823 - - - mdirChanged: - - - - 757 - - - - sdirChanged: - - - - 752 - scrollSpeedSlider @@ -1859,14 +1808,6 @@ aW5nLg 891 - - - radioChanged: - - - - 731 - keyInput @@ -1875,14 +1816,6 @@ aW5nLg 781 - - - mbtnChanged: - - - - 747 - mouseSpeedChanged: @@ -1971,6 +1904,38 @@ aW5nLg 1035 + + + scrollDirectionChanged: + + + + 1038 + + + + mouseButtonChanged: + + + + 1039 + + + + mouseDirectionChanged: + + + + 1040 + + + + outputTypeChanged: + + + + 1041 + delegate @@ -3344,7 +3309,7 @@ aW5nLg - 1037 + 1041