In the game I am working on we use the standard Cocoa way of handling events, i.e. run NSApplicationMain and implement the various callbacks in our NSWindow and NSApplication delegates. At no point do we pump the event queue ourselves. If System::Update is called every frame the system will frequently not processes key events, though if an event is processed all events which were previously skipped are also issued. If we do not call System::Update all events are handled as expected. I’m not sure what FMod could be doing to cause this behavior, but there it is.
Mac OS 10.5.2 build 9C31
iMac 1.83GHz Core Duo w/ 2GB RAM (first generation intel iMac)
FMod Ex 4.12.04
- AlexS asked 10 years ago
Currently during System::Update we make a call to process one event in the event loop. This is needed so any changes made to system defaults for audio devices are propagated to the application. We use the follow to do this.
[code:31t7xruo]CFRunLoopRunInMode(kCFRunLoopDefaultMode, 0, true);[/code:31t7xruo]
It is my understanding that this will basically pump the event queue, so any registered callbacks you have in-place in your code will get fired from here also. It seems to me like your code would need something similar to process the rest of your key events. This is just a thought, I haven’t actually worked with Cocoa before.
That would do it. CFRunLoopRunInMode is leaving the event in the Cocoa event queue but NSApplicationMain wouldn’t send it. Executing this
[code:1pt1rlpt] NSApplication* app = [NSApplication sharedApplication];
NSEvent* event = [app nextEventMatchingMask:NSAnyEventMask untilDate:nil inMode:NSDefaultRunLoopMode dequeue:YES];
every frame resolved the issue. Essentially, it grabs the most recent event on the event queue (if there is one) and dispatches it.
[quote:1pt1rlpt]It seems to me like your code would need something similar to process the rest of your key events.[/quote:1pt1rlpt]
NSApplicationMain handles pumping the event queue and dispatching events. I peeked at the assembly and noted it does a lot of stuff with the application’s CFRunLoop and never calls CFRunLoopRun, which is probably the cause of all of this.
- AlexS answered 10 years ago
Please login first to submit.