Remove a branch that could never trigger (unsigned < 0) and some other logic errors...
[enjoyable.git] / JoystickController.m
index 976b531..1bf5b43 100644 (file)
@@ -65,7 +65,7 @@ void input_callback(void* inContext, IOReturn inResult, void* inSender, IOHIDVal
        IOHIDDeviceRef device = IOHIDQueueGetDevice((IOHIDQueueRef) inSender);
        
        Joystick* js = [self findJoystickByRef: device];
-       if([[[NSApplication sharedApplication] delegate] active]) {
+       if([(ApplicationController *)[[NSApplication sharedApplication] delegate] active]) {
                // for reals
                JSAction* mainAction = [js actionForEvent: value];
                if(!mainAction)
@@ -148,10 +148,10 @@ void add_callback(void* inContext, IOReturn inResult, void* inSender, IOHIDDevic
 }
        
 -(Joystick*) findJoystickByRef: (IOHIDDeviceRef) device {
-       for(int i=0; i<[joysticks count]; i++)
-               if([[joysticks objectAtIndex:i] device] == device)
-                       return [joysticks objectAtIndex:i];
-       return NULL;
+    for (Joystick *js in joysticks)
+        if (js.device == device)
+            return js;
+       return nil;
 }      
 
 void remove_callback(void* inContext, IOReturn inResult, void* inSender, IOHIDDeviceRef device) {