macOS Catalina: Keyboard monitoring permission

I just ran one of my existing apps under Catalina for the first time. I got a message box from the system telling me my app wants to read the keyboard from any application and do I want to grant permission. At the same time messages appeared in the Xcode console saying TCC deny IOHIDDeviceOpen.

Naturally I gave permission but the language around all this seems to be saying that the app wants to monitor the keyboard so it can see anything typed regardless of whether it has focus. Is this the default setup for keyboard handling in SDL? Shouldn’t the app only get input when it has focus? How to I make it do that? I would hate users to be hit with this dialog.

I ran a second app. This time there was no message box, the app ran and was able to receive keyboard input. However the same “deny” messages appeared in the Xcode console.

Which SDL2 version are you using? I believe this was fixed in a recent release.

Ahh! Thanks. My version is several months old. I’ll update to the latest.

Yeah, we were hooking the keyboard on macOS so we could get correct information about Caps Lock.

Now we don’t get correct information for Caps Lock anymore, but at least Catalina doesn’t tell people we might be sniffing for passwords! :slight_smile:

I just tried tip. It does indeed fix the problem and I have removed the special permission I previously set.

could this be done for the SDL 1.2x branch as well? Pretty please?

I’ve just realized that the updated libSDL I took to fix this problem has broken MULTIGESTURE and FINGERUP events on macOS. My app is no longer receiving these. Is there something I need to do differently in the app to enable these events now on macOS? They are still working fine on iOS.

I tried to build the gesture test to see if that works but I can’t build it:

Undefined symbols for architecture x86_64:
  "_SDLTest_CommonCreateState", referenced from:
      _main in testgesture.o
  "_SDLTest_CommonDefaultArgs", referenced from:
      _main in testgesture.o
  "_SDLTest_CommonEvent", referenced from:
      _loop in testgesture.o
  "_SDLTest_CommonInit", referenced from:
      _main in testgesture.o
  "_SDLTest_CommonQuit", referenced from:
      _main in testgesture.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

Got testgesture to build. I had to add libSDL_test.a to the libraries list. Don’t know why it wasn’t there already.

Anyway testgesture doesn’t work either. It is not receiving events. No messages are output when I compile with VERBOSE 1. I will try the current tip.

Doesn’t work on current tip, changeset 13845, either.

1 Like