From d4ffd217288cfc0d2798b3df67ab20bc867a7f7e Mon Sep 17 00:00:00 2001 From: Dominik Pich Date: Sun, 17 Mar 2013 13:33:20 +0100 Subject: DDHIDLib 1.1.1 --- browser/English.lproj/EventWatcher.nib/classes.nib | 13 + browser/English.lproj/EventWatcher.nib/info.nib | 16 ++ .../EventWatcher.nib/keyedobjects.nib | Bin 0 -> 9260 bytes browser/English.lproj/InfoPlist.strings | Bin 0 -> 190 bytes browser/English.lproj/MainMenu.nib/classes.nib | 19 ++ browser/English.lproj/MainMenu.nib/info.nib | 22 ++ .../English.lproj/MainMenu.nib/keyedobjects.nib | Bin 0 -> 31311 bytes browser/HIDBrowser_Prefix.pch | 7 + browser/HexFormatter.h | 34 +++ browser/HexFormatter.m | 49 ++++ browser/HidBrowserController.h | 42 ++++ browser/HidBrowserController.m | 144 +++++++++++ browser/Info.plist | 30 +++ browser/WatcherWindowController.h | 57 +++++ browser/WatcherWindowController.m | 269 +++++++++++++++++++++ browser/main.m | 30 +++ 16 files changed, 732 insertions(+) create mode 100644 browser/English.lproj/EventWatcher.nib/classes.nib create mode 100644 browser/English.lproj/EventWatcher.nib/info.nib create mode 100644 browser/English.lproj/EventWatcher.nib/keyedobjects.nib create mode 100644 browser/English.lproj/InfoPlist.strings create mode 100644 browser/English.lproj/MainMenu.nib/classes.nib create mode 100644 browser/English.lproj/MainMenu.nib/info.nib create mode 100644 browser/English.lproj/MainMenu.nib/keyedobjects.nib create mode 100644 browser/HIDBrowser_Prefix.pch create mode 100644 browser/HexFormatter.h create mode 100644 browser/HexFormatter.m create mode 100644 browser/HidBrowserController.h create mode 100644 browser/HidBrowserController.m create mode 100644 browser/Info.plist create mode 100644 browser/WatcherWindowController.h create mode 100644 browser/WatcherWindowController.m create mode 100644 browser/main.m (limited to 'browser') diff --git a/browser/English.lproj/EventWatcher.nib/classes.nib b/browser/English.lproj/EventWatcher.nib/classes.nib new file mode 100644 index 0000000..8f04df5 --- /dev/null +++ b/browser/English.lproj/EventWatcher.nib/classes.nib @@ -0,0 +1,13 @@ +{ + IBClasses = ( + {CLASS = FirstResponder; LANGUAGE = ObjC; SUPERCLASS = NSObject; }, + { + ACTIONS = {clearHistory = id; }; + CLASS = WatcherWindowController; + LANGUAGE = ObjC; + OUTLETS = {mEventHistoryController = NSArrayController; }; + SUPERCLASS = NSWindowController; + } + ); + IBVersion = 1; +} \ No newline at end of file diff --git a/browser/English.lproj/EventWatcher.nib/info.nib b/browser/English.lproj/EventWatcher.nib/info.nib new file mode 100644 index 0000000..1c52771 --- /dev/null +++ b/browser/English.lproj/EventWatcher.nib/info.nib @@ -0,0 +1,16 @@ + + + + + IBDocumentLocation + 69 14 356 240 0 0 1440 878 + IBFramework Version + 446.1 + IBOpenObjects + + 5 + + IBSystem Version + 8N1037 + + diff --git a/browser/English.lproj/EventWatcher.nib/keyedobjects.nib b/browser/English.lproj/EventWatcher.nib/keyedobjects.nib new file mode 100644 index 0000000..61ebe6c Binary files /dev/null and b/browser/English.lproj/EventWatcher.nib/keyedobjects.nib differ diff --git a/browser/English.lproj/InfoPlist.strings b/browser/English.lproj/InfoPlist.strings new file mode 100644 index 0000000..30cfd96 Binary files /dev/null and b/browser/English.lproj/InfoPlist.strings differ diff --git a/browser/English.lproj/MainMenu.nib/classes.nib b/browser/English.lproj/MainMenu.nib/classes.nib new file mode 100644 index 0000000..910a1c9 --- /dev/null +++ b/browser/English.lproj/MainMenu.nib/classes.nib @@ -0,0 +1,19 @@ +{ + IBClasses = ( + {CLASS = DDHidElement; LANGUAGE = ObjC; SUPERCLASS = NSObject; }, + {CLASS = FirstResponder; LANGUAGE = ObjC; SUPERCLASS = NSObject; }, + {CLASS = HexFormatter; LANGUAGE = ObjC; SUPERCLASS = NSFormatter; }, + { + ACTIONS = {exportPlist = id; watchSelected = id; }; + CLASS = HidBrowserController; + LANGUAGE = ObjC; + OUTLETS = { + mDevicesController = NSArrayController; + mElementsController = NSTreeController; + mWindow = NSWindow; + }; + SUPERCLASS = NSObject; + } + ); + IBVersion = 1; +} \ No newline at end of file diff --git a/browser/English.lproj/MainMenu.nib/info.nib b/browser/English.lproj/MainMenu.nib/info.nib new file mode 100644 index 0000000..d20a5cf --- /dev/null +++ b/browser/English.lproj/MainMenu.nib/info.nib @@ -0,0 +1,22 @@ + + + + + IBDocumentLocation + 110 86 356 240 0 0 1440 878 + IBEditorPositions + + 29 + 95 721 310 44 0 0 1440 878 + + IBFramework Version + 446.1 + IBOpenObjects + + 21 + 29 + + IBSystem Version + 8N1037 + + diff --git a/browser/English.lproj/MainMenu.nib/keyedobjects.nib b/browser/English.lproj/MainMenu.nib/keyedobjects.nib new file mode 100644 index 0000000..904f45d Binary files /dev/null and b/browser/English.lproj/MainMenu.nib/keyedobjects.nib differ diff --git a/browser/HIDBrowser_Prefix.pch b/browser/HIDBrowser_Prefix.pch new file mode 100644 index 0000000..5d5ed48 --- /dev/null +++ b/browser/HIDBrowser_Prefix.pch @@ -0,0 +1,7 @@ +// +// Prefix header for all source files of the 'HIDBrowser' target in the 'HIDBrowser' project +// + +#ifdef __OBJC__ + #import +#endif diff --git a/browser/HexFormatter.h b/browser/HexFormatter.h new file mode 100644 index 0000000..e3b28c2 --- /dev/null +++ b/browser/HexFormatter.h @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2007 Dave Dribin + * + * Permission is hereby granted, free of charge, to any person + * obtaining a copy of this software and associated documentation + * files (the "Software"), to deal in the Software without + * restriction, including without limitation the rights to use, copy, + * modify, merge, publish, distribute, sublicense, and/or sell copies + * of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be + * included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS + * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN + * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +#import + + +@interface HexFormatter : NSFormatter { + +} + ++ (NSString*)format:(long)number; + +@end diff --git a/browser/HexFormatter.m b/browser/HexFormatter.m new file mode 100644 index 0000000..5ac3f6f --- /dev/null +++ b/browser/HexFormatter.m @@ -0,0 +1,49 @@ +/* + * Copyright (c) 2007 Dave Dribin + * + * Permission is hereby granted, free of charge, to any person + * obtaining a copy of this software and associated documentation + * files (the "Software"), to deal in the Software without + * restriction, including without limitation the rights to use, copy, + * modify, merge, publish, distribute, sublicense, and/or sell copies + * of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be + * included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS + * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN + * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +#import "HexFormatter.h" + + +@implementation HexFormatter + ++ (NSString*)format:(long)number; +{ + return [NSString stringWithFormat: @"0x%02X", number]; +} + + +- (NSString *)stringForObjectValue:(id)anObject { + return [HexFormatter format:[anObject longValue]]; +} + +- (BOOL)getObjectValue:(id *)anObject forString:(NSString *)string errorDescription:(NSString **)error { + return NO; +} + +- (NSAttributedString *)attributedStringForObjectValue:(id)anObject withDefaultAttributes:(NSDictionary *)attributes { + return [[[NSAttributedString alloc] initWithString:[self stringForObjectValue:anObject]] autorelease]; +} + + +@end diff --git a/browser/HidBrowserController.h b/browser/HidBrowserController.h new file mode 100644 index 0000000..3e7e116 --- /dev/null +++ b/browser/HidBrowserController.h @@ -0,0 +1,42 @@ +/* + * Copyright (c) 2007 Dave Dribin + * + * Permission is hereby granted, free of charge, to any person + * obtaining a copy of this software and associated documentation + * files (the "Software"), to deal in the Software without + * restriction, including without limitation the rights to use, copy, + * modify, merge, publish, distribute, sublicense, and/or sell copies + * of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be + * included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS + * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN + * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +#import + + +@interface HidBrowserController : NSObject +{ + IBOutlet NSWindow * mWindow; + IBOutlet NSArrayController * mDevicesController; + IBOutlet NSTreeController * mElementsController; + NSArray * mDevices; +} + +- (NSArray *) devices; + +- (IBAction) watchSelected: (id) sender; + +- (IBAction) exportPlist: (id) sender; + +@end diff --git a/browser/HidBrowserController.m b/browser/HidBrowserController.m new file mode 100644 index 0000000..4b12267 --- /dev/null +++ b/browser/HidBrowserController.m @@ -0,0 +1,144 @@ +/* + * Copyright (c) 2007 Dave Dribin + * + * Permission is hereby granted, free of charge, to any person + * obtaining a copy of this software and associated documentation + * files (the "Software"), to deal in the Software without + * restriction, including without limitation the rights to use, copy, + * modify, merge, publish, distribute, sublicense, and/or sell copies + * of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be + * included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS + * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN + * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +#import "HidBrowserController.h" +#import "DDHidUsageTables.h" +#import "DDHidDevice.h" +#import "DDHidElement.h" +#import "WatcherWindowController.h" + +@implementation HidBrowserController + +static BOOL sSleepAtExit = NO; + +static void exit_sleeper() +{ + while (sSleepAtExit) sleep(60); +} + +- (void) awakeFromNib +{ + sSleepAtExit = [[NSUserDefaults standardUserDefaults] boolForKey: @"SleepAtExit"]; + atexit(exit_sleeper); + + [self willChangeValueForKey: @"devices"]; + mDevices = [[DDHidDevice allDevices] retain]; + [self didChangeValueForKey: @"devices"]; + + [mWindow center]; + [mWindow makeKeyAndOrderFront: self]; +} + +//=========================================================== +// dealloc +//=========================================================== +- (void) dealloc +{ + [mDevices release]; + + mDevices = nil; + [super dealloc]; +} + +//=========================================================== +// - devices +//=========================================================== +- (NSArray *) devices +{ + return mDevices; +} + +- (DDHidDevice *) selectedDevice; +{ + NSArray * selectedDevices = [mDevicesController selectedObjects]; + if ([selectedDevices count] > 0) + return [selectedDevices objectAtIndex: 0]; + else + return nil; +} + +- (IBAction) watchSelected: (id) sender; +{ + NSArray * selectedElements = [mElementsController selectedObjects]; + if ([selectedElements count] == 0) + return; + + WatcherWindowController * controller = + [[WatcherWindowController alloc] init]; + [controller setDevice: [self selectedDevice]]; + [controller setElements: selectedElements]; + [controller showWindow: self]; +} + +- (IBAction) exportPlist: (id) sender; +{ + DDHidDevice * selectedDevice = [self selectedDevice]; + if (selectedDevice == nil) + return; + + NSSavePanel * panel = [NSSavePanel savePanel]; + + /* set up new attributes */ + [panel setRequiredFileType: @"plist"]; + [panel setAllowsOtherFileTypes: NO]; + [panel setCanSelectHiddenExtension: YES]; + + /* display the NSSavePanel */ + [panel beginSheetForDirectory: NSHomeDirectory() + file: @"" + modalForWindow: [NSApp mainWindow] + modalDelegate: self + didEndSelector: @selector(exportPlistPanelDidEnd:returnCode:contextInfo:) + contextInfo: selectedDevice]; +} + +- (void) exportPlistPanelDidEnd: (NSSavePanel *) panel + returnCode: (int) returnCode + contextInfo: (void *) contextInfo; +{ + DDHidDevice * selectedDevice = contextInfo; + + /* if successful, save file under designated name */ + if (returnCode != NSOKButton) + return; + + NSDictionary * deviceProperties = [selectedDevice properties]; + if (![deviceProperties writeToFile: [panel filename] atomically: YES]) + NSBeep(); +} + +- (BOOL)applicationShouldTerminateAfterLastWindowClosed:(NSApplication *)theApplication +{ + return YES; +} + +- (void)applicationWillTerminate:(NSNotification *)aNotification +{ + [self willChangeValueForKey: @"devices"]; + [mDevices release]; + mDevices = nil; + [self didChangeValueForKey: @"devices"]; +} + +@end diff --git a/browser/Info.plist b/browser/Info.plist new file mode 100644 index 0000000..feff01c --- /dev/null +++ b/browser/Info.plist @@ -0,0 +1,30 @@ + + + + + CFBundleDevelopmentRegion + English + CFBundleExecutable + ${EXECUTABLE_NAME} + CFBundleIconFile + + CFBundleIdentifier + org.dribin.dave.ddhidlib.HIDBrowser + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + ${PRODUCT_NAME} + CFBundlePackageType + APPL + CFBundleSignature + ???? + CFBundleVersion + ${CURRENT_PROJECT_VERSION} + CFBundleShortVersionString + ${CURRENT_MARKETING_VERSION} + NSMainNibFile + MainMenu + NSPrincipalClass + NSApplication + + diff --git a/browser/WatcherWindowController.h b/browser/WatcherWindowController.h new file mode 100644 index 0000000..5cc447a --- /dev/null +++ b/browser/WatcherWindowController.h @@ -0,0 +1,57 @@ +/* + * Copyright (c) 2007 Dave Dribin + * + * Permission is hereby granted, free of charge, to any person + * obtaining a copy of this software and associated documentation + * files (the "Software"), to deal in the Software without + * restriction, including without limitation the rights to use, copy, + * modify, merge, publish, distribute, sublicense, and/or sell copies + * of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be + * included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS + * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN + * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +#import +#import "DDHidDevice.h" +#import "DDHidElement.h" + +@class DDHidQueue; + +@interface WatcherWindowController : NSWindowController +{ + IBOutlet NSArrayController * mEventHistoryController; + DDHidDevice * mDevice; + NSArray * mElements; + DDHidQueue * mQueue; + NSMutableArray * mEventHistory; + int mNextIndex; +} + +- (DDHidDevice *) device; +- (void) setDevice: (DDHidDevice *) newDevice; + +- (NSArray *) elements; +- (void) setElements: (NSArray *) newElements; + +- (NSMutableArray *) eventHistory; +- (void) setEventHistory: (NSMutableArray *) anEventHistory; +- (void) addToEventHistory: (id)mEventHistoryObject; +- (void) removeFromEventHistory: (id)mEventHistoryObject; + +- (BOOL) isWatching; +- (void) setWatching: (BOOL) watching; + +- (IBAction) clearHistory: (id) sender; + +@end diff --git a/browser/WatcherWindowController.m b/browser/WatcherWindowController.m new file mode 100644 index 0000000..a13c986 --- /dev/null +++ b/browser/WatcherWindowController.m @@ -0,0 +1,269 @@ +/* + * Copyright (c) 2007 Dave Dribin + * + * Permission is hereby granted, free of charge, to any person + * obtaining a copy of this software and associated documentation + * files (the "Software"), to deal in the Software without + * restriction, including without limitation the rights to use, copy, + * modify, merge, publish, distribute, sublicense, and/or sell copies + * of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be + * included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS + * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN + * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +#import "WatcherWindowController.h" +#import "DDHidQueue.h" +#import "DDHidEvent.h" +#import "DDHidUsage.h" + +@interface WatcherEvent : NSObject +{ + NSString * mUsageDescription; + DDHidEvent * mEvent; + int mIndex; +} + +- (id) initWithUsageDescription: (NSString *) anUsageDecription + event: (DDHidEvent *) anEvent + index: (int) index; + +- (NSString *) usageDescription; +- (DDHidEvent *) event; +- (int) index; + +@end + +@implementation WatcherEvent : NSObject + +- (id) initWithUsageDescription: (NSString *) anUsageDescription + event: (DDHidEvent *) anEvent + index: (int) index +{ + if (self = [super init]) + { + mUsageDescription = [anUsageDescription retain]; + mEvent = [anEvent retain]; + mIndex = index; + } + return self; +} + +//=========================================================== +// dealloc +//=========================================================== +- (void) dealloc +{ + [mUsageDescription release]; + [mEvent release]; + + mUsageDescription = nil; + mEvent = nil; + [super dealloc]; +} + +//=========================================================== +// - usageDescription +//=========================================================== +- (NSString *) usageDescription +{ + return mUsageDescription; +} + +//=========================================================== +// - event +//=========================================================== +- (DDHidEvent *) event +{ + return mEvent; +} + +//=========================================================== +// - index +//=========================================================== +- (int) index +{ + return mIndex; +} + +@end + +@implementation WatcherWindowController + +- (id) init +{ + self = [super initWithWindowNibName: @"EventWatcher" owner: self]; + if (self == nil) + return nil; + + mEventHistory = [[NSMutableArray alloc] init]; + mNextIndex = 1; + + return self; +} + + +//=========================================================== +// dealloc +//=========================================================== +- (void) dealloc +{ + [mQueue release]; + [mDevice release]; + [mElements release]; + [mEventHistory release]; + + mQueue = nil; + mDevice = nil; + mElements = nil; + mEventHistory = nil; + [super dealloc]; +} + +- (void)windowWillClose:(NSNotification *)notification +{ + [mQueue release]; + mQueue = nil; + [mDevice close]; + [self autorelease]; +} + +- (IBAction)showWindow:(id)sender +{ + [super showWindow: sender]; +} + +- (void) ddhidQueueHasEvents: (DDHidQueue *) hidQueue; +{ + WatcherEvent * watcherEvent; + watcherEvent = + [[WatcherEvent alloc] initWithUsageDescription: @"-----------------------------" + event: nil + index: mNextIndex++]; + [watcherEvent autorelease]; + [mEventHistoryController addObject: watcherEvent]; + + NSMutableArray * newEvents = [NSMutableArray array]; + DDHidEvent * event; + while (event = [hidQueue nextEvent]) + { + DDHidElement * element = [mDevice elementForCookie: [event elementCookie]]; + watcherEvent = + [[WatcherEvent alloc] initWithUsageDescription: [[element usage] usageNameWithIds] + event: event + index: mNextIndex++]; + [watcherEvent autorelease]; + [newEvents addObject: watcherEvent]; + } + + [mEventHistoryController addObjects: newEvents]; +} + +- (void) windowDidLoad; +{ + [mDevice open]; + mQueue = [[mDevice createQueueWithSize: 30] retain]; + [mQueue setDelegate: self]; + [mQueue addElements: mElements]; + [self willChangeValueForKey: @"watching"]; + [mQueue startOnCurrentRunLoop]; + [self didChangeValueForKey: @"watching"]; +} + +//=========================================================== +// device +//=========================================================== +- (DDHidDevice *) device +{ + return [[mDevice retain] autorelease]; +} + +- (void) setDevice: (DDHidDevice *) newDevice +{ + if (mDevice != newDevice) + { + [mDevice release]; + mDevice = [newDevice retain]; + } +} + +//=========================================================== +// elements +//=========================================================== +- (NSArray *) elements +{ + return [[mElements retain] autorelease]; +} + +- (void) setElements: (NSArray *) newElements +{ + if (mElements != newElements) + { + [mElements release]; + mElements = [newElements retain]; + } +} + +//=========================================================== +// eventHistory +//=========================================================== +- (NSMutableArray *) eventHistory +{ + return mEventHistory; +} + +- (void) setEventHistory: (NSMutableArray *) anEventHistory +{ + if (mEventHistory != anEventHistory) + { + [mEventHistory release]; + mEventHistory = [anEventHistory retain]; + } +} +- (void) addToEventHistory: (id)mEventHistoryObject +{ + [[self eventHistory] addObject: mEventHistoryObject]; +} +- (void) removeFromEventHistory: (id)mEventHistoryObject +{ + [[self eventHistory] removeObject: mEventHistoryObject]; +} + +- (BOOL) isWatching; +{ + if (mQueue == nil) + return NO; + return [mQueue isStarted]; +} + +- (void) setWatching: (BOOL) watching; +{ + BOOL isStarted = [mQueue isStarted]; + if (isStarted == watching) + return; + + if (watching) + [mQueue startOnCurrentRunLoop]; + else + [mQueue stop]; +} + +- (IBAction) clearHistory: (id) sender; +{ + [self willChangeValueForKey: @"eventHistory"]; + [mEventHistory removeAllObjects]; + mNextIndex = 1; + [self didChangeValueForKey: @"eventHistory"]; +} + +@end diff --git a/browser/main.m b/browser/main.m new file mode 100644 index 0000000..f05b99f --- /dev/null +++ b/browser/main.m @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2007 Dave Dribin + * + * Permission is hereby granted, free of charge, to any person + * obtaining a copy of this software and associated documentation + * files (the "Software"), to deal in the Software without + * restriction, including without limitation the rights to use, copy, + * modify, merge, publish, distribute, sublicense, and/or sell copies + * of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be + * included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS + * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN + * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +#import + +int main(int argc, char *argv[]) +{ + return NSApplicationMain(argc, (const char **) argv); +} -- cgit v1.2.3