Skip to content

Commit

Permalink
Merge pull request #716 from vosaica/Upgrade-DriverKit-VirtualHIDDevice
Browse files Browse the repository at this point in the history
[Mac] Upgrade Karabiner-DriverKit-VirtualHIDDevice to v2.1.0
  • Loading branch information
slotThe committed Oct 25, 2023
2 parents a1aea16 + a96f039 commit 1b2ec00
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 6 deletions.
2 changes: 1 addition & 1 deletion c_src/mac/Karabiner-DriverKit-VirtualHIDDevice
5 changes: 3 additions & 2 deletions c_src/mac/dext.cpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#include <filesystem> // Include this before virtual_hid_device_service.hpp to avoid compile error

#include "keyio_mac.hpp"

#include "virtual_hid_device_driver.hpp"
Expand All @@ -16,8 +18,7 @@ static pqrs::karabiner::driverkit::virtual_hid_device_driver::hid_report::consum

int init_sink() {
pqrs::dispatcher::extra::initialize_shared_dispatcher();
std::filesystem::path client_socket_file_path("/tmp/karabiner_driverkit_virtual_hid_device_service_client.sock");
client = new pqrs::karabiner::driverkit::virtual_hid_device_service::client(client_socket_file_path);
client = new pqrs::karabiner::driverkit::virtual_hid_device_service::client();
auto copy = client;
client->async_driver_loaded();
client->async_driver_version_matched();
Expand Down
10 changes: 8 additions & 2 deletions c_src/mac/keyio_mac.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,12 @@
#include <map>
#include <iostream>
#include <mach/mach_error.h>
#include <AvailabilityMacros.h>

/* The name was changed from "Master" to "Main" in Apple SDK 12.0 (Monterey) */
#if !defined (MAC_OS_X_VERSION_12_0) || (MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_12_0)
#define kIOMainPortDefault kIOMasterPortDefault
#endif

int init_sink(void);
int exit_sink(void);
Expand Down Expand Up @@ -157,7 +163,7 @@ void monitor_kb(char *product) {
CFRelease(cfValue);
io_iterator_t iter = IO_OBJECT_NULL;
CFRetain(matching_dictionary);
kr = IOServiceGetMatchingServices(kIOMasterPortDefault,
kr = IOServiceGetMatchingServices(kIOMainPortDefault,
matching_dictionary,
&iter);
if(kr != KERN_SUCCESS) {
Expand All @@ -166,7 +172,7 @@ void monitor_kb(char *product) {
}
listener_loop = CFRunLoopGetCurrent();
open_matching_devices(product, iter);
IONotificationPortRef notification_port = IONotificationPortCreate(kIOMasterPortDefault);
IONotificationPortRef notification_port = IONotificationPortCreate(kIOMainPortDefault);
CFRunLoopSourceRef notification_source = IONotificationPortGetRunLoopSource(notification_port);
CFRunLoopAddSource(listener_loop, notification_source, kCFRunLoopDefaultMode);
CFRetain(matching_dictionary);
Expand Down
2 changes: 1 addition & 1 deletion c_src/mac/list-keyboards.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ int main() {
CFDictionarySetValue(matching_dictionary,CFSTR(kIOHIDDeviceUsageKey),cfValue);
CFRelease(cfValue);
io_iterator_t iter = IO_OBJECT_NULL;
kern_return_t r = IOServiceGetMatchingServices(kIOMasterPortDefault,
kern_return_t r = IOServiceGetMatchingServices(kIOMainPortDefault,
matching_dictionary,
&iter);
if(r != KERN_SUCCESS) {
Expand Down

0 comments on commit 1b2ec00

Please sign in to comment.