X-Git-Url: https://git.yukkurigames.com/?p=enjoyable.git;a=blobdiff_plain;f=Classes%2FNJDeviceController.m;fp=Classes%2FNJDeviceController.m;h=2f1736b4b2e2ebd12fc50943fadb83ebc369b664;hp=610c07b5a4f29c925572a850209c3b4e3d6bfc9d;hb=bda2aa3a8897f574b97c0bd125e84374087017a9;hpb=47a530c22a3f277d11e7ddb4b0147c8f93f6f9cd diff --git a/Classes/NJDeviceController.m b/Classes/NJDeviceController.m index 610c07b..2f1736b 100644 --- a/Classes/NJDeviceController.m +++ b/Classes/NJDeviceController.m @@ -210,11 +210,23 @@ static int findAvailableIndex(NSArray *list, NJDevice *dev) { } - (void)hidManager:(NJHIDManager *)manager didError:(NSError *)error { - [outlineView.window presentError:error - modalForWindow:outlineView.window - delegate:nil - didPresentSelector:nil - contextInfo:nil]; + // Since the error shows the window, it can trigger another attempt + // to re-open the HID manager, which will also probably fail and error, + // so don't bother repeating ourselves. + if (!outlineView.window.attachedSheet) { + [NSApplication.sharedApplication activateIgnoringOtherApps:YES]; + [outlineView.window makeKeyAndOrderFront:nil]; + [outlineView.window presentError:error + modalForWindow:outlineView.window + delegate:nil + didPresentSelector:nil + contextInfo:nil]; + } + self.translatingEvents = NO; + if (manager.running) + [self hidManagerDidStart:manager]; + else + [self hidManagerDidStop:manager]; } - (void)hidManagerDidStart:(NJHIDManager *)manager { @@ -313,7 +325,7 @@ objectValueForTableColumn:(NSTableColumn *)tableColumn if (!translatingEvents && !NSApplication.sharedApplication.isActive) [self stopHid]; - else if (translatingEvents || NSApplication.sharedApplication.isActive) + else [self startHid]; } }