D5617D1A0FAF568100928B3A /* JSActionButton.m in Sources */ = {isa = PBXBuildFile; fileRef = D5617D190FAF568100928B3A /* JSActionButton.m */; };
D5617D260FAF579300928B3A /* JSActionHat.m in Sources */ = {isa = PBXBuildFile; fileRef = D5617D250FAF579300928B3A /* JSActionHat.m */; };
D5617D2B0FAF579A00928B3A /* JSActionAnalog.m in Sources */ = {isa = PBXBuildFile; fileRef = D5617D2A0FAF579A00928B3A /* JSActionAnalog.m */; };
- D5617DF20FAF636C00928B3A /* SubAction.m in Sources */ = {isa = PBXBuildFile; fileRef = D5617DF10FAF636C00928B3A /* SubAction.m */; };
D5617FD60FAFD06000928B3A /* Target.m in Sources */ = {isa = PBXBuildFile; fileRef = D5617FD50FAFD06000928B3A /* Target.m */; };
D5617FD90FAFD1E600928B3A /* TargetKeyboard.m in Sources */ = {isa = PBXBuildFile; fileRef = D5617FD80FAFD1E600928B3A /* TargetKeyboard.m */; };
D5617FE40FAFD7B000928B3A /* TargetController.m in Sources */ = {isa = PBXBuildFile; fileRef = D5617FE30FAFD7B000928B3A /* TargetController.m */; };
D5617D250FAF579300928B3A /* JSActionHat.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = JSActionHat.m; sourceTree = "<group>"; };
D5617D290FAF579A00928B3A /* JSActionAnalog.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSActionAnalog.h; sourceTree = "<group>"; };
D5617D2A0FAF579A00928B3A /* JSActionAnalog.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = JSActionAnalog.m; sourceTree = "<group>"; };
- D5617DF00FAF636C00928B3A /* SubAction.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SubAction.h; sourceTree = "<group>"; };
- D5617DF10FAF636C00928B3A /* SubAction.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SubAction.m; sourceTree = "<group>"; };
D5617FD40FAFD06000928B3A /* Target.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Target.h; sourceTree = "<group>"; };
D5617FD50FAFD06000928B3A /* Target.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = Target.m; sourceTree = "<group>"; };
D5617FD70FAFD1E600928B3A /* TargetKeyboard.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TargetKeyboard.h; sourceTree = "<group>"; };
D5617A350FAEB74000928B3A /* ConfigsController.m */,
D5617A370FAEBA1800928B3A /* Config.h */,
D5617A380FAEBA1800928B3A /* Config.m */,
- D5617DF00FAF636C00928B3A /* SubAction.h */,
- D5617DF10FAF636C00928B3A /* SubAction.m */,
D5F8096F0FB093400006A4DE /* TargetConfig.h */,
D5F809700FB093400006A4DE /* TargetConfig.m */,
D5617FD40FAFD06000928B3A /* Target.h */,
D5617D1A0FAF568100928B3A /* JSActionButton.m in Sources */,
D5617D260FAF579300928B3A /* JSActionHat.m in Sources */,
D5617D2B0FAF579A00928B3A /* JSActionAnalog.m in Sources */,
- D5617DF20FAF636C00928B3A /* SubAction.m in Sources */,
D5617FD60FAFD06000928B3A /* Target.m in Sources */,
D5617FD90FAFD1E600928B3A /* TargetKeyboard.m in Sources */,
D5617FE40FAFD7B000928B3A /* TargetController.m in Sources */,
#import "JSActionButton.h"
#import "JSActionHat.h"
#import "KeyInputTextView.h"
-#import "SubAction.h"
#import "Target.h"
#import "TargetConfig.h"
#import "TargetController.h"
@property (assign) BOOL active;
@property (readonly) float magnitude;
+- (id)initWithName:(NSString *)newName base:(JSAction *)newBase;
+
- (void)notifyEvent:(IOHIDValueRef)value;
- (NSString *)stringify;
- (id)findSubActionForValue:(IOHIDValueRef)value;
@synthesize name;
@synthesize active;
+- (id)initWithName:(NSString *)newName base:(JSAction *)newBase {
+ if ((self = [super init])) {
+ self.name = newName;
+ self.base = newBase;
+ }
+ return self;
+}
+
- (id)findSubActionForValue:(IOHIDValueRef)value {
return NULL;
}
- (NSString *)stringify {
- return [NSString stringWithFormat: @"%@~%p", [base stringify], cookie];
+ if (cookie)
+ return [NSString stringWithFormat: @"%@~%p", [base stringify], cookie];
+ else
+ return [NSString stringWithFormat: @"%@~%@", [base stringify], name];
}
- (void)notifyEvent:(IOHIDValueRef)value {
- (id)initWithIndex:(int)newIndex offset:(float)offset_ scale:(float)scale_ {
if ((self = [super init])) {
- self.children = @[[[SubAction alloc] initWithIndex:0 name:@"Low" base:self],
- [[SubAction alloc] initWithIndex:1 name:@"High" base:self]];
+ self.children = @[[[JSAction alloc] initWithName:@"Low" base:self],
+ [[JSAction alloc] initWithName:@"High" base:self]];
self.index = newIndex;
self.offset = offset_;
self.scale = scale_;
- self.name = [[NSString alloc] initWithFormat: @"Axis %d", self.index + 1];
+ self.name = [[NSString alloc] initWithFormat: @"Axis %d", self.index];
}
return self;
}
self.index = idx;
self.max = max_;
if (name_.length)
- self.name = [NSString stringWithFormat:@"Button %d - %@", self.index + 1, name_];
+ self.name = [NSString stringWithFormat:@"Button %d - %@", self.index, name_];
else
- self.name = [NSString stringWithFormat:@"Button %d", self.index + 1];
+ self.name = [NSString stringWithFormat:@"Button %d", self.index];
}
return self;
}
- (id)init {
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]];
+ 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]];
// TODO(jfw): Should have an indexed name, like everything else.
self.name = @"Hat switch";
}
if (max - min == 1 || usagePage == kHIDPage_Button || type == kIOHIDElementTypeInput_Button) {
action = [[JSActionButton alloc] initWithName:(__bridge NSString *)elName
- idx:buttons++
+ idx:++buttons
max:max];
} else if (usage == kHIDUsage_GD_Hatswitch) {
action = [[JSActionHat alloc] init];
} else if (usage >= kHIDUsage_GD_X && usage <= kHIDUsage_GD_Rz) {
// TODO(jfw): Scaling equation doesn't seem right if min != 0.
- action = [[JSActionAnalog alloc] initWithIndex:axes++
+ action = [[JSActionAnalog alloc] initWithIndex:++axes
offset:-1.f
scale:2.f / (max - min)];
} else {
}
- (NSString *)name {
- return [NSString stringWithFormat:@"%@ #%d", productName, index + 1];
+ return [NSString stringWithFormat:@"%@ #%d", productName, index];
}
- (id)base {
}
static int findAvailableIndex(NSArray *list, Joystick *js) {
- for (int index = 0; ; index++) {
+ for (int index = 1; ; index++) {
BOOL available = YES;
for (Joystick *used in list) {
if ([used.productName isEqualToString:js.productName] && used.index == index) {
+++ /dev/null
-//
-// SubAction.h
-// Enjoy
-//
-// Created by Sam McCall on 5/05/09.
-// Copyright 2009 University of Otago. All rights reserved.
-//
-
-#import <Cocoa/Cocoa.h>
-
-#import "JSAction.h"
-
-@interface SubAction : JSAction
-
-- (id)initWithIndex:(int)newIndex name:(NSString *)newName base:(JSAction *)newBase;
-
-@end
+++ /dev/null
-//
-// SubAction.m
-// Enjoy
-//
-// Created by Sam McCall on 5/05/09.
-//
-
-// TODO(jfw): This class is useless and can just be replaced w/ JSAction probably.
-
-#import "SubAction.h"
-
-@implementation SubAction
-
-- (id)initWithIndex:(int)newIndex name:(NSString *)newName base:(JSAction *)newBase {
- if ((self = [super init])) {
- self.name = newName;
- self.base = newBase;
- self.index = newIndex;
- }
- return self;
-}
-
--(NSString*) stringify {
- return [[NSString alloc] initWithFormat: @"%@~%d", [self.base stringify], self.index];
-}
-
-@end