-1

Is there anyway to read keyboard inputs in AppKit off the main thread? I've managed to do so using CGEventTapCreate but unfortunately it requires permissions I'd rather not have to request. Is there a way to read local inputs off the main thread?

(Use case is a keyboard driven real time audio application where graphics should never block the input->audio pipeline)

I've tried using addLocalMonitorForEventsMatchingMask but it seems the handler is only called on the main thread even if I setup a runloop in a separate thread. Thanks in advance!

1 Answer 1

0

I believe the answer is 'no' on the basis that the entryway for keyboard input — assuming you don't try to misappropriate the accessibility event tap route — is either -[NSApplication sendEvent:] or your override of the same and per Apple "sendEvent: messages are sent from the main event loop (the run method)".

It'll likely be a heavier lift but probably the appropriate solution here is to move your graphics off the main thread. Or at least break that work up into very small chunks so that you can route out from sendEvent:.

Sign up to request clarification or add additional context in comments.

1 Comment

Ah I see, thank you! Unfortunately I can't move the graphics off the main thread (using Unity) so I guess I'll just have to work around it

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.