I have a custom view setup to receive keyDown, keyUp, and flagsChanged events. When I first launch my app and press a key on the keyboard, I consistently see a half-second stall/hiccup before my keyDown handler is invoked. Subsequent key presses trigger the handler instantly.
This is a barebones app with no other logic running, so there shouldn't be any performance bottlenecks.
I see the same hiccup (though less consistently) when my app regains focus--it can take over a second before AppKit starts pumping my keyboard events again.
I checked the backtrace when my keyDown handler is called, and I don't see anything weird:
* frame #0: 0x0000000100008ea4 Sim`-[SimMetalView keyDown:](self=0x000000010022e880, _cmd="keyDown:", event=0x000000010034e6d0) at macos_sim.m:1795:2
* frame #1: 0x00007fff2b9942ad AppKit`-[NSWindow(NSEventRouting) _reallySendEvent:isDelayedEvent:] + 6512
* frame #2: 0x00007fff2b992719 AppKit`-[NSWindow(NSEventRouting) sendEvent:] + 349
* frame #3: 0x00007fff2b99144e AppKit`-[NSApplication(NSEvent) sendEvent:] + 2826
* frame #4: 0x00007fff2b7ddbdf AppKit`-[NSApplication run] + 707
* frame #5: 0x000000010000bfc5 Sim`main(argument_count=1, argument_input=0x00007ffeefbff888) at macos_sim.m:1974:2
* frame #6: 0x00007fff682a7cc9 libdyld.dylib`start + 1
* frame #7: 0x00007fff682a7cc9 libdyld.dylib`start + 1
I tried posting an empty event in applicationDidFinishLaunching to see if that would jumpstart the event loop, but that didn't help. I also tried setting the event supression interval to 0, which also did nothing:
CGEventSourceRef input_event_source = CGEventSourceCreate( kCGEventSourceStateHIDSystemState );
CGEventSourceSetLocalEventsSuppressionInterval( input_event_source, 0 );
What could be causing this delay in receiving keyboard events? What are my options for getting instant access to keyboard events?
Thank you!
Post
Replies
Boosts
Views
Activity
I'm using an Xbox Wireless Controller Model 1708 (listed as a supported device here) on a Late 2012 iMac running Catalina 10.15.7. The controller connects to the system just fine, but I can't interface with it using the Game Controller framework.
At boot, I query the list of connected controllers and it's always empty--even if I've already connected my controller to the iMac. I can register for the controller connect/disconnect notifications, and they appear to be working. I receive a connect notification for my Xbox controller shortly after booting (not sure why there's a delay...). The problem is that the GCController object for my Xbox controller returns NIL when I query its extended gamepad profile.
How can I query button states if I can't access the extended profile?
I can access the deprecated GCGamepad profile as well as the micro gamepad profile, but neither give me access to the full controller's button state.
I've tried searching for help and I noticed an unanswered question with the same problem here.
How are you all supporting Xbox controllers in your apps? Is it unsupported in Catalina?
Cheers! :)