}
@property(readwrite) BOOL active;
-@property(readonly) JoystickController * jsController;
-@property(readonly) TargetController * targetController;
-@property(readonly) ConfigsController * configsController;
+@property(strong, readonly) JoystickController * jsController;
+@property(strong, readonly) TargetController * targetController;
+@property(strong, readonly) ConfigsController * configsController;
-(IBAction) toggleActivity: (id)sender;
-(void) configsChanged;
-(void) configChanged;
et.eventClass = kEventClassApplication;
et.eventKind = kEventAppFrontSwitched;
EventHandlerUPP handler = NewEventHandlerUPP(appSwitch);
- InstallApplicationEventHandler(handler, 1, &et, self, NULL);
+ InstallApplicationEventHandler(handler, 1, &et, (void *)CFBridgingRetain(self), NULL);
}
-(void) applicationWillTerminate: (NSNotification *)aNotification {
}
pascal OSStatus appSwitch(EventHandlerCallRef handlerChain, EventRef event, void* userData) {
- ApplicationController* self = (ApplicationController*)userData;
+ ApplicationController* self = (__bridge ApplicationController*)userData;
NSDictionary* currentApp = [[NSWorkspace sharedWorkspace] activeApplication];
ProcessSerialNumber psn;
psn.lowLongOfPSN = [currentApp[@"NSApplicationProcessSerialNumberLow"] longValue];
-(NSDictionary*) dumpAll;
-(void) loadAllFrom: (NSDictionary*) dict;
-@property(readonly) Config* currentConfig;
-@property(readonly) Config* currentNeutralConfig;
+@property(strong, readonly) Config* currentConfig;
+@property(strong, readonly) Config* currentNeutralConfig;
@property(readonly) NSArray* configs;
@property(readonly) ProcessSerialNumber* targetApplication;
-(void) save;
[ary addObject: cfgInfo];
}
envelope[@"configurationList"] = ary;
- envelope[@"selectedIndex"] = [NSNumber numberWithInt: [configs indexOfObject: [self currentNeutralConfig] ] ];
+ envelope[@"selectedIndex"] = @([configs indexOfObject: [self currentNeutralConfig] ]);
return envelope;
}
-(void) loadAllFrom: (NSDictionary*) envelope{
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
ARCHS = "$(ARCHS_STANDARD_64_BIT)";
+ CLANG_ENABLE_OBJC_ARC = YES;
COMBINE_HIDPI_IMAGES = YES;
COPY_PHASE_STRIP = NO;
FRAMEWORK_SEARCH_PATHS = (
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
ARCHS = "$(ARCHS_STANDARD_64_BIT)";
+ CLANG_ENABLE_OBJC_ARC = YES;
COMBINE_HIDPI_IMAGES = YES;
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
FRAMEWORK_SEARCH_PATHS = (
@interface JSAction : NSObject {
int usage, index;
void* cookie;
- NSArray* subActions;
+ NSArray *subActions;
id base;
- NSString* name;
+ NSString *name;
}
@property(readwrite) int usage;
@property(readwrite) void* cookie;
@property(readonly) int index;
-@property(readonly) NSArray* subActions;
-@property(readwrite, retain) id base;
-@property(readonly) NSString* name;
+@property(copy) NSArray* subActions;
+@property(readwrite, strong) id base;
+@property(copy) NSString* name;
@property(readonly) BOOL active;
-(void) notifyEvent: (IOHIDValueRef) value;
subActions = @[[[SubAction alloc] initWithIndex: 0 name: @"Low" base: self],
[[SubAction alloc] initWithIndex: 1 name: @"High" base: self],
[[SubAction alloc] initWithIndex: 2 name: @"Analog" base: self]];
- [subActions retain];
index = newIndex;
name = [[NSString alloc] initWithFormat: @"Axis %d", (index+1)];
}
[[SubAction alloc] initWithIndex: 1 name: @"Down" base: self],
[[SubAction alloc] initWithIndex: 2 name: @"Left" base: self],
[[SubAction alloc] initWithIndex: 3 name: @"Right" base: self]];
- [subActions retain];
name = @"Hat switch";
}
return self;
children = [[NSMutableArray alloc]init];
device = newDevice;
- productName = (NSString*)IOHIDDeviceGetProperty( device, CFSTR(kIOHIDProductKey) );
- vendorId = [(NSNumber*)IOHIDDeviceGetProperty(device, CFSTR(kIOHIDVendorIDKey)) intValue];
- productId = [(NSNumber*)IOHIDDeviceGetProperty(device, CFSTR(kIOHIDVendorIDKey)) intValue];
+ productName = (__bridge NSString*)IOHIDDeviceGetProperty( device, CFSTR(kIOHIDProductKey) );
+ vendorId = [(__bridge NSNumber*)IOHIDDeviceGetProperty(device, CFSTR(kIOHIDVendorIDKey)) intValue];
+ productId = [(__bridge NSNumber*)IOHIDDeviceGetProperty(device, CFSTR(kIOHIDVendorIDKey)) intValue];
name = productName;
}
}
-(void) populateActions {
- NSArray* elements = (NSArray*)IOHIDDeviceCopyMatchingElements(device, NULL, kIOHIDOptionsTypeNone);
+ NSArray* elements = (NSArray*)CFBridgingRelease(IOHIDDeviceCopyMatchingElements(device, NULL, kIOHIDOptionsTypeNone));
int buttons = 0;
int axes = 0;
for(int i=0; i<[elements count]; i++) {
- IOHIDElementRef element = (IOHIDElementRef)elements[i];
+ IOHIDElementRef element = (__bridge IOHIDElementRef)elements[i];
int type = IOHIDElementGetType(element);
int usage = IOHIDElementGetUsage(element);
int usagePage = IOHIDElementGetUsagePage(element);
}
if((max - min == 1) || usagePage == kHIDPage_Button || type == kIOHIDElementTypeInput_Button) {
- action = [[JSActionButton alloc] initWithIndex: buttons++ andName: (NSString *)elName];
+ action = [[JSActionButton alloc] initWithIndex: buttons++ andName: (__bridge NSString *)elName];
[(JSActionButton*)action setMax: max];
} else if(usage == 0x39)
action = [[JSActionHat alloc] init];
-(void) setup;
-(Joystick*) findJoystickByRef: (IOHIDDeviceRef) device;
-@property(readonly) id selectedAction;
+@property(strong, readonly) id selectedAction;
@property(readonly) NSMutableArray *joysticks;
@property(readonly) NSMutableArray *runningTargets;
@property(readwrite) BOOL frontWindowOnly;
return self;
}
--(void) finalize {
+-(void) dealloc {
for(int i=0; i<[joysticks count]; i++) {
[joysticks[i] invalidate];
}
IOHIDManagerClose(hidManager, kIOHIDOptionsTypeNone);
CFRelease(hidManager);
- [super finalize];
}
static NSMutableDictionary* create_criterion( UInt32 inUsagePage, UInt32 inUsage )
{
NSMutableDictionary* dict = [[NSMutableDictionary alloc] init];
- dict[(NSString*)CFSTR(kIOHIDDeviceUsagePageKey)] = [NSNumber numberWithInt: inUsagePage];
- dict[(NSString*)CFSTR(kIOHIDDeviceUsageKey)] = [NSNumber numberWithInt: inUsage];
+ dict[(NSString*)CFSTR(kIOHIDDeviceUsagePageKey)] = @(inUsagePage);
+ dict[(NSString*)CFSTR(kIOHIDDeviceUsageKey)] = @(inUsage);
return dict;
}
}
void timer_callback(CFRunLoopTimerRef timer, void *ctx) {
- JoystickController *jc = (JoystickController *)ctx;
+ JoystickController *jc = (__bridge JoystickController *)ctx;
jc->mouseLoc = [NSEvent mouseLocation];
for (Target *target in [jc runningTargets]) {
[target update: jc];
}
void input_callback(void* inContext, IOReturn inResult, void* inSender, IOHIDValueRef value) {
- JoystickController* self = (JoystickController*)inContext;
+ JoystickController* self = (__bridge JoystickController*)inContext;
IOHIDDeviceRef device = IOHIDQueueGetDevice((IOHIDQueueRef) inSender);
Joystick* js = [self findJoystickByRef: device];
}
void add_callback(void* inContext, IOReturn inResult, void* inSender, IOHIDDeviceRef device) {
- JoystickController* self = (JoystickController*)inContext;
+ JoystickController* self = (__bridge JoystickController*)inContext;
IOHIDDeviceOpen(device, kIOHIDOptionsTypeNone);
- IOHIDDeviceRegisterInputValueCallback(device, input_callback, (void*) self);
+ IOHIDDeviceRegisterInputValueCallback(device, input_callback, (void*) CFBridgingRetain(self));
Joystick *js = [[Joystick alloc] initWithDevice: device];
[js setIndex: findAvailableIndex([self joysticks], js)];
}
void remove_callback(void* inContext, IOReturn inResult, void* inSender, IOHIDDeviceRef device) {
- JoystickController* self = (JoystickController*)inContext;
+ JoystickController* self = CFBridgingRelease(inContext);
Joystick* match = [self findJoystickByRef: device];
if(!match)
create_criterion(kHIDPage_GenericDesktop, kHIDUsage_GD_GamePad),
create_criterion(kHIDPage_GenericDesktop, kHIDUsage_GD_MultiAxisController)];
- IOHIDManagerSetDeviceMatchingMultiple(hidManager, (CFArrayRef)criteria);
+ IOHIDManagerSetDeviceMatchingMultiple(hidManager, (CFArrayRef)CFBridgingRetain(criteria));
IOHIDManagerScheduleWithRunLoop( hidManager, CFRunLoopGetCurrent(), kCFRunLoopDefaultMode );
IOReturn tIOReturn = IOHIDManagerOpen( hidManager, kIOHIDOptionsTypeNone );
(void)tIOReturn;
- IOHIDManagerRegisterDeviceMatchingCallback( hidManager, add_callback, (void*)self );
- IOHIDManagerRegisterDeviceRemovalCallback(hidManager, remove_callback, (void*) self);
+ IOHIDManagerRegisterDeviceMatchingCallback( hidManager, add_callback, (__bridge void*)self );
+ IOHIDManagerRegisterDeviceRemovalCallback(hidManager, remove_callback, (__bridge void*) self);
// IOHIDManagerRegisterInputValueCallback(hidManager, input_callback, (void*)self);
// register individually so we can find the device more easily
// Setup timer for continuous targets
CFRunLoopTimerContext ctx = {
- 0, (void*)self, NULL, NULL, NULL
+ 0, (__bridge void*)self, NULL, NULL, NULL
};
CFRunLoopTimerRef timer = CFRunLoopTimerCreate(kCFAllocatorDefault,
CFAbsoluteTimeGetCurrent(), 1.0/80.0,
@property(readonly) BOOL hasKey;
@property(readwrite) int vk;
-@property(readonly) NSString* descr;
+@property(copy) NSString* descr;
@property(readwrite) BOOL enabled;
-(void) clear;
-(id) initWithIndex:(int)newIndex name: (NSString*)newName base: (JSAction*)newBase;
-@property(readwrite, assign) JSAction* base;
+@property(readwrite, strong) JSAction* base;
@property(readwrite, copy) NSString* name;
@property(readwrite) int index;
@property(readwrite) BOOL active;
Config *config;
}
-@property(readwrite, retain) Config* config;
+@property(readwrite, strong) Config* config;
+(TargetConfig*) unstringifyImpl: (NSArray*) comps withConfigList: (NSArray*) configs;
@end