Adding read functionnality to our HidDevice.
Fixing some state issues upon connection.
1 /*******************************
2 Mac support for HID Test GUI
6 *******************************/
9 #import <Cocoa/Cocoa.h>
11 extern FXMainWindow *g_main_window;
14 @interface MyAppDelegate : NSObject
19 @implementation MyAppDelegate
20 - (void) applicationWillBecomeActive:(NSNotification*)notif
22 printf("WillBecomeActive\n");
23 g_main_window->show();
27 - (void) applicationWillTerminate:(NSNotification*)notif
29 /* Doesn't get called. Not sure why */
30 printf("WillTerminate\n");
31 FXApp::instance()->exit();
34 - (NSApplicationTerminateReply) applicationShouldTerminate:(NSApplication*)sender
36 /* Doesn't get called. Not sure why */
37 printf("ShouldTerminate\n");
41 - (void) applicationWillHide:(NSNotification*)notif
44 g_main_window->hide();
47 - (void) handleQuitEvent:(NSAppleEventDescriptor*)event withReplyEvent:(NSAppleEventDescriptor*)replyEvent
49 printf("QuitEvent\n");
50 FXApp::instance()->exit();
58 init_apple_message_system()
60 static MyAppDelegate *d = [MyAppDelegate new];
62 [[NSApplication sharedApplication] setDelegate:d];
64 /* Register for Apple Events. */
66 http://stackoverflow.com/questions/1768497/application-exit-event */
67 NSAppleEventManager *aem = [NSAppleEventManager sharedAppleEventManager];
68 [aem setEventHandler:d
69 andSelector:@selector(handleQuitEvent:withReplyEvent:)
70 forEventClass:kCoreEventClass andEventID:kAEQuitApplication];
76 NSApplication *app = [NSApplication sharedApplication];
78 NSAutoreleasePool *pool = [NSAutoreleasePool new];
80 NSEvent* event = [NSApp nextEventMatchingMask:NSAnyEventMask
82 inMode:NSDefaultRunLoopMode
87 //printf("Event happened: Type: %d\n", event->_type);
88 [app sendEvent: event];