Skip to content

Commit

Permalink
Add some extra macOS Caps Lock stuff.
Browse files Browse the repository at this point in the history
Add specific messaging on startup when IOHidManagerOpen returns the
value that implies b2 hasn't been granted keyboard input monitoring
privileges. Include link to docs on github.

Add note to docs about running from dmg directly possibly producing odd
behaviour.

Fix #345.
  • Loading branch information
tom-seddon committed Jul 10, 2024
1 parent 7035f9e commit 844adac
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
3 changes: 2 additions & 1 deletion doc/Installing-on-OSX.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ You don't need to download any of the other files; the dmg contains
everything required.

Open the dmg, drag b2 to your Applications folder, and run it from
there.
there. (Running it from the dmg directly is unsupported, and it may
not work. I've had reports of odd behaviour when attempting it!)

## macOS files missing from releases page?

Expand Down
10 changes: 8 additions & 2 deletions src/b2/b2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -539,13 +539,19 @@ static void InitHIDCallback(Messages *msg) {
goto cleanup;
}
}

IOHIDManagerSetDeviceMatchingMultiple(g_hid_manager, matches);
IOHIDManagerRegisterInputValueCallback(g_hid_manager, &HIDCallback, g_hid_manager);
IOHIDManagerScheduleWithRunLoop(g_hid_manager, CFRunLoopGetMain(), kCFRunLoopDefaultMode);
ior = IOHIDManagerOpen(g_hid_manager, kIOHIDOptionsTypeNone);
if (ior != kIOReturnSuccess) {
msg->i.f("InitHIDCallback: IOHIDManagerOpen returned: %" PRIu32 " (0x%" PRIx32 ")\n", (uint32_t)ior, (uint32_t)ior);
if (ior == kIOReturnNotPermitted) {
msg->i.f("b2 has not been granted permission to monitor keyboard input.\n");
msg->i.f("The emulated BBC will not respond properly to the Caps Lock key!\n");
msg->i.f("For more info, please see https://github.com/tom-seddon/b2/blob/master/doc/Installing-on-OSX.md\n");
} else {
msg->i.f("InitHIDCallback: IOHIDManagerOpen returned: %" PRIu32 " (0x%" PRIx32 ")\n", (uint32_t)ior, (uint32_t)ior);
}
goto cleanup;
}

Expand Down

0 comments on commit 844adac

Please sign in to comment.