Reset target settings in UI when switching target types.
[enjoyable.git] / JoystickController.m
index d87dca7..0675075 100644 (file)
@@ -7,9 +7,16 @@
 
 #import "JoystickController.h"
 
+#import "ApplicationController.h"
+#import "Config.h"
+#import "ConfigsController.h"
+#import "Joystick.h"
+#import "JSAction.h"
+#import "Target.h"
+#import "TargetController.h"
+
 @implementation JoystickController {
     IOHIDManagerRef hidManager;
-    BOOL programmaticallySelecting;
     NSTimer *continuousTimer;
 }
 
@@ -76,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];
     }
 }
 
@@ -184,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