// Created by Sam McCall on 5/05/09.
//
+#import "JSActionHat.h"
+
static BOOL active_eightway[36] = {
NO, NO, NO, NO , // center
YES, NO, NO, NO , // N
@implementation JSActionHat
-- (id)init {
+- (id)initWithIndex:(int)index {
if ((self = [super init])) {
- self.children = @[[[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]];
- // TODO(jfw): Should have an indexed name, like everything else.
- self.name = @"Hat switch";
+ self.children = @[[[JSAction alloc] initWithName:@"Up" base:self],
+ [[JSAction alloc] initWithName:@"Down" base:self],
+ [[JSAction alloc] initWithName:@"Left" base:self],
+ [[JSAction alloc] initWithName:@"Right" base:self]];
+ self.name = [NSString stringWithFormat:@"Hat Switch %d", index];
}
return self;
}
- (id)findSubActionForValue:(IOHIDValueRef)value {
- int parsed = IOHIDValueGetIntegerValue(value);
+ long parsed = IOHIDValueGetIntegerValue(value);
switch (IOHIDElementGetLogicalMax(IOHIDValueGetElement(value))) {
case 7: // 8-way switch, 0-7.
switch (parsed) {
}
- (void)notifyEvent:(IOHIDValueRef)value {
- int parsed = IOHIDValueGetIntegerValue(value);
- int size = IOHIDElementGetLogicalMax(IOHIDValueGetElement(value));
+ long parsed = IOHIDValueGetIntegerValue(value);
+ long size = IOHIDElementGetLogicalMax(IOHIDValueGetElement(value));
// Skip first row in table if 0 is not neutral.
if (size & 1) {
parsed++;