• Stars
    star
    223
  • Rank 178,458 (Top 4 %)
  • Language
    C++
  • License
    The Unlicense
  • Created over 4 years ago
  • Updated 3 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Build Status License

Karabiner-DriverKit-VirtualHIDDevice

Virtual devices (keyboard and mouse) implementation for macOS using DriverKit.

Supported systems

  • macOS 12 Monterey
    • Both Intel-based Macs and Apple Silicon Macs
  • macOS 11 Big Sur
    • Both Intel-based Macs and Apple Silicon Macs

Status

  • Implemented:
    • Extension manager
    • Virtual HID keyboard
    • Virtual HID pointing
    • Virtual HID device client

Documents

Screenshots

  • System Preferences (macOS detects the virtual keyboard)

    System Preferences


Usage

  1. Open dist/Karabiner-DriverKit-VirtualHIDDevice-x.x.x.pkg.

  2. Install files via installer.

  3. Execute the following command in Terminal.

    /Applications/.Karabiner-VirtualHIDDevice-Manager.app/Contents/MacOS/Karabiner-VirtualHIDDevice-Manager activate
  4. Run a client program to test the driver extension.

    git clone --depth 1 https://github.com/pqrs-org/Karabiner-DriverKit-VirtualHIDDevice.git
    cd Karabiner-DriverKit-VirtualHIDDevice/examples/virtual-hid-device-service-client
    brew install xcodegen
    make
    make run

Uninstallation

  1. Run uninstaller in Terminal.

    bash '/Library/Application Support/org.pqrs/Karabiner-DriverKit-VirtualHIDDevice/scripts/uninstall/deactivate_driver.sh'
    sudo bash '/Library/Application Support/org.pqrs/Karabiner-DriverKit-VirtualHIDDevice/scripts/uninstall/remove_files.sh'

Installed files

  • /Applications/.Karabiner-VirtualHIDDevice-Manager.app
  • /Library/Application Support/org.pqrs/Karabiner-DriverKit-VirtualHIDDevice
  • /Library/LaunchDaemons/org.pqrs.Karabiner-DriverKit-VirtualHIDDeviceClient.plist
  • /Library/Application Support/org.pqrs/tmp
  • /var/log/karabiner

For developers

How to build

System requirements to build Karabiner-Elements:

  • macOS 11+
  • Xcode 13.0 (You need to hold Xcode version to 13.0 because Xcode 13.1 generate binary which does not work on macOS 11 Big Sur.)
  • Command Line Tools for Xcode
  • XcodeGen

Note

A provisioning profile which supports com.apple.developer.driverkit is required to build a driver extension since Xcode 12.

If you want to start without a valid provisioning profile, use Xcode 11 and Karabiner-DriverKit-VirtualHIDDevice v0.11.0.

Steps

  1. Gain the DriverKit entitlements to be able to create a provisioning profile which supports com.apple.developer.driverkit. Specifically, follow the instructions on Requesting Entitlements for DriverKit Development

    Note: This process may take some time to complete on Apple's end.

    If you want to start without the request, use Xcode 11 and Karabiner-DriverKit-VirtualHIDDevice v0.11.0. (See above note)

  2. Create a Developer ID distribution provisioning profile for org.pqrs.Karabiner-DriverKit-VirtualHIDDevice with com.apple.developer.driverkit entitlement.

    Generate a Provisioning Profile
  3. Replace CODE_SIGN_IDENTITY at src/scripts/codesign.sh with yours.

    Find your codesign identity by executing the following command in Terminal.

    security find-identity -p codesigning -v

    The result is as follows.

    1) 8D660191481C98F5C56630847A6C39D95C166F22 "Developer ID Application: Fumihiko Takayama (G43BCU2T37)"
    2) 6B9AF0D3B3147A69C5E713773ADD9707CB3480D9 "Apple Development: Fumihiko Takayama (YVB3SM6ECS)"
    3) 637B86ED1C06AE99854E9F5A5DCE02DA58F2BBF4 "Mac Developer: Fumihiko Takayama (YVB3SM6ECS)"
    4) 987BC26C6474DF0C0AF8BEA797354873EC83DC96 "Apple Distribution: Fumihiko Takayama (G43BCU2T37)"
        4 valid identities found
    

    Choose one of them (e.g., 8D660191481C98F5C56630847A6C39D95C166F22) and replace existing CODE_SIGN_IDENTITY with yours as follows.

    # Replace with your identity
    readonly CODE_SIGN_IDENTITY=8D660191481C98F5C56630847A6C39D95C166F22
  4. Replace team identifier, domain and embedded.provisionprofile.

    • Search G43BCU2T37 and replace them with your team identifier.

      git grep G43BCU2T37 src/
    • Search org.pqrs and org_pqrs, then replace them with your domain.

      git grep org.pqrs src/
      git grep org_pqrs src/
    • Replace embedded.provisionprofile file with yours.

      find * -name 'embedded.provisionprofile'
  5. Build by the following command in terminal.

    make package

    dist/Karabiner-DriverKit-VirtualHIDDevice-X.X.X.pkg will be generated.

Components

Karabiner-DriverKit-VirtualHIDDevice consists the following components.

  • Extension Manager (including DriverKit driver)
    • /Applications/.Karabiner-VirtualHIDDevice-Manager.app
    • It provides a command line interface to activate or deactivate DriverKit driver.
  • VirtualHIDDeviceClient
    • /Library/Application Support/org.pqrs/Karabiner-DriverKit-VirtualHIDDevice/Applications/Karabiner-DriverKit-VirtualHIDDeviceClient.app
    • It mediates between the client app and the driver.
    • It allows apps to communicate with the virtual device even if the app is not signed with pqrs.org's code signing identity. (The client app must be running with root privileges.)
  • Client apps
    • Client apps are not included in the distributed package.
    • For example, you can build the client app from examples/virtual-hid-device-service-client in this repository.
    • Client apps can send input events by communicating with VirtualHIDDeviceClient via UNIX domain socket. (/Library/Application Support/org.pqrs/tmp/rootonly/vhidd_server/*.sock)

components.svg

Version files

  • version:
    • Karabiner-DriverKit-VirtualHIDDevice package version.
    • Increment when any components are updated.
  • driver-version:
    • DriverKit driver internal version.
    • Increment when the driver source code is updated.

More Repositories

1

Karabiner-Elements

Karabiner-Elements is a powerful utility for keyboard customization on macOS Sierra (10.12) or later.
C++
18,651
star
2

Karabiner-archived

Karabiner (KeyRemap4MacBook) is a powerful utility for keyboard customization.
C++
3,817
star
3

KE-complex_modifications

Karabiner-Elements complex_modifications rules
JavaScript
1,306
star
4

Seil

Seil (PCKeyboardHack) applies a patch to a keyboard driver. You can change CapsLock behavior, and activate dead keys on non-Apple keyboard.
Objective-C
571
star
5

ShowyEdge

A visible indicator of the current input source for macOS.
Swift
301
star
6

Tinkle

Swift
82
star
7

osx-event-observer-examples

Objective-C++
68
star
8

Karabiner-VirtualHIDDevice-archived

Karabiner-VirtualHIDDevice is a virtual HID device driver for macOS.
C++
55
star
9

TrueWidget

Swift
44
star
10

NoEjectDelay

NoEjectDelay clears the eject key delay. Use this software when you change the eject key behavior in KeyRemap4MacBook.
Shell
35
star
11

osx-hid-inspector

C++
26
star
12

pqrs.org-old

Source code of http://pqrs.org/
HTML
22
star
13

repository-overview

Overview of pqrs.org repositories
21
star
14

BulletGBA

C++
16
star
15

disable-draganddrop-tb

A Thunderbird add-on which disables drag and drop on the folder tree in order to prevent unintended folder movement.
JavaScript
10
star
16

Vulkanon

C++
8
star
17

NesterDC

C
5
star
18

cpp-osx-launchctl

C++
5
star
19

cpp-osx-iokit_service_monitor

C++
5
star
20

ComboStick

A mouse that combines and operates two sticks simultaneously
5
star
21

cpp-osx-iokit_hid_element

C++
4
star
22

pqrs.org

HTML
4
star
23

cpp-osx-iokit_registry_entry

C++
3
star
24

cpp-osx-system_preferences_monitor

C++
3
star
25

cpp-osx-accessibility

C++
3
star
26

cpp-osx-iokit_iterator

C++
3
star
27

cpp-osx-system_preferences

C++
3
star
28

AXAlert

AXAlert shows an alert message when "access for assistive devices" is enabled.
Objective-C
3
star
29

cpp-osx-iokit_types

C++
3
star
30

objc-weakify

Objective-C
2
star
31

cpp-osx-iokit_hid_manager

C++
2
star
32

cpp-process

C++
2
star
33

cpp-osx-cg_event

C++
2
star
34

cpp-thread_wait

C++
2
star
35

cpp-osx-codesign

C++
2
star
36

cpp-osx-iokit_hid_system

C++
2
star
37

gh-pages-karabiner-elements.pqrs.org

Makefile
2
star
38

cpp-osx-os_kext_return

C++
2
star
39

gh-pages-ke-complex-modifications.pqrs.org

2
star
40

cpp-json

C++
2
star
41

dcgnuboy

C
1
star
42

cpp-osx-json_file_monitor

C++
1
star
43

cget-recipes

Python
1
star
44

KE-complex_modifications-core

TypeScript
1
star
45

cpp-osx-iokit_hid_value

C++
1
star
46

cpp-filesystem

C++
1
star
47

cpp-osx-session

C++
1
star
48

cpp-osx-process_info

C++
1
star
49

cpp-cf-number

C++
1
star
50

cpp-osx-input_source

C++
1
star
51

cpp-osx-iokit_hid_device

C++
1
star
52

cpp-osx-iokit_object_ptr

C++
1
star
53

cpp-osx-iokit_hid_device_open_checker

C++
1
star
54

cpp-osx-frontmost_application_monitor

C++
1
star
55

cpp-osx-kern_return

C++
1
star
56

cpp-cf-json

C++
1
star
57

cpp-osx-input_source_monitor

C++
1
star
58

cpp-osx-iokit_hid_queue_value_monitor

C++
1
star
59

cpp-osx-input_source_selector

C++
1
star
60

cpp-osx-chrono

C++
1
star
61

cpp-cf-string

C++
1
star
62

cpp-cf-run_loop_thread

C++
1
star
63

cpp-osx-cg_display

C++
1
star
64

cpp-osx-iokit_power_management

C++
1
star
65

cpp-cf-url

C++
1
star
66

cpp-osx-launch_services

C++
1
star
67

cpp-gcd

C++
1
star
68

cpp-hid

C++
1
star
69

cpp-cf-dictionary

C++
1
star
70

cpp-spdlog

C++
1
star
71

cpp-cf-array

C++
1
star
72

cpp-osx-workspace

C++
1
star
73

cpp-osx-file_monitor

C++
1
star
74

cpp-dispatcher

C++
1
star
75

cpp-osx-iokit_return

C++
1
star
76

cpp-osx-iokit_hid_event_system_client

C++
1
star
77

cpp-osx-iokit_hid_device_report_monitor

C++
1
star
78

cpp-cf-cf_ptr

C++
1
star
79

cpp-cf-boolean

C++
1
star
80

cpp-cf-set

C++
1
star