#import "NJOutputMouseMove.h"
#import "NJOutputMouseScroll.h"
-@implementation NJOutputController
+@implementation NJOutputController {
+ NJInput *_input;
+}
- (id)init {
if ((self = [super init])) {
if (row != 2) {
[mappingPopup selectItemAtIndex:-1];
[mappingPopup resignIfFirstResponder];
- } else if (!mappingPopup.selectedItem)
- [mappingPopup selectItemAtIndex:0];
+ unknownMapping.hidden = YES;
+ }
if (row != 3) {
mouseDirSelect.selectedSegment = -1;
- (void)mappingChosen:(id)sender {
[radioButtons selectCellAtRow:2 column:0];
[mappingPopup.window makeFirstResponder:mappingPopup];
+ unknownMapping.hidden = YES;
[self commit];
}
}
- (NJOutput *)currentOutput {
- return mappingsController.currentMapping[inputController.selectedInput];
+ return mappingsController.currentMapping[_input];
}
- (NJOutput *)makeOutput {
case 1:
if (keyInput.hasKeyCode) {
NJOutputKeyPress *k = [[NJOutputKeyPress alloc] init];
- k.vk = keyInput.keyCode;
+ k.keyCode = keyInput.keyCode;
return k;
} else {
return nil;
- (void)commit {
[self cleanUpInterface];
- mappingsController.currentMapping[inputController.selectedInput] = [self makeOutput];
+ mappingsController.currentMapping[_input] = [self makeOutput];
[mappingsController save];
}
scrollDirSelect.enabled = enabled;
smoothCheck.enabled = enabled;
scrollSpeedSlider.enabled = enabled && smoothCheck.state;
+ if (!enabled)
+ unknownMapping.hidden = YES;
}
- (void)loadOutput:(NJOutput *)output forInput:(NJInput *)input {
if ([output isKindOfClass:NJOutputKeyPress.class]) {
[radioButtons selectCellAtRow:1 column:0];
- keyInput.keyCode = [(NJOutputKeyPress*)output vk];
+ keyInput.keyCode = [(NJOutputKeyPress*)output keyCode];
} else if ([output isKindOfClass:NJOutputMapping.class]) {
[radioButtons selectCellAtRow:2 column:0];
- NSMenuItem *item = [mappingPopup itemWithRepresentedObject:[(NJOutputMapping *)output mapping]];
+ NSMenuItem *item = [mappingPopup itemWithIdenticalRepresentedObject:[(NJOutputMapping *)output mapping]];
[mappingPopup selectItem:item];
- if (!item)
- [radioButtons selectCellAtRow:self.enabled ? 0 : -1 column:0];
+ unknownMapping.hidden = !!item;
+ unknownMapping.title = [(NJOutputMapping *)output mappingName];
}
else if ([output isKindOfClass:NJOutputMouseMove.class]) {
[radioButtons selectCellAtRow:3 column:0];
[self cleanUpInterface];
}
-- (void)loadCurrent {
- [self loadOutput:self.currentOutput forInput:inputController.selectedInput];
+- (void)loadInput:(NJInput *)input {
+ _input = input;
+ [self loadOutput:self.currentOutput forInput:input];
}
- (void)focusKey {
item.representedObject = mapping;
[mappingPopup.menu addItem:item];
}
- [mappingPopup selectItemWithRepresentedObject:current];
+ [mappingPopup selectItemWithIdenticalRepresentedObject:current];
}
- (void)mappingDidChange:(NSNotification *)note {
- [self loadCurrent];
+ [self loadInput:_input];
}
@end