@class TargetController;
@class ConfigsController;
-@interface ApplicationController : NSObject {
+@interface ApplicationController : NSObject <NSApplicationDelegate> {
IBOutlet NSDrawer *drawer;
IBOutlet NSWindow *mainWindow;
IBOutlet NSToolbarItem *activeButton;
EE1D7C9116E01E7000B000EB /* NSView+FirstResponder.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "NSView+FirstResponder.m"; sourceTree = "<group>"; };
EE1D7C9416E0ECCF00B000EB /* NSError+Description.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "NSError+Description.h"; sourceTree = "<group>"; };
EE1D7C9516E0ECCF00B000EB /* NSError+Description.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "NSError+Description.m"; sourceTree = "<group>"; };
+ EEF86B7316E2241000674B87 /* NJActionPathElement.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = NJActionPathElement.h; sourceTree = "<group>"; };
/* End PBXFileReference section */
/* Begin PBXFrameworksBuildPhase section */
8BEFAD9B15C46BFF00823AEC /* TargetMouseScroll.m */,
8BEFAD9E15C476DC00823AEC /* TargetToggleMouseScope.h */,
8BEFAD9F15C476DC00823AEC /* TargetToggleMouseScope.m */,
+ EEF86B7316E2241000674B87 /* NJActionPathElement.h */,
);
name = Classes;
sourceTree = "<group>";
// Copyright 2009 University of Otago. All rights reserved.
//
-@interface JSAction : NSObject
+#import "NJActionPathElement.h"
+
+@interface JSAction : NSObject <NJActionPathElement>
@property (nonatomic, assign) IOHIDElementCookie cookie;
@property (nonatomic, copy) NSArray *children;
@property (nonatomic, readonly) float magnitude;
@property (readonly) NSString *uid;
-- (id)initWithName:(NSString *)newName base:(JSAction *)newBase;
+- (id)initWithName:(NSString *)newName base:(id <NJActionPathElement>)newBase;
- (void)notifyEvent:(IOHIDValueRef)value;
- (id)findSubActionForValue:(IOHIDValueRef)value;
@implementation JSAction
-- (id)initWithName:(NSString *)newName base:(JSAction *)newBase {
+- (id)initWithName:(NSString *)newName base:(id <NJActionPathElement>)newBase {
if ((self = [super init])) {
self.name = newName;
self.base = newBase;
// Copyright 2009 University of Otago. All rights reserved.
//
+#import "NJActionPathElement.h"
+
@class JSAction;
-@interface Joystick : NSObject
+@interface Joystick : NSObject <NJActionPathElement>
@property (nonatomic, assign) int index;
@property (nonatomic, copy) NSString *productName;
@property (readonly) NSString *uid;
- (id)initWithDevice:(IOHIDDeviceRef)device;
-- (id)handlerForEvent:(IOHIDValueRef)value;
+- (JSAction *)handlerForEvent:(IOHIDValueRef)value;
- (JSAction *)actionForEvent:(IOHIDValueRef)value;
@end
return nil;
}
-- (id)handlerForEvent:(IOHIDValueRef) value {
+- (JSAction *)handlerForEvent:(IOHIDValueRef)value {
JSAction *mainAction = [self actionForEvent:value];
return [mainAction findSubActionForValue:value];
}
CFRelease(hidManager);
}
-- (void)expandRecursive:(id)handler {
- if ([handler base])
- [self expandRecursive:[handler base]];
- [outlineView expandItem:handler];
+- (void)expandRecursive:(id <NJActionPathElement>)pathElement {
+ if (pathElement) {
+ [self expandRecursive:pathElement.base];
+ [outlineView expandItem:pathElement];
+ }
}
- (void)addRunningTarget:(Target *)target {
}
- (JSAction *)selectedAction {
- id item = [outlineView itemAtRow:outlineView.selectedRow];
- return [item children] ? nil : item;
+ id <NJActionPathElement> item = [outlineView itemAtRow:outlineView.selectedRow];
+ return (!item.children && item.base) ? item : nil;
}
-- (NSInteger)outlineView:(NSOutlineView *)outlineView numberOfChildrenOfItem:(id)item {
- return item ? [[item children] count] : _joysticks.count;
+- (NSInteger)outlineView:(NSOutlineView *)outlineView
+ numberOfChildrenOfItem:(id <NJActionPathElement>)item {
+ return item ? item.children.count : _joysticks.count;
}
-- (BOOL)outlineView:(NSOutlineView *)outlineView isItemExpandable:(id)item {
+- (BOOL)outlineView:(NSOutlineView *)outlineView
+ isItemExpandable:(id <NJActionPathElement>)item {
return item ? [[item children] count] > 0: YES;
}
-- (id)outlineView:(NSOutlineView *)outlineView child:(NSInteger)index ofItem:(id)item {
- return item ? [item children][index] : _joysticks[index];
+- (id)outlineView:(NSOutlineView *)outlineView
+ child:(NSInteger)index
+ ofItem:(id <NJActionPathElement>)item {
+ return item ? item.children[index] : _joysticks[index];
}
-- (id)outlineView:(NSOutlineView *)outlineView objectValueForTableColumn:(NSTableColumn *)tableColumn byItem:(id)item {
- if(item == nil)
- return @"root";
- return [item name];
+- (id)outlineView:(NSOutlineView *)outlineView
+objectValueForTableColumn:(NSTableColumn *)tableColumn
+ byItem:(id <NJActionPathElement>)item {
+ return item ? item.name : @"root";
}
- (void)outlineViewSelectionDidChange:(NSNotification *)notification {
--- /dev/null
+#import <Foundation/Foundation.h>
+
+@protocol NJActionPathElement <NSObject>
+
+- (NSArray *)children;
+- (id <NJActionPathElement>) base;
+- (NSString *)name;
+
+@end
} else {
self.enabled = YES;
NSString *actFullName = action.name;
- for (JSAction *cur = action.base; cur; cur = cur.base) {
+ for (id <NJActionPathElement> cur = action.base; cur; cur = cur.base) {
actFullName = [[NSString alloc] initWithFormat:@"%@ > %@", cur.name, actFullName];
}
title.stringValue = [[NSString alloc] initWithFormat:@"%@ > %@", configsController.currentConfig.name, actFullName];