X-Git-Url: https://git.yukkurigames.com/?p=enjoyable.git;a=blobdiff_plain;f=JSActionHat.m;fp=JSActionHat.m;h=61241b99c17bbaa9de8a155161bb8f186cf43f32;hp=1ea30af7284dd297e931ed684073894c8dd5839f;hb=51ca12b552a9c17c4d4029b0340e193b273044a8;hpb=5704217edc0a67f3720053248d5c9ba10131b776 diff --git a/JSActionHat.m b/JSActionHat.m index 1ea30af..61241b9 100644 --- a/JSActionHat.m +++ b/JSActionHat.m @@ -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