projects
/
enjoyable.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
a7260fe
)
Fix various bad names in input controller. Make devices appear as a group header.
author
Joe Wreschnig
<joe.wreschnig@gmail.com>
Sun, 10 Mar 2013 18:50:06 +0000
(19:50 +0100)
committer
Joe Wreschnig
<joe.wreschnig@gmail.com>
Sun, 10 Mar 2013 18:50:06 +0000
(19:50 +0100)
Classes/NJDeviceController.h
patch
|
blob
|
history
Classes/NJDeviceController.m
patch
|
blob
|
history
Classes/NJInput.h
patch
|
blob
|
history
Classes/NJInput.m
patch
|
blob
|
history
Classes/NJInputPathElement.h
patch
|
blob
|
history
Info.plist
patch
|
blob
|
history
diff --git
a/Classes/NJDeviceController.h
b/Classes/NJDeviceController.h
index
07695f7
..
ce05cee
100644
(file)
--- a/
Classes/NJDeviceController.h
+++ b/
Classes/NJDeviceController.h
@@
-25,8
+25,6
@@
@property (nonatomic, assign) BOOL translatingEvents;
- (void)setup;
@property (nonatomic, assign) BOOL translatingEvents;
- (void)setup;
-- (NJDevice *)findDeviceByRef:(IOHIDDeviceRef)device;
-
- (IBAction)translatingEventsChanged:(id)sender;
@end
- (IBAction)translatingEventsChanged:(id)sender;
@end
diff --git
a/Classes/NJDeviceController.m
b/Classes/NJDeviceController.m
index
db821bf
..
8417927
100644
(file)
--- a/
Classes/NJDeviceController.m
+++ b/
Classes/NJDeviceController.m
@@
-16,24
+16,24
@@
#import "NJEvents.h"
@implementation NJDeviceController {
#import "NJEvents.h"
@implementation NJDeviceController {
- IOHIDManagerRef hidManager;
- NSTimer *
continuousTimer
;
- NSMutableArray *
running
Outputs;
+ IOHIDManagerRef
_
hidManager;
+ NSTimer *
_continuousOutputsTick
;
+ NSMutableArray *
_continous
Outputs;
NSMutableArray *_devices;
}
- (id)init {
if ((self = [super init])) {
_devices = [[NSMutableArray alloc] initWithCapacity:16];
NSMutableArray *_devices;
}
- (id)init {
if ((self = [super init])) {
_devices = [[NSMutableArray alloc] initWithCapacity:16];
-
running
Outputs = [[NSMutableArray alloc] initWithCapacity:32];
+
_continous
Outputs = [[NSMutableArray alloc] initWithCapacity:32];
}
return self;
}
- (void)dealloc {
}
return self;
}
- (void)dealloc {
- [
continuousTimer
invalidate];
- IOHIDManagerClose(hidManager, kIOHIDOptionsTypeNone);
- CFRelease(hidManager);
+ [
_continuousOutputsTick
invalidate];
+ IOHIDManagerClose(
_
hidManager, kIOHIDOptionsTypeNone);
+ CFRelease(
_
hidManager);
}
- (void)expandRecursive:(id <NJInputPathElement>)pathElement {
}
- (void)expandRecursive:(id <NJInputPathElement>)pathElement {
@@
-44,13
+44,11
@@
}
- (void)addRunningOutput:(NJOutput *)output {
}
- (void)addRunningOutput:(NJOutput *)output {
- if (![runningOutputs containsObject:output]) {
- [runningOutputs addObject:output];
- }
- if (!continuousTimer) {
- continuousTimer = [NSTimer scheduledTimerWithTimeInterval:1.f/60.f
+ [_continousOutputs addObject:output];
+ if (!_continuousOutputsTick) {
+ _continuousOutputsTick = [NSTimer scheduledTimerWithTimeInterval:1.0/60.0
target:self
target:self
- selector:@selector(updateContinuous
In
puts:)
+ selector:@selector(updateContinuous
Out
puts:)
userInfo:nil
repeats:YES];
}
userInfo:nil
repeats:YES];
}
@@
-77,7
+75,8
@@
return;
[self expandRecursive:handler];
return;
[self expandRecursive:handler];
- [outlineView selectRowIndexes:[NSIndexSet indexSetWithIndex:[outlineView rowForItem:handler]] byExtendingSelection: NO];
+ [outlineView selectRowIndexes:[NSIndexSet indexSetWithIndex:[outlineView rowForItem:handler]]
+ byExtendingSelection: NO];
[outputController focusKey];
}
[outputController focusKey];
}
@@
-107,12
+106,12
@@
static int findAvailableIndex(NSArray *list, NJDevice *dev) {
}
- (void)addDeviceForDevice:(IOHIDDeviceRef)device {
}
- (void)addDeviceForDevice:(IOHIDDeviceRef)device {
- IOHIDDeviceRegisterInputValueCallback(device, input_callback, (__bridge void*)self);
+ IOHIDDeviceRegisterInputValueCallback(device, input_callback, (__bridge void
*)self);
NJDevice *dev = [[NJDevice alloc] initWithDevice:device];
dev.index = findAvailableIndex(_devices, dev);
[_devices addObject:dev];
[outlineView reloadData];
NJDevice *dev = [[NJDevice alloc] initWithDevice:device];
dev.index = findAvailableIndex(_devices, dev);
[_devices addObject:dev];
[outlineView reloadData];
-
[connectDevicePrompt setHidden:!!_devices.count]
;
+
connectDevicePrompt.hidden = !!_devices.count
;
}
static void add_callback(void *ctx, IOReturn inResult, void *inSender, IOHIDDeviceRef device) {
}
static void add_callback(void *ctx, IOReturn inResult, void *inSender, IOHIDDeviceRef device) {
@@
-138,28
+137,29
@@
static void remove_callback(void *ctx, IOReturn inResult, void *inSender, IOHIDD
if (match) {
[_devices removeObject:match];
[outlineView reloadData];
if (match) {
[_devices removeObject:match];
[outlineView reloadData];
-
[connectDevicePrompt setHidden:!!_devices.count]
;
+
connectDevicePrompt.hidden = !!_devices.count
;
}
}
-
+ if (_devices.count == 1)
+ [outlineView expandItem:_devices[0]];
}
}
-- (void)updateContinuous
In
puts:(NSTimer *)timer {
+- (void)updateContinuous
Out
puts:(NSTimer *)timer {
self.mouseLoc = [NSEvent mouseLocation];
self.mouseLoc = [NSEvent mouseLocation];
- for (NJOutput *output in [
running
Outputs copy]) {
+ for (NJOutput *output in [
_continous
Outputs copy]) {
if (![output update:self]) {
if (![output update:self]) {
- [
running
Outputs removeObject:output];
+ [
_continous
Outputs removeObject:output];
}
}
}
}
- if (!
running
Outputs.count) {
- [
continuousTimer
invalidate];
-
continuousTimer
= nil;
+ if (!
_continous
Outputs.count) {
+ [
_continuousOutputsTick
invalidate];
+
_continuousOutputsTick
= nil;
}
}
#define NSSTR(e) ((NSString *)CFSTR(e))
- (void)setup {
}
}
#define NSSTR(e) ((NSString *)CFSTR(e))
- (void)setup {
- hidManager = IOHIDManagerCreate(kCFAllocatorDefault, kIOHIDOptionsTypeNone);
+
_
hidManager = IOHIDManagerCreate(kCFAllocatorDefault, kIOHIDOptionsTypeNone);
NSArray *criteria = @[ @{ NSSTR(kIOHIDDeviceUsagePageKey) : @(kHIDPage_GenericDesktop),
NSSTR(kIOHIDDeviceUsageKey) : @(kHIDUsage_GD_Joystick) },
@{ NSSTR(kIOHIDDeviceUsagePageKey) : @(kHIDPage_GenericDesktop),
NSArray *criteria = @[ @{ NSSTR(kIOHIDDeviceUsagePageKey) : @(kHIDPage_GenericDesktop),
NSSTR(kIOHIDDeviceUsageKey) : @(kHIDUsage_GD_Joystick) },
@{ NSSTR(kIOHIDDeviceUsagePageKey) : @(kHIDPage_GenericDesktop),
@@
-167,10
+167,10
@@
static void remove_callback(void *ctx, IOReturn inResult, void *inSender, IOHIDD
@{ NSSTR(kIOHIDDeviceUsagePageKey) : @(kHIDPage_GenericDesktop),
NSSTR(kIOHIDDeviceUsageKey) : @(kHIDUsage_GD_MultiAxisController) }
];
@{ NSSTR(kIOHIDDeviceUsagePageKey) : @(kHIDPage_GenericDesktop),
NSSTR(kIOHIDDeviceUsageKey) : @(kHIDUsage_GD_MultiAxisController) }
];
- IOHIDManagerSetDeviceMatchingMultiple(hidManager, (__bridge CFArrayRef)criteria);
+ IOHIDManagerSetDeviceMatchingMultiple(
_
hidManager, (__bridge CFArrayRef)criteria);
- IOHIDManagerScheduleWithRunLoop(hidManager, CFRunLoopGetCurrent(), kCFRunLoopDefaultMode);
- IOReturn ret = IOHIDManagerOpen(hidManager, kIOHIDOptionsTypeNone);
+ IOHIDManagerScheduleWithRunLoop(
_
hidManager, CFRunLoopGetCurrent(), kCFRunLoopDefaultMode);
+ IOReturn ret = IOHIDManagerOpen(
_
hidManager, kIOHIDOptionsTypeNone);
if (ret != kIOReturnSuccess) {
[[NSAlert alertWithMessageText:@"Input devices are unavailable"
defaultButton:nil
if (ret != kIOReturnSuccess) {
[[NSAlert alertWithMessageText:@"Input devices are unavailable"
defaultButton:nil
@@
-185,8
+185,8
@@
static void remove_callback(void *ctx, IOReturn inResult, void *inSender, IOHIDD
contextInfo:nil];
}
contextInfo:nil];
}
- IOHIDManagerRegisterDeviceMatchingCallback(hidManager, add_callback, (__bridge void *)self);
- IOHIDManagerRegisterDeviceRemovalCallback(hidManager, remove_callback, (__bridge void *)self);
+ IOHIDManagerRegisterDeviceMatchingCallback(
_
hidManager, add_callback, (__bridge void *)self);
+ IOHIDManagerRegisterDeviceRemovalCallback(
_
hidManager, remove_callback, (__bridge void *)self);
}
- (NJInput *)selectedInput {
}
- (NJInput *)selectedInput {
@@
-217,10
+217,19
@@
objectValueForTableColumn:(NSTableColumn *)tableColumn
}
- (void)outlineViewSelectionDidChange:(NSNotification *)notification {
}
- (void)outlineViewSelectionDidChange:(NSNotification *)notification {
-
[outputController loadCurrent];
}
[outputController loadCurrent];
}
+- (BOOL)outlineView:(NSOutlineView *)outlineView
+ isGroupItem:(id <NJInputPathElement>)item {
+ return [item isKindOfClass:NJDevice.class];
+}
+
+- (BOOL)outlineView:(NSOutlineView *)outlineView_
+ shouldSelectItem:(id <NJInputPathElement>)item {
+ return ![self outlineView:outlineView_ isGroupItem:item];
+}
+
- (void)setTranslatingEvents:(BOOL)translatingEvents {
if (translatingEvents != _translatingEvents) {
_translatingEvents = translatingEvents;
- (void)setTranslatingEvents:(BOOL)translatingEvents {
if (translatingEvents != _translatingEvents) {
_translatingEvents = translatingEvents;
diff --git
a/Classes/NJInput.h
b/Classes/NJInput.h
index
380e858
..
d63be1b
100644
(file)
--- a/
Classes/NJInput.h
+++ b/
Classes/NJInput.h
@@
-12,7
+12,7
@@
@property (nonatomic, assign) IOHIDElementCookie cookie;
@property (nonatomic, copy) NSArray *children;
@property (nonatomic, assign) IOHIDElementCookie cookie;
@property (nonatomic, copy) NSArray *children;
-@property (nonatomic, weak) id base;
+@property (nonatomic, weak) id
<NJInputPathElement>
base;
@property (nonatomic, copy) NSString *name;
@property (nonatomic, assign) BOOL active;
@property (nonatomic, assign) float magnitude;
@property (nonatomic, copy) NSString *name;
@property (nonatomic, assign) BOOL active;
@property (nonatomic, assign) float magnitude;
diff --git
a/Classes/NJInput.m
b/Classes/NJInput.m
index
077dac8
..
a279322
100644
(file)
--- a/
Classes/NJInput.m
+++ b/
Classes/NJInput.m
@@
-18,11
+18,11
@@
}
- (id)findSubInputForValue:(IOHIDValueRef)value {
}
- (id)findSubInputForValue:(IOHIDValueRef)value {
- return
NULL
;
+ return
nil
;
}
- (NSString *)uid {
}
- (NSString *)uid {
- return [NSString stringWithFormat:@"%@~%@",
[_base uid]
, _name];
+ return [NSString stringWithFormat:@"%@~%@",
_base.uid
, _name];
}
- (void)notifyEvent:(IOHIDValueRef)value {
}
- (void)notifyEvent:(IOHIDValueRef)value {
diff --git
a/Classes/NJInputPathElement.h
b/Classes/NJInputPathElement.h
index
8fe5c65
..
8750038
100644
(file)
--- a/
Classes/NJInputPathElement.h
+++ b/
Classes/NJInputPathElement.h
@@
-5,5
+5,6
@@
- (NSArray *)children;
- (id <NJInputPathElement>) base;
- (NSString *)name;
- (NSArray *)children;
- (id <NJInputPathElement>) base;
- (NSString *)name;
+- (NSString *)uid;
@end
@end
diff --git
a/Info.plist
b/Info.plist
index
2b4ff49
..
e875f02
100644
(file)
--- a/
Info.plist
+++ b/
Info.plist
@@
-46,7
+46,7
@@
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
- <string>9
0
</string>
+ <string>9
7
</string>
<key>LSApplicationCategoryType</key>
<string>public.app-category.utilities</string>
<key>NSHumanReadableCopyright</key>
<key>LSApplicationCategoryType</key>
<string>public.app-category.utilities</string>
<key>NSHumanReadableCopyright</key>