Skip to content

Commit

Permalink
Merge pull request #781 from brttbndr/ignore-karabiner-kbs
Browse files Browse the repository at this point in the history
Mac: ignore keyboards named "Karabiner ..."
  • Loading branch information
slotThe committed Jan 12, 2024
2 parents 1c4641f + 9858c94 commit 5f1f9cd
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions c_src/mac/keyio_mac.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ void open_matching_devices(char *product, io_iterator_t iter) {
return;
}
}
CFStringRef cfkarabiner = CFStringCreateWithCString(kCFAllocatorDefault, "Karabiner VirtualHIDKeyboard", CFStringGetSystemEncoding());
CFStringRef cfkarabiner = CFStringCreateWithCString(kCFAllocatorDefault, "Karabiner ", CFStringGetSystemEncoding());
if(cfkarabiner == NULL) {
print_iokit_error("CFStringCreateWithCString");
if(product) {
Expand All @@ -89,7 +89,9 @@ void open_matching_devices(char *product, io_iterator_t iter) {
print_iokit_error("IORegistryEntryCreateCFProperty");
continue;
}
bool match = (CFStringCompare(cfcurr, cfkarabiner, 0) != kCFCompareEqualTo);

// any device named "Karabiner ..." should be ignored
bool match = !CFStringHasPrefix(cfcurr, cfkarabiner);
if(product) {
match = match && (CFStringCompare(cfcurr, cfproduct, 0) == kCFCompareEqualTo);
}
Expand Down

0 comments on commit 5f1f9cd

Please sign in to comment.