Open TobyLobster opened 2 years ago
For now, this is unfortunately working as planned.
The Mac left shift key maps to the beeb's Caps Lock key. This is because modern macOS does not seem to treat caps lock like other keys and I've been unable to get it working correctly. So given that the beeb Caps Lock is so important for games, I used the Mac left shift for now.
Yes. I looked into the problem a little but didn't find an ideal solution: I see "flagsChanged:" doesn't fire on a key up for Caps Lock, only on key down. A solution using IOHIDDevice should work but will give the user an off-putting warning message on a first run. B2 had this issue too https://github.com/tom-seddon/b2/issues/167 and went with the IOHIDDevice solution anyway.
One simpler possibility would be to move the Beeb '@' key from the Mac's "`\~" to the "±§" key, then put the Beeb's CAPS LOCK onto "`\~" on the Mac.
I looked at the IOHIDDevice solution and unfortunately I think it got locked down in more modern macOS, such that the user has to authorize the app to use that API. I wanted to steer away from any password dialogs popping up.
Where is the "±§" key? I'm not sure my MacBook Air has one. It seems to have a general lack of keys, which is a real headache :)
I don't believe it's a password dialog, but is a "request permission" dialog which is worded scarily for an unsuspecting user.
On further investigation the "±§" key appears to be on UK keyboards but not US keyboards. So that's not a great solution either.
Did the IOHIDDevice ever work for you? I noticed that because b2 isn't notarized, every b2 build is considered different, meaning b2 needs to be manually removed from the control panel after every build: https://github.com/tom-seddon/b2/issues/197 (can't remember which macOS that was with? Probably Big Sur)
People downloading it have an easier time and need only do this after upgrading.
I had some warnings when running the CI builds of the BeebLink server, also not notarized, "fixed" with some xattr
stuff that strips off the quarantine flag: https://github.com/tom-seddon/beeblink#macos - haven't experimented to see whether this could make a difference too.
--Tom
I confess I didn't try IOHIDDevice myself. I read about it, didn't like the sounds of it, and failed to try it.
For completeness, I notice that CGEventTapCreate is another possible way to detect Caps Lock. But it only works if you are a root user or have an accessibility setting enabled. So that doesn't seem like a great solution either. See the discussion section of https://developer.apple.com/documentation/coregraphics/1454426-cgeventtapcreate
For further completeness, here is the dialog that appears on first run with the IOHIDDevice solution:
Running the tagged version v0.9.7, I notice that the left SHIFT key on the Mac doesn't act as shift. The right SHIFT key does work, but not the left.
I realise you know about this already, but it does seem like a bug nonetheless! Is it possible to map BBC caps lock to a different Mac key somewhere out of the way - I tend not to use it that much, unless playing Zalaga :-) I use left SHIFT all the time in comparison.