Keystroke Receiving in Distributed macOS Panda3D Application

Dear Panda3D Community,

I am trying to compile my Panda3D application to builds on Windows, Linux and macOS. While it works for me in general, under macOS (Monterey), every time I start my application, I get a message that my application would like to receive keystrokes from any application:

This doesn’t block the app from running, but it looks lame and is just annoying. Moreover, clicking on Open System Preferences and allowing Keystroke Receiving does nothing. The next time I start my application, I have the same problem. I have the impression that this is a general problem with Panda3D, because I received identical warnings for other Panda3D applications (Asteroids, Pollen), which can even be seen in the screenshot:

I don’t really need keyboard support in my application at all. So I would be glad to get rid of this message simply by disabling keyboard support. I just don’t know how. I searched the internet, the Panda3D documentation and found nothing specific. Maybe I was looking wrong…

Will you help?

Regards,
Miklesz

We had this problem in the past but it was fixed, what version of Panda3D are you using ?
Perhaps Apple has tightened its security rules again in Monterrey and we need to look at it again.

We need to add a switch for this in Panda. I’d be willing to upload new wheels to PyPI for this.

I don’t have a mac capable of running Monterey, so it would be great if someone could check whether the warning goes away when we restrict the device usages we listen for or whether we’re not allowed to call IOHIDManagerOpen at all any more.

In the interim, one way to work around it without compiling Panda would be to have ShowBase.py not call InputDeviceManager.getGlobalPtr(). One could edit the Panda wheel manually to comment out the two lines relating to self.devices.

@eldee - I was running 1.10.10 but figured out it was just an update. I did the upgrade to 1.10.11 and… the same. But you’re right, Apple is crazy about security. On the one hand, it is good, of course, but on the other hand, it causes such annoying problems.

@rdb - I declare readiness to help with my equipment. I know Python quite well, but in Panda3D I am a beginner, but with your help I will probably get it somehow. What exactly should I check? I just want to emphasise that sometimes it only happens that my regular work overwhelms me so much that for even a week I have no chance to do anything or answer.
At the moment, however, I do not urgently need a workaround. The planned release of my application is August 2022, so I hope that it will probably be handled in a more elegant way by then.

My spare mac is also too old to run Monterey, I hope next week I can find some time to upgrade my main one and give it a try.

I could give it a try, and indeed removing kHIDUsage_GD_Keyboard and kHIDUsage_GD_Mouse from the usages list makes the permission request disappear.

Unfortunately I don’t have a macOS compatible game controller right now to validate that the permission restriction does not apply on game controller, but I should get my hands on one in a couple of days. (Also, from what I could google around, it is indeed only mouse and keyboard which are restricted).

1 Like

Thanks a lot for confirming!

For my part I can confirm that my Xbox One controller still works on my old (10.13) mac with the keyboard/mouse lines commented out.

I think I will upload a post-release with those lines disabled by default and upload macOS wheels to PyPI so that the deployment system will pick those up automatically.

I’ve uploaded new macOS wheels tagged with version v1.10.11.post1. This disables getting keyboard/mouse devices by default. It can be reenabled, if desired, using this config:

iokit-scan-mouse-devices true
iokit-scan-keyboard-devices true

@miklesz at your leisure, could you test deployment again and verify that it is solved? You don’t need to reinstall Panda3D, but you do probably need to delete the build directory to make sure it doesn’t use the cached wheel. Make sure you see “.post1” in the name of the .whl file that setup.py is downloading when it’s building the macOS binary.

2 Likes

@rdb Works (no warnings)! Thank you!

1 Like

Great! Thanks to both of you for your help in testing and getting this fixed!

2 Likes