Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: Has anyone had any issues with SFML keyboard input on MacOS Catalina? [Solved]  (Read 3876 times)

0 Members and 1 Guest are viewing this topic.

ashley

  • Newbie
  • *
  • Posts: 6
    • View Profile
This is _kinda_ bridging into help request territory, but I'm not expecting any help since it's very specific and I imagine this is a weird issue on my system, so just asking the question to see if anyone's already ran into this. Hope that's cool!

I'd also appreciate anyone who has successfully been using SFML on Catalina without running into this issue letting me know so that I know if it's just me!

I'm running macOS Catalina, and SFML is failing to identify any keys on my keyboards. Specifically, I get an error from line 188 of https://github.com/SFML/SFML/blob/master/src/SFML/Window/OSX/HIDInputManager.mm: "We got a keyboard without any keys (1)".

This happens for any keyboard I plug into my system, and it definitely is searching on my keyboard devices since if I plug in two it prints it twice, one it prints it once, and zero it prints it zero times.

I am running a Hackintosh, which always may be the source of the problem, however I've never once experienced a keyboard problem with anything else, so I wonder if somehow there's an issue with SFML? Although it seems to be using a fairly standard AppKit library...

FWIW, I'm using SFML.NET Core 1.0, which in turn, I believe, uses SFML 2.5. I'm not doing anything crazy (just doing normal Keyboard.IsKeyDown calls) & this same code works flawlessly on Windows, Ubuntu and Mojave installs. In addition, my mouse works correctly, and the rest of my game logic works perfectly - just it doesn't observe any keyboard input.
« Last Edit: September 19, 2019, 11:46:15 pm by ashley »

ashley

  • Newbie
  • *
  • Posts: 6
    • View Profile
Re: Has anyone had any issues with SFML keyboard input on MacOS Catalina?
« Reply #1 on: September 19, 2019, 11:44:33 pm »
Aha, this is interesting. I kept searching and came across a totally irrelevant question where someone was having trouble setting the mouse cursor position and had to enable their game access to accessibility.

I thought, screw it, and had a look. It turns out my IDE (Rider) had asked for "Input Monitoring" permissions. I think this is new in Catalina, although apps should be able to monitor keyboard input while you are already within them...

In any case, enabling this (i.e. allowing reading keyboard input while another application is focused) setting on my IDE (not the game! perhaps it inherits it, since it's a sub-process, but I had also tried launching it from the terminal with dotnet to the same effect...) fixed it! I am totally perplexed why, but it works, so I'm happy.

I feel a bit embarrassed having solved this immediately after posting -- I've been struggling with this issue for a few days and was just about to start drafting up a minimal reproducible Objective-C example of this failing to report to an Apple help forum, but I'll leave this up incase anyone else in a similar position comes across this. I imagine there is probably very few people with a similar configuration (macOS, Rider, SFML.NET Core), but hopefully it helps someone :)

unlight

  • Newbie
  • *
  • Posts: 33
    • View Profile
    • Email
Thank you for posting on this, I was having the same issue using VsCode. I added the SFML "dylibs" to the input monitoring whitelist but wasn't having any luck. I didn't think it would be VsCode itself that needed to be whitelisted.