+ [self.ic activateMapping:self.ic.mappings[idx]];
+}
+
+- (id)deviceViewController:(NJDeviceViewController *)dvc
+ elementForUID:(NSString *)uid {
+ return [self.ic elementForUID:uid];
+}
+
+- (void)loadOutputForInput:(NJInput *)input {
+ NJOutput *output = self.ic.currentMapping[input];
+ [self.oc loadOutput:output forInput:input];
+}
+
+- (void)deviceViewControllerDidSelectNothing:(NJDeviceViewController *)dvc {
+ [self loadOutputForInput:nil];
+}
+
+- (void)deviceViewController:(NJDeviceViewController *)dvc
+ didSelectBranch:(NJInputPathElement *)handler {
+ [self loadOutputForInput:dvc.selectedHandler];
+}
+
+- (void)deviceViewController:(NJDeviceViewController *)dvc
+ didSelectHandler:(NJInputPathElement *)handler {
+ [self loadOutputForInput:dvc.selectedHandler];
+}
+
+- (void)deviceViewController:(NJDeviceViewController *)dvc
+ didSelectDevice:(NJInputPathElement *)device {
+ [self loadOutputForInput:dvc.selectedHandler];
+}
+
+- (void)inputController:(NJInputController *)ic
+ didAddDevice:(NJDevice *)device {
+ [self.dvc addedDevice:device atIndex:ic.devices.count - 1];
+}
+
+- (void)inputController:(NJInputController *)ic
+ didRemoveDeviceAtIndex:(NSInteger)idx {
+ [self.dvc removedDeviceAtIndex:idx];
+}
+
+- (void)inputControllerDidStartHID:(NJInputController *)ic {
+ [self.dvc hidStarted];
+}
+
+- (void)inputControllerDidStopHID:(NJInputController *)ic {
+ [self.dvc hidStopped];
+}
+
+- (void)inputController:(NJInputController *)ic didInput:(NJInput *)input {
+ [self.dvc expandAndSelectItem:input];
+ [self loadOutputForInput:input];
+ [self.oc focusKey];
+}
+
+- (void)inputController:(NJInputController *)ic didError:(NSError *)error {
+ [self presentErrorSheet:error];
+}
+
+- (NSInteger)numberOfDevicesInDeviceList:(NJDeviceViewController *)dvc {
+ return self.ic.devices.count;
+}
+
+- (NJDevice *)deviceViewController:(NJDeviceViewController *)dvc
+ deviceForIndex:(NSUInteger)idx {
+ return self.ic.devices[idx];
+}
+
+- (IBAction)simulatingEventsChanged:(NSButton *)sender {
+ self.ic.simulatingEvents = sender.state == NSOnState;
+}
+
+- (void)outputViewController:(NJOutputViewController *)ovc
+ setOutput:(NJOutput *)output
+ forInput:(NJInput *)input {
+ self.ic.currentMapping[input] = output;
+ [self.ic save];
+}
+
+- (NJMapping *)outputViewController:(NJOutputViewController *)ovc
+ mappingForIndex:(NSUInteger)index {
+ return self.ic.mappings[index];