Skip to content

Commit

Permalink
ignore any keyboard named "Karabiner ..." as it is VirtualHID / output
Browse files Browse the repository at this point in the history
Examples:
Karabiner VirtualHIDKeyboard
Karabiner DriverKit VirtualHIDKeyboard 1.6.0
Karabiner DriverKit VirtualHIDKeyboard 1.7.0
  • Loading branch information
brttbndr committed Dec 27, 2023
1 parent 1c4641f commit a525a00
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 a525a00

Please sign in to comment.