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 864a917cff446ae613f8282deb856f7537c7a8fc..0675075f158545ed1fba58d7e7cd7b2e95cc964e 100644 (file)
@@ -17,7 +17,6 @@
 
 @implementation JoystickController {
     IOHIDManagerRef hidManager;
-    BOOL programmaticallySelecting;
     NSTimer *continuousTimer;
 }
 
@@ -84,8 +83,8 @@ static void input_callback(void *ctx, IOReturn inResult, void *inSender, IOHIDVa
             return;
         
         [controller expandRecursive:handler];
-        controller->programmaticallySelecting = YES;
         [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];
-    if (programmaticallySelecting)
-        [targetController focusKey];
-    programmaticallySelecting = NO;
 }
 
 @end
index 8afaaf2fc6056d2f79140875fde15dff400f767d..14f81a94dd4ab317d302cfd55ef57047f43cd498 100644 (file)
 }
 
 -(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  {