Only refocus key input for empty/key targets.
authorJoe Wreschnig <joe.wreschnig@gmail.com>
Thu, 28 Feb 2013 14:01:17 +0000 (15:01 +0100)
committerJoe Wreschnig <joe.wreschnig@gmail.com>
Thu, 28 Feb 2013 14:01:17 +0000 (15:01 +0100)
JoystickController.m
TargetController.m

index 864a917..0675075 100644 (file)
@@ -17,7 +17,6 @@
 
 @implementation JoystickController {
     IOHIDManagerRef hidManager;
 
 @implementation JoystickController {
     IOHIDManagerRef hidManager;
-    BOOL programmaticallySelecting;
     NSTimer *continuousTimer;
 }
 
     NSTimer *continuousTimer;
 }
 
@@ -84,8 +83,8 @@ static void input_callback(void *ctx, IOReturn inResult, void *inSender, IOHIDVa
             return;
         
         [controller expandRecursive:handler];
             return;
         
         [controller expandRecursive:handler];
-        controller->programmaticallySelecting = YES;
         [controller->outlineView selectRowIndexes:[NSIndexSet indexSetWithIndex:[controller->outlineView rowForItem:handler]] byExtendingSelection: NO];
         [controller->outlineView selectRowIndexes:[NSIndexSet indexSetWithIndex:[controller->outlineView rowForItem:handler]] byExtendingSelection: NO];
+        [controller->targetController focusKey];
     }
 }
 
     }
 }
 
@@ -192,9 +191,6 @@ static void remove_callback(void *ctx, IOReturn inResult, void *inSender, IOHIDD
 - (void)outlineViewSelectionDidChange: (NSNotification*) notification {
     [targetController reset];
     [targetController load];
 - (void)outlineViewSelectionDidChange: (NSNotification*) notification {
     [targetController reset];
     [targetController load];
-    if (programmaticallySelecting)
-        [targetController focusKey];
-    programmaticallySelecting = NO;
 }
 
 @end
 }
 
 @end
index 8afaaf2..14f81a9 100644 (file)
 }
 
 -(void) focusKey {
 }
 
 -(void) focusKey {
-       [[[NSApplication sharedApplication] mainWindow] makeFirstResponder: keyInput];
+    Target *currentTarget = configsController.currentConfig[currentJsaction];
+    if (!currentTarget || [currentTarget isKindOfClass:[TargetKeyboard class]])
+        [[[NSApplication sharedApplication] mainWindow] makeFirstResponder: keyInput];
+    else
+        [keyInput resignFirstResponder];
 }
 
 -(void) refreshConfigsPreservingSelection: (BOOL) preserve  {
 }
 
 -(void) refreshConfigsPreservingSelection: (BOOL) preserve  {