'Convert to Modern Objective-C Syntax'...
[enjoyable.git] / JSActionHat.m
index 1ea30af..61241b9 100644 (file)
@@ -28,13 +28,10 @@ NO,  NO,  YES, NO , // W
 
 - (id) init {
        if(self = [super init]) {
-               subActions = [NSArray arrayWithObjects:
-                                         [[SubAction alloc] initWithIndex: 0 name: @"Up" base: self],
+               subActions = @[[[SubAction alloc] initWithIndex: 0 name: @"Up" base: self],
                                          [[SubAction alloc] initWithIndex: 1 name: @"Down" base: self],
                                          [[SubAction alloc] initWithIndex: 2 name: @"Left" base: self],
-                                         [[SubAction alloc] initWithIndex: 3 name: @"Right" base: self],
-                                         nil
-                                         ];
+                                         [[SubAction alloc] initWithIndex: 3 name: @"Right" base: self]];
                [subActions retain];
                name = @"Hat switch";
        }
@@ -46,34 +43,34 @@ NO,  NO,  YES, NO , // W
        if(IOHIDElementGetLogicalMax(IOHIDValueGetElement(value)) == 7) {
                // 8-way
                switch(parsed) {
-                       case 0: return [subActions objectAtIndex: 0];
-                       case 4: return [subActions objectAtIndex: 1];
-                       case 6: return [subActions objectAtIndex: 2];
-                       case 2: return [subActions objectAtIndex: 3];
+                       case 0: return subActions[0];
+                       case 4: return subActions[1];
+                       case 6: return subActions[2];
+                       case 2: return subActions[3];
                }
        } else  if(IOHIDElementGetLogicalMax(IOHIDValueGetElement(value)) == 8) {
                // 8-way
                switch(parsed) {
-                       case 1: return [subActions objectAtIndex: 0];
-                       case 5: return [subActions objectAtIndex: 1];
-                       case 7: return [subActions objectAtIndex: 2];
-                       case 3: return [subActions objectAtIndex: 3];
+                       case 1: return subActions[0];
+                       case 5: return subActions[1];
+                       case 7: return subActions[2];
+                       case 3: return subActions[3];
                }
        } else if(IOHIDElementGetLogicalMax(IOHIDValueGetElement(value)) == 3) {
                        // 4-way
                switch(parsed) {
-                       case 0: return [subActions objectAtIndex: 0];
-                       case 2: return [subActions objectAtIndex: 1];
-                       case 3: return [subActions objectAtIndex: 2];
-                       case 1: return [subActions objectAtIndex: 3];
+                       case 0: return subActions[0];
+                       case 2: return subActions[1];
+                       case 3: return subActions[2];
+                       case 1: return subActions[3];
                }
        } else if(IOHIDElementGetLogicalMax(IOHIDValueGetElement(value)) == 4) {
                // 4-way
                switch(parsed) {
-                       case 1: return [subActions objectAtIndex: 0];
-                       case 3: return [subActions objectAtIndex: 1];
-                       case 4: return [subActions objectAtIndex: 2];
-                       case 2: return [subActions objectAtIndex: 3];
+                       case 1: return subActions[0];
+                       case 3: return subActions[1];
+                       case 4: return subActions[2];
+                       case 2: return subActions[3];
                }
        }
        return NULL;
@@ -88,7 +85,7 @@ NO,  NO,  YES, NO , // W
        }
        BOOL* activeSubactions = (size == 8) ? active_eightway : active_fourway;
        for(int i=0; i<4; i++)
-               [[subActions objectAtIndex: i] setActive: activeSubactions[parsed * 4 + i]];
+               [subActions[i] setActive: activeSubactions[parsed * 4 + i]];
 }
 
 @end